From b1ca45fd7837ace7c71234d016e00bd5465a3af8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 20 Jan 2022 18:46:06 +0100 Subject: [PATCH 1/5] GH Actions: re-work the integration tests This removes three keys from the integration test matrix in favour of adding steps for each of those options to the job. * The GitHub workspace is cleaned up between each run. * The Composer cache is removed between each run. This means that, in effect, the tests are being run in the same way as previously (clean install), but sequentially in one job instead of in parallel in different builds. This slims down the number of builds per run from 197 to 29. --- .github/workflows/continuous-integration.yml | 104 ++++++++++++++++--- 1 file changed, 91 insertions(+), 13 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index a863f9a..453c964 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -108,18 +108,9 @@ jobs: composer-version: - "v1" - "v2" - composer-options: - - "--ignore-platform-reqs" - - "" working-directory: - "tests/fixtures/with-lock-file" - "" - ignore-cache: - - "yes" - - "" - custom-cache-key: - - "my-super-custom-cache-key" - - "" steps: - name: "Checkout repository" uses: "actions/checkout@v2" @@ -129,11 +120,98 @@ jobs: php-version: "latest" tools: "composer:${{ matrix.composer-version }}" coverage: "none" - - name: "Run composer-install action" + + - name: "Test: plain install" uses: ./ with: + working-directory: "${{ matrix.working-directory }}" dependency-versions: "${{ matrix.dependency-versions }}" - composer-options: "${{ matrix.composer-options }}" + + - name: Clean up between tests + run: | + git clean -ffdx && git reset --hard HEAD + composer clear-cache + + - name: "Test: ignore platform reqs" + uses: ./ + with: working-directory: "${{ matrix.working-directory }}" - ignore-cache: "${{ matrix.ignore-cache }}" - custom-cache-key: "${{ matrix.custom-cache-key }}" + dependency-versions: "${{ matrix.dependency-versions }}" + composer-options: '--ignore-platform-reqs' + + - name: Clean up between tests + run: | + git clean -ffdx && git reset --hard HEAD + composer clear-cache + + - name: "Test: ignore platform reqs, ignore cache" + uses: ./ + with: + working-directory: "${{ matrix.working-directory }}" + dependency-versions: "${{ matrix.dependency-versions }}" + composer-options: '--ignore-platform-reqs' + ignore-cache: 'yes' + + - name: Clean up between tests + run: | + git clean -ffdx && git reset --hard HEAD + composer clear-cache + + - name: "Test: ignore platform reqs, custom cache key" + uses: ./ + with: + working-directory: "${{ matrix.working-directory }}" + dependency-versions: "${{ matrix.dependency-versions }}" + composer-options: '--ignore-platform-reqs' + custom-cache-key: 'my-super-custom-cache-key' + + - name: Clean up between tests + run: | + git clean -ffdx && git reset --hard HEAD + composer clear-cache + + - name: "Test: ignore platform reqs, ignore cache, custom cache key" + uses: ./ + with: + working-directory: "${{ matrix.working-directory }}" + dependency-versions: "${{ matrix.dependency-versions }}" + composer-options: '--ignore-platform-reqs' + ignore-cache: 'yes' + custom-cache-key: 'my-super-custom-cache-key' + + - name: Clean up between tests + run: | + git clean -ffdx && git reset --hard HEAD + composer clear-cache + + - name: "Test: ignore cache" + uses: ./ + with: + working-directory: "${{ matrix.working-directory }}" + dependency-versions: "${{ matrix.dependency-versions }}" + ignore-cache: 'yes' + + - name: Clean up between tests + run: | + git clean -ffdx && git reset --hard HEAD + composer clear-cache + + - name: "Test: ignore cache, custom cache key" + uses: ./ + with: + working-directory: "${{ matrix.working-directory }}" + dependency-versions: "${{ matrix.dependency-versions }}" + ignore-cache: 'yes' + custom-cache-key: 'my-super-custom-cache-key' + + - name: Clean up between tests + run: | + git clean -ffdx && git reset --hard HEAD + composer clear-cache + + - name: "Test: custom cache key" + uses: ./ + with: + working-directory: "${{ matrix.working-directory }}" + dependency-versions: "${{ matrix.dependency-versions }}" + custom-cache-key: 'my-super-custom-cache-key' From c267ed6960ee08dead34e275c9a931906cc40e21 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 20 Jan 2022 19:02:18 +0100 Subject: [PATCH 2/5] GH Actions: run integration tests for additional situations This adds the `tests/fixtures/no-lock-file` and `tests/fixtures/out-of-sync-lock` working directories to the matrix for the integration tests to test these situations more thoroughly on each commit as well. Fixes 219 --- .github/workflows/continuous-integration.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 453c964..b6341ca 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -110,6 +110,8 @@ jobs: - "v2" working-directory: - "tests/fixtures/with-lock-file" + - "tests/fixtures/no-lock-file" + - "tests/fixtures/out-of-sync-lock" - "" steps: - name: "Checkout repository" From 3454cf5db5e564c9c84907fb8804bc7ace7d69b6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 20 Jan 2022 19:08:53 +0100 Subject: [PATCH 3/5] GH Actions: add extra job for unclean install test Add a job which tests "unclean" installs, i.e. running the action when there is already a `vendor` directory and a Composer `downloads` directory in place. --- .github/workflows/continuous-integration.yml | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index b6341ca..a9e32f3 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -217,3 +217,38 @@ jobs: working-directory: "${{ matrix.working-directory }}" dependency-versions: "${{ matrix.dependency-versions }}" custom-cache-key: 'my-super-custom-cache-key' + + run-no-cleanup: + needs: test + name: "Run unclean" + runs-on: "${{ matrix.operating-system }}" + strategy: + matrix: + operating-system: + - "ubuntu-latest" + - "windows-latest" + composer-version: + - "v1" + - "v2" + steps: + - name: "Checkout repository" + uses: "actions/checkout@v2" + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "latest" + tools: "composer:${{ matrix.composer-version }}" + coverage: "none" + + - name: "Test: plain install" + uses: ./ + + - name: "Test: switch to lowest dependencies" + uses: ./ + with: + dependency-versions: 'lowest' + + - name: "Test: switch to highest dependencies" + uses: ./ + with: + dependency-versions: 'highest' From 92473893ae291e9f3ad7750419e9b867b7346d30 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 21 Jan 2022 04:21:08 +0100 Subject: [PATCH 4/5] Composer: require-dev the package used for testing .. in the root `composer.json`. --- composer.json | 4 ++-- composer.lock | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index d9101f4..82bdca7 100644 --- a/composer.json +++ b/composer.json @@ -9,8 +9,8 @@ "email": "ben@benramsey.com" } ], - "require": { - "ehime/hello-world": "1.0.5" + "require-dev": { + "ehime/hello-world": "^1.0.0" }, "config": { "allow-plugins": false diff --git a/composer.lock b/composer.lock index 983d1ae..66406ce 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,9 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "07afce4d403282b01344497e2b8ba6a9", - "packages": [ + "content-hash": "52abd0fd24f907ced897a9e6adeab5bf", + "packages": [], + "packages-dev": [ { "name": "ehime/hello-world", "version": "1.0.5", @@ -56,7 +57,6 @@ "time": "2015-07-31T17:53:36+00:00" } ], - "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [], From a4633e01b72b523a528b2352eadd16ea60150bf7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 21 Jan 2022 04:26:09 +0100 Subject: [PATCH 5/5] Tests: update version constraints in test fixtures ... to allow for installing a wider range of versions of the `ehime/hello-world` package. Includes locking the version for the `with-lock-file` test to `1.0.3` so there are higher and lower versions to switch to during the tests and switching the "unclean" test to use that fixture as a base. --- .github/workflows/continuous-integration.yml | 4 +++ tests/expect/composer.json | 2 +- tests/expect/composer.lock | 2 +- tests/fixtures/no-lock-file/composer.json | 2 +- tests/fixtures/with-lock-file/composer.json | 2 +- tests/fixtures/with-lock-file/composer.lock | 30 ++++++-------------- 6 files changed, 17 insertions(+), 25 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index a9e32f3..e416b84 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -242,13 +242,17 @@ jobs: - name: "Test: plain install" uses: ./ + with: + working-directory: 'tests/fixtures/with-lock-file' - name: "Test: switch to lowest dependencies" uses: ./ with: + working-directory: 'tests/fixtures/with-lock-file' dependency-versions: 'lowest' - name: "Test: switch to highest dependencies" uses: ./ with: + working-directory: 'tests/fixtures/with-lock-file' dependency-versions: 'highest' diff --git a/tests/expect/composer.json b/tests/expect/composer.json index a98134e..42ccd13 100644 --- a/tests/expect/composer.json +++ b/tests/expect/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "ehime/hello-world": "1.0.5" + "ehime/hello-world": "^1.0.0" }, "config": { "allow-plugins": false diff --git a/tests/expect/composer.lock b/tests/expect/composer.lock index 47151b3..f76f733 100644 --- a/tests/expect/composer.lock +++ b/tests/expect/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e037e746895f35129420cbf41acc8908", + "content-hash": "6da8813786f5c3143608266fa0cf0a17", "packages": [ { "name": "ehime/hello-world", diff --git a/tests/fixtures/no-lock-file/composer.json b/tests/fixtures/no-lock-file/composer.json index 2cec593..6eefeaf 100644 --- a/tests/fixtures/no-lock-file/composer.json +++ b/tests/fixtures/no-lock-file/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "ehime/hello-world": "1.0.5" + "ehime/hello-world": "^1.0.0" }, "config": { "allow-plugins": false diff --git a/tests/fixtures/with-lock-file/composer.json b/tests/fixtures/with-lock-file/composer.json index 8b17281..0dfee7a 100644 --- a/tests/fixtures/with-lock-file/composer.json +++ b/tests/fixtures/with-lock-file/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "ehime/hello-world": "1.0.5" + "ehime/hello-world": "^1.0.0" }, "config": { "allow-plugins": false diff --git a/tests/fixtures/with-lock-file/composer.lock b/tests/fixtures/with-lock-file/composer.lock index f488e4e..e50b7ce 100644 --- a/tests/fixtures/with-lock-file/composer.lock +++ b/tests/fixtures/with-lock-file/composer.lock @@ -4,28 +4,24 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "aa5dffd9f21d5d44ce358b01b329e78b", + "content-hash": "091919c4ac368d87445398fc8c8c2696", "packages": [ { "name": "ehime/hello-world", - "version": "1.0.5", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/ehime/hello-world.git", - "reference": "b1c8cdd2c11272d8c5deec7816e51fa5374217c1" + "reference": "033c81f43e6768e817219ab71c6073e6d5b8b094" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ehime/hello-world/zipball/b1c8cdd2c11272d8c5deec7816e51fa5374217c1", - "reference": "b1c8cdd2c11272d8c5deec7816e51fa5374217c1", + "url": "https://api.github.com/repos/ehime/hello-world/zipball/033c81f43e6768e817219ab71c6073e6d5b8b094", + "reference": "033c81f43e6768e817219ab71c6073e6d5b8b094", "shasum": "" }, "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "mockery/mockery": "0.8.*", - "phpunit/phpunit": "4.3.5" + "php": ">=5.3.0" }, "type": "library", "autoload": { @@ -34,26 +30,18 @@ } }, "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], "authors": [ { "name": "Jd Daniel", "email": "dodomeki@gmail.com" } ], - "description": "Sample Composer project", - "keywords": [ - "helloworld", - "sample", - "test" - ], + "description": "My first Composer project", "support": { "issues": "https://github.com/ehime/hello-world/issues", - "source": "https://github.com/ehime/hello-world/tree/1.0.5" + "source": "https://github.com/ehime/hello-world/tree/1.0.3" }, - "time": "2015-07-31T17:53:36+00:00" + "time": "2015-07-31T17:46:00+00:00" } ], "packages-dev": [],