generated from ghostwriter/wip
-
-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (106 loc) · 3.95 KB
/
automation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Automation
on:
pull_request:
push:
branches:
- "main"
- "[0-9]+.[0-9]+.x"
- "v[0-9]+"
schedule:
- cron: "0 * * * *" # Runs hourly
workflow_dispatch:
workflow_call:
secrets:
STRYKER_DASHBOARD_API_KEY:
required: false
CODECOV_TOKEN:
required: false
jobs:
matrix:
name: Generate job matrix
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Determine CI Jobs
id: matrix
uses: docker://ghcr.io/ghostwriter/compliance:v1
with:
command: matrix
qa:
name: ${{ matrix.name }} on PHP ${{ matrix.php }} with ${{ matrix.dependency }} dependencies
needs: [matrix]
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.dependency == 'lowest' || matrix.experimental }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
coverage: pcov
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
php-version: ${{ matrix.php }}
tools: composer:v2, infection, phpunit, psalm, rector, symplify/easy-coding-standard
- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ matrix.dependency }}-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ matrix.dependency }}-
- name: Validate composer.json file
working-directory: ${{ github.workspace }}
run: |
if [ ! -f "composer.json" ]; then
echo "composer.json does not exist"
exit 1
fi
composer validate --no-check-publish --no-check-lock --no-interaction --ansi --strict
- name: Install ${{ matrix.dependency }} dependencies
working-directory: ${{ github.workspace }}
run: |
composerDependency="${{ matrix.dependency }}"
composerCommand="update"
composerOptions=("--no-interaction" "--no-progress" "--ansi")
case ${composerDependency} in
highest) composerCommand="update" ;;
lowest) composerOptions+=("--prefer-lowest" "--prefer-stable") ;;
*) composerCommand="install" ;;
esac
# Use the `update` if there is a composer.lock file
if [ ! -f "composer.lock" ]; then
composerCommand="update"
fi
fullCommand="composer ${composerCommand} ${composerOptions[*]}"
echo "Running: ${fullCommand}"
${fullCommand}
- name: Run ${{ matrix.name }} command
run: ${{ matrix.command }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: ${{ matrix.php == '8.2' && matrix.dependency == 'locked' }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ${{ github.workspace }}/.cache/phpunit/
verbose: true