Skip to content

Commit

Permalink
GH Actions: re-work the integration tests (#221)
Browse files Browse the repository at this point in the history
* 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.

* 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

* 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.

* Composer: require-dev the package used for testing

.. in the root `composer.json`.

* 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.

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
  • Loading branch information
jrfnl and jrfnl committed Jan 24, 2022
1 parent f680dac commit 6085843
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 43 deletions.
145 changes: 132 additions & 13 deletions .github/workflows/continuous-integration.yml
Expand Up @@ -108,17 +108,10 @@ 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"
- "tests/fixtures/no-lock-file"
- "tests/fixtures/out-of-sync-lock"
- ""
steps:
- name: "Checkout repository"
Expand All @@ -129,11 +122,137 @@ 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 }}"

- 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 }}"
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 }}"
composer-options: "${{ matrix.composer-options }}"
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 }}"
ignore-cache: "${{ matrix.ignore-cache }}"
custom-cache-key: "${{ matrix.custom-cache-key }}"
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: ./
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'
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/expect/composer.json
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"ehime/hello-world": "1.0.5"
"ehime/hello-world": "^1.0.0"
},
"config": {
"allow-plugins": false
Expand Down
2 changes: 1 addition & 1 deletion tests/expect/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/fixtures/no-lock-file/composer.json
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"ehime/hello-world": "1.0.5"
"ehime/hello-world": "^1.0.0"
},
"config": {
"allow-plugins": false
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/with-lock-file/composer.json
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"ehime/hello-world": "1.0.5"
"ehime/hello-world": "^1.0.0"
},
"config": {
"allow-plugins": false
Expand Down
30 changes: 9 additions & 21 deletions tests/fixtures/with-lock-file/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6085843

Please sign in to comment.