-
Notifications
You must be signed in to change notification settings - Fork 1
200 lines (169 loc) · 7.15 KB
/
continuous-integration.yaml
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Continuous integration
on:
push:
branches: [ master, release* ]
pull_request:
branches: [ master, release* ]
jobs:
ci:
runs-on: ${{ matrix.operating-system }}
if: "!contains(github.event.head_commit.message, 'ci: add updated coverage_badge.svg')"
concurrency:
group: ci-${{ matrix.php-version }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php-version: [ '7.4', '8.0', '8.1' ]
include:
- php-version: '7.4'
node-version: '18'
coverage: true
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.head_ref || github.ref_name }}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Use Node.js ${{ matrix.node-version }}
if: ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Validate composer.json and composer.lock
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Configure NPM bridge plugin
run: composer config allow-plugins.oat-sa/composer-npm-bridge $([[ "${{ matrix.node-version }}" ]] && echo "true" || echo "false") --no-interaction --no-plugins
- name: Install dependencies
run: composer install --no-progress
- name: Generate localization files
if: ${{ matrix.node-version }}
run: php tao/scripts/tools/GenerateTranslationBundles.php
- name: Front-end tests
if: ${{ matrix.node-version }}
working-directory: tao/views/build
run: |
npm ci
npx grunt connect:test qunit_junit pcisamplestest qtiitempcitest taotest taoclientdiagnostictest taodeliveryrdftest taoitemstest taomediamanagertest taooutcomeuitest taoproctoringtest taoqtiitemtest taoqtitesttest taoqtitestpreviewertest taotaskqueuetest taoteststest --force --reports=../../../junit-reports
- name: Back-end tests
run: ./test.sh ${{ matrix.coverage && '-c' }}
continue-on-error: true
- name: Publish a back-end test report
uses: mikepenz/action-junit-report@v3
id: be-junit
with:
report_paths: 'log/*/junit.xml'
job_summary: false
- name: Publish a front-end test report
if: ${{ matrix.node-version }}
uses: mikepenz/action-junit-report@v3
id: fe-junit
with:
job_summary: false
- name: Parse the the back-end reports
id: report
run: grep testFailed log/*/teamcity.txt -R > /tmp/failures.txt
- name: Build back-end coverage report link
id: report-link
if: ${{ matrix.coverage }}
run: echo formatted='[🔗 Coverage report](https://oat-sa.github.io/tao-community/${{ github.head_ref || github.ref_name }})' >> $GITHUB_OUTPUT
- name: Back-end job summary
uses: mathiasvr/[email protected]
id: be-summary
with:
run: |
cat << EOF
# Back-end summary PHP ${{ matrix.php-version }}
${{ steps.report-link.outputs.formatted }}
|💯 Total|✅ Passed|⏭️ Skipped|❌ Failed|
|-|-|-|-|
|${{ steps.be-junit.outputs.total }}|${{ steps.be-junit.outputs.passed }}|${{ steps.be-junit.outputs.skipped }}|${{ steps.be-junit.outputs.failed }}|
EOF
php ./.github/parse-reports.php
- name: Front-end job summary
if: ${{ matrix.node-version }}
uses: mathiasvr/[email protected]
id: fe-summary
with:
run: |
cat << EOF
# Front-end summary Node ${{ matrix.node-version }}
|💯 Total|✅ Passed|⏭️ Skipped|❌ Failed|
|-|-|-|-|
|${{ steps.fe-junit.outputs.total }}|${{ steps.fe-junit.outputs.passed }}|${{ steps.fe-junit.outputs.skipped }}|${{ steps.fe-junit.outputs.failed }}|
EOF
php ./.github/parse-reports.php
- uses: peter-evans/find-comment@v2
id: be-summary-comment
if: github.event_name == 'pull_request'
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Back-end summary PHP ${{ matrix.php-version }}
- uses: peter-evans/find-comment@v2
id: fe-summary-comment
if: ${{ github.event_name == 'pull_request' && matrix.node-version }}
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Front-end summary Node ${{ matrix.node-version }}
- name: Create or update back-end summary comment
uses: peter-evans/create-or-update-comment@v2
if: github.event_name == 'pull_request'
with:
comment-id: ${{ steps.be-summary-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.be-summary.outputs.stdout }}
edit-mode: replace
- name: Create or update front-end summary comment
uses: peter-evans/create-or-update-comment@v2
if: ${{ github.event_name == 'pull_request' && matrix.node-version }}
with:
comment-id: ${{ steps.fe-summary-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.fe-summary.outputs.stdout }}
edit-mode: replace
- name: Merge coverage reports
run: vendor/bin/phpunit-merger coverage coverage --html=clover clover.xml
if: ${{ matrix.coverage }}
- name: Generate a coverage badge
uses: timkrase/[email protected]
if: ${{ matrix.coverage }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Push a coverage badge
uses: EndBug/add-and-commit@v9
if: ${{ matrix.coverage }}
with:
add: coverage_badge.svg
commit: --signoff
message: 'ci: add updated coverage_badge.svg'
- name: Deploy coverage reports
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ matrix.coverage }}
with:
folder: clover
target-folder: ${{ github.head_ref || github.ref_name }}
single-commit: true
token: ${{ secrets.CI_GITHUB_TOKEN }}
- name: Back-end job summary
run: echo "${{ steps.be-summary.outputs.stdout }}" >> $GITHUB_STEP_SUMMARY
- name: Front-end job summary
if: ${{ matrix.node-version }}
run: echo "${{ steps.fe-summary.outputs.stdout }}" >> $GITHUB_STEP_SUMMARY
- name: Fail the job if back-end tests weren't OK
run: exit ${{ steps.be-junit.outputs.failed }}
- name: Fail the job if front-end tests weren't OK
if: ${{ matrix.node-version }}
run: exit ${{ steps.fe-junit.outputs.failed }}