add composer cache to github action #2 #16
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "CI workflow" | |
on: | |
# Triggers the workflow on push or pull request events | |
push: | |
pull_request: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
permissions: | |
contents: "read" | |
jobs: | |
composer: | |
name: "Composer config validation" | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: "actions/checkout@v3" | |
- name: "Validate composer.json" | |
run: "composer validate --strict" | |
php: | |
name: "PHP tests" | |
runs-on: "ubuntu-latest" | |
strategy: | |
matrix: | |
php_version: | |
- "7.2" | |
- "7.4" | |
env: | |
CC_TEST_REPORTER_ID: "c8bc13b8787c6de68ae094688dec7fd7bb3a14445d560194b5785fae2623d489" | |
steps: | |
- name: "GIT checkout" | |
uses: "actions/checkout@v3" | |
- name: "Setup PHP" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
php-version: "${{ matrix.php_version }}" | |
coverage: "xdebug" | |
- name: "PHP syntax validation" | |
run: | | |
php -l src/ | |
php -l tests/ | |
- name: "Get composer cache directory" | |
id: "composer-cache" | |
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT' | |
- name: "Cache composer dependencies" | |
uses: "actions/cache@v3" | |
with: | |
path: "${{ steps.composer-cache.outputs.dir }}" | |
# Use composer.json for key, if composer.lock is not committed. | |
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | |
key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}" | |
restore-keys: "${{ runner.os }}-composer-" | |
- name: "Composer install dependencies" | |
run: "composer install --prefer-dist --no-progress" | |
- name: "CodeClimate Reporter Setup" | |
run: | | |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | |
chmod +x ./cc-test-reporter | |
./cc-test-reporter before-build | |
- name: "PHPUnit tests" | |
run: | | |
php vendor/bin/phpunit --coverage-clover clover.xml --coverage-text | |
export PHPUNIT_EXIT_CODE=$? | |
- name: "CodeClimate report" | |
run: "./cc-test-reporter after-build -t clover" |