-
Notifications
You must be signed in to change notification settings - Fork 189
130 lines (106 loc) · 3.94 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
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 8.1"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
- 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 --minimum-priority 1
env:
DIFF: ${{ steps.diff.outputs.diff_php }}
- name: "Install PHPCSFixer"
if: ${{ env.DIFF != '' }}
run: wget https://cs.symfony.com/download/php-cs-fixer-v3.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-fixer.php --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 [email protected] --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-81:
name: "PHPUnit (PHP 8.1)"
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.1"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
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 install --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: php bin/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 [email protected]