Skip to content

Commit

Permalink
Add caching to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Kolb committed Feb 14, 2024
1 parent 86deb78 commit 9e73ffc
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 16 deletions.
89 changes: 77 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,32 @@ jobs:
name: "Tests on PHP 8.2"
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Setup env
run: cp .github/workflows/.env .env

- name: Cache PHP 8.2 dependencies
id: cache-php-8-2-dependencies
uses: actions/cache@v3
env:
cache-name: cache-php-8-2-dependencies
with:
path: |
~/.cache
vendor
key: ${{ runner.os }}-php-8-2-cache-${{ hashFiles('composer.lock') }}
restore-keys: |
${{ runner.os }}-php-8-2-cache-${{ hashFiles('composer.lock') }}
- name: Install
run: |
cp .github/workflows/.env .env
make install-8.2
if: steps.cache-php-8-2-dependencies.outputs.cache-hit != 'true'
run: make install-8.2

- name: Run PHP tests
run: make php-8.2-tests-ci

- name: Upload to Codecov
uses: codecov/codecov-action@v2
with:
Expand All @@ -24,34 +43,80 @@ jobs:
name: "Tests on PHP 8.3"
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Setup env
run: cp .github/workflows/.env .env

- name: Cache PHP 8.3 dependencies
id: cache-php-8-3-dependencies
uses: actions/cache@v3
env:
cache-name: cache-php-8-3-dependencies
with:
path: |
~/.cache
vendor
key: ${{ runner.os }}-php-8-3-cache-${{ hashFiles('composer.lock') }}
restore-keys: |
${{ runner.os }}-php-8-3-cache-${{ hashFiles('composer.lock') }}
- name: Install
run: |
cp .github/workflows/.env .env
make install-8.3
if: steps.cache-php-8-3-dependencies.outputs.cache-hit != 'true'
run: make install-8.3

- name: Run PHP tests
run: make php-8.3-tests-ci

mutation-testing:
name: "Mutation tests"
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Setup env
run: cp .github/workflows/.env .env

- name: Restore cache for PHP 8.3 dependencies
id: cache-php-8-3-dependencies
uses: actions/cache/restore@v3
with:
path: |
~/.cache
vendor
key: ${{ runner.os }}-php-8-3-cache-${{ hashFiles('composer.lock') }}

- name: Install
run: |
cp .github/workflows/.env .env
make install-8.2
if: steps.cache-php-8-3-dependencies.outputs.cache-hit != 'true'
run: make install-8.3

- name: Run mutation testing
run: make php-mutation-testing-ci

code-validation:
name: "Code validation"
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Setup env
run: cp .github/workflows/.env .env

- name: Restore cache for PHP 8.3 dependencies
id: cache-php-8-3-dependencies
uses: actions/cache/restore@v3
with:
path: |
~/.cache
vendor
key: ${{ runner.os }}-php-8-3-cache-${{ hashFiles('composer.lock') }}

- name: Install
run: |
cp .github/workflows/.env .env
make install
if: steps.cache-php-8-3-dependencies.outputs.cache-hit != 'true'
run: make install-8.3

- name: Run code validation
run: make php-code-validation
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ reset: .reset
.PHONY: .reset
.reset: .down .install .up

## install Install PHP dependencies with the default PHP version (8.1).
## install Install PHP dependencies with the default PHP version (8.3).
.PHONY: .install
install: install-8.2
install: install-8.3

## install-8.2 Install PHP dependencies with PHP 8.2.
.PHONY: install-8.2
Expand All @@ -66,9 +66,9 @@ install-8.2:
install-8.3:
docker-compose run --rm php-8.3 composer install

## php-cli Enter a shell for the default PHP version (8.2).
## php-cli Enter a shell for the default PHP version (8.3).
.PHONY: php-cli
php-cli: php-8.2-cli
php-cli: php-8.3-cli

## php-8.2-cli Enter a shell for PHP 8.2.
.PHONY: php-8.2-cli
Expand Down

0 comments on commit 9e73ffc

Please sign in to comment.