Skip to content

Commit 5bc53ca

Browse files
Merge pull request #10 from codenamephp/feature/ciInstall
Added CI install task
2 parents eb2ae2e + 45956cf commit 5bc53ca

5 files changed

Lines changed: 101 additions & 8 deletions

File tree

.idea/deployer.npm.iml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/phpunit.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/ci_all.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/task/install/Ci.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* Copyright 2022 Bastian Schwarz <bastian@codename-php.de>.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace de\codenamephp\deployer\npm\task\install;
19+
20+
/**
21+
* Runs a CI install using the ci command that is supposedly faster and more strict than install
22+
*
23+
* @see https://docs.npmjs.com/cli/v6/commands/npm-ci
24+
*/
25+
final class Ci extends AbstractInstallTask {
26+
27+
public const NAME = 'npm:install:ci';
28+
29+
public function getArguments() : array {
30+
return [];
31+
}
32+
33+
public function getDescription() : string {
34+
return 'Runs npm ci to install a project with a clean slate.';
35+
}
36+
37+
public function getName() : string {
38+
return self::NAME;
39+
}
40+
}

test/task/install/CiTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* Copyright 2022 Bastian Schwarz <bastian@codename-php.de>.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace de\codenamephp\deployer\npm\test\task\install;
19+
20+
use de\codenamephp\deployer\command\runner\iRunner;
21+
use de\codenamephp\deployer\npm\command\iNpmCommandFactory;
22+
use de\codenamephp\deployer\npm\task\install\Ci;
23+
use de\codenamephp\deployer\npm\task\install\Production;
24+
use PHPUnit\Framework\TestCase;
25+
26+
final class CiTest extends TestCase {
27+
28+
private Ci $sut;
29+
30+
protected function setUp() : void {
31+
parent::setUp();
32+
33+
$commandFactory = $this->createMock(iNpmCommandFactory::class);
34+
$runner = $this->createMock(iRunner::class);
35+
36+
$this->sut = new Ci($commandFactory, $runner);
37+
}
38+
39+
public function testGetArguments() : void {
40+
self::assertEquals([], $this->sut->getArguments());
41+
}
42+
43+
public function testGetName() : void {
44+
self::assertEquals(Ci::NAME, $this->sut->getName());
45+
}
46+
47+
public function testGEtDescription() : void {
48+
self::assertEquals('Runs npm ci to install a project with a clean slate.', $this->sut->getDescription());
49+
}
50+
}

0 commit comments

Comments
 (0)