-
Notifications
You must be signed in to change notification settings - Fork 186
195 lines (158 loc) · 5.87 KB
/
ci.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
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
name: "CI"
on:
pull_request:
jobs:
cs:
name: "Coding Style"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2
- name: "Install PHP 7.4"
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
- name: "List modified files"
id: diff
run: |
git fetch origin
git diff --name-only --diff-filter=AM origin/${{ github.base_ref }} > git_diff_files.txt
echo "::set-output name=diff_php::$(cat git_diff_files.txt | grep '.\+\.php' | sed ':a;N;$!ba;s/\n/ /g')"
echo "::set-output name=diff_js::$(cat git_diff_files.txt | grep 'Resources/modules/.\+\.js' | sed ':a;N;$!ba;s/\n/ /g')"
- name: "Install PHPMD"
if: ${{ env.DIFF != '' }}
run: wget -c https://phpmd.org/static/latest/phpmd.phar -O phpmd;
env:
DIFF: ${{ steps.diff.outputs.diff_php}}
- name: "Run PHPMD checks"
if: ${{ env.DIFF != '' }}
run: php phpmd `echo "$DIFF" | tr ' ' ','` text phpmd.xml
env:
DIFF: ${{ steps.diff.outputs.diff_php }}
- name: "Install PHPCSFixer"
if: ${{ env.DIFF != '' }}
run: wget https://cs.symfony.com/download/php-cs-fixer-v2.phar -O php-cs-fixer
env:
DIFF: ${{ steps.diff.outputs.diff_php }}
- name: "Run PHPCSFixer checks"
if: ${{ env.DIFF != '' }}
run: php php-cs-fixer fix --dry-run --diff --config=.php_cs --path-mode=intersection `echo "$DIFF"`
env:
PHP_CS_FIXER_IGNORE_ENV: 1
DIFF: ${{ steps.diff.outputs.diff_php }}
- name: "Install ESLint"
if: ${{ env.DIFF != '' }}
run: npm install eslint eslint-plugin-react@7.21.5 --legacy-peer-deps
env:
DIFF: ${{ steps.diff.outputs.diff_js }}
- name: "Run ESLint checks"
if: ${{ env.DIFF != '' }}
run: node_modules/.bin/eslint --ext js --ext jsx `echo "$DIFF"`
env:
DIFF: ${{ steps.diff.outputs.diff_js }}
php-74:
name: "PHPUnit (PHP 7.4)"
needs: cs
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
options: >-
--health-cmd "mysqladmin ping --silent"
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes
-e MYSQL_DATABASE=claroline_test
ports:
- "3306:3306"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2
- name: "Install PHP 7.4"
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
extensions: pdo_mysql
- name: "Cache composer dependencies"
uses: actions/cache@v1
with:
path: "~/.composer/cache"
key: composer-${{ hashFiles('**/composer.json') }}
restore-keys: composer-
- name: "Set project parameters"
run: php bin/configure --default
- name: "Install PHP dependencies with Composer"
run: composer update --no-interaction
- name: "Cache node modules"
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('**/package.json') }}
restore-keys: |
npm-
- name: "Install JS dependencies with NPM"
run: npm install --legacy-peer-deps
- name: "Build JS files with Webpack"
run: npm run webpack
- name: "Setup Claroline platform"
run: php bin/console claroline:install --env=test -vvv
- name: "Run PHPUnit Tests"
run: SYMFONY_DEPRECATIONS_HELPER=weak vendor/bin/simple-phpunit --dont-report-useless-tests
# Created user is not used in the job. This is just a dumb way to test the user creation process.
# We do it after tests because we don't want tests on user parts to be affected by this.
- name: "Create a Claroline user"
run: php bin/console claroline:user:create --env=test -vvv -a John Doe john.doe john.doe john.doe@test.com
php-80:
name: "PHPUnit (PHP 8.0)"
needs: cs
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
options: >-
--health-cmd "mysqladmin ping --silent"
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes
-e MYSQL_DATABASE=claroline_test
ports:
- "3306:3306"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2
- name: "Install PHP 8.0"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.0"
extensions: pdo_mysql
- name: "Cache composer dependencies"
uses: actions/cache@v1
with:
path: "~/.composer/cache"
key: composer-${{ hashFiles('**/composer.json') }}
restore-keys: composer-
- name: "Set project parameters"
run: php bin/configure --default
- name: "Install PHP dependencies with Composer"
run: composer update --no-interaction
- name: "Cache node modules"
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('**/package.json') }}
restore-keys: |
npm-
- name: "Install JS dependencies with NPM"
run: npm install --legacy-peer-deps
- name: "Build JS files with Webpack"
run: npm run webpack
- name: "Setup Claroline platform"
run: php bin/console claroline:install --env=test -vvv
- name: "Run PHPUnit Tests"
run: SYMFONY_DEPRECATIONS_HELPER=weak vendor/bin/simple-phpunit --dont-report-useless-tests
# Created user is not used in the job. This is just a dumb way to test the user creation process.
# We do it after tests because we don't want tests on user parts to be affected by this.
- name: "Create a Claroline user"
run: php bin/console claroline:user:create --env=test -vvv -a John Doe john.doe john.doe john.doe@test.com