-
Notifications
You must be signed in to change notification settings - Fork 2
192 lines (153 loc) · 6.49 KB
/
main.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
name: CI
on:
push:
pull_request:
release:
types: [published]
workflow_dispatch:
schedule:
- cron: "23 4 5 * *"
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 18.x, 20.x ]
php-version: [ 8.1, 8.2, 8.3 ]
name: Lint on Node${{matrix.node-version}}, PHP${{ matrix.php-version }}
steps:
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
ini-file: apps/switchboardbridge/tests/php.ini
tools: phpcs, phpcbf
- uses: actions/checkout@v4
name: Checkout switchboardbridge
- name: Install npm dependencies for switchboardbridge
run: npm ci --force --save-dev
- name: Style checking
continue-on-error: true
run: npm run stylelint
- name: Fix Style Lint
run: npm run stylelint:fix
- name: Js Lint checking
continue-on-error: true
run: npm run lint
- name: Fix Js Lint
run: npm run lint:fix
- name: PHP lint and fix
continue-on-error: true
run: phpcbf --extensions=php --ignore=*/tests/*,*/node_modules/* .
- name: PHP lint verify
run: phpcs --extensions=php --ignore=*/tests/*,*/node_modules/* .
- name: Archive workspace
run: tar cf switchboardbridge-lint_node${{matrix.node-version}}_php${{ matrix.php-version }}.zip --exclude=./switchboardbridge-lint_node${{matrix.node-version}}_php${{ matrix.php-version }}.zip .
- name: Upload lint result workspace
uses: actions/upload-artifact@v4
with:
name: switchboardbridge-lint_node${{matrix.node-version}}_php${{ matrix.php-version }}
path: switchboardbridge-lint_node${{matrix.node-version}}_php${{ matrix.php-version }}.zip
build:
needs: [lint]
runs-on: ubuntu-latest
name: Build Js on Node${{matrix.node-version}}, PHP${{ matrix.php-version }}
strategy:
matrix:
node-version: [ 18.x, 20.x ]
php-version: [ 8.1, 8.2, 8.3 ]
steps:
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Download lint job workspace
uses: actions/download-artifact@v4
with:
name: switchboardbridge-lint_node${{matrix.node-version}}_php${{ matrix.php-version }}
- name: Extract workspace
run: tar xf switchboardbridge-lint_node${{matrix.node-version}}_php${{ matrix.php-version }}.zip .
- name: Build target Js
run: npm run build
- name: Archive workspace
run: tar cf switchboardbridge-build_node${{matrix.node-version}}_php${{ matrix.php-version }}.zip --exclude=./switchboardbridge-build_node${{matrix.node-version}}_php${{ matrix.php-version }}.zip .
- name: Upload build result workspace
uses: actions/upload-artifact@v4
with:
name: switchboardbridge-build_node${{matrix.node-version}}_php${{ matrix.php-version }}
path: switchboardbridge-build_node${{matrix.node-version}}_php${{ matrix.php-version }}.zip
deploy:
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20.x ]
nextcloud-version-branch: [ stable28, stable29 ] # see https://github.com/nextcloud/server/branches
php-version: [ 8.1, 8.2, 8.3 ]
name: Deploy on NC${{matrix.nextcloud-version-branch}}, PHP${{ matrix.php-version }}
env:
DB_DATABASE: oc_autotest
DB_ROOT: root
steps:
- name: Setup MySQL
run: |
sudo /etc/init.d/mysql start
mysql -u${{ env.DB_ROOT }} -p${{ env.DB_ROOT }} -e 'CREATE DATABASE ${{ env.DB_DATABASE }};'
mysql -u${{ env.DB_ROOT }} -p${{ env.DB_ROOT }} -e "CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY '';"
mysql -u${{ env.DB_ROOT }} -p${{ env.DB_ROOT }} -e "grant all on oc_autotest.* to 'oc_autotest'@'localhost';"
- uses: actions/checkout@v4
name: Checkout Nextcloud ${{matrix.nextcloud-version-branch}}
with:
repository: nextcloud/server
ref: ${{matrix.nextcloud-version-branch}}
fetch-depth: 1
submodules: true # 'Composer autoloader' is required in order to run the code check
- name: Add switchboardbridge to nextcloud from build job workspace
uses: actions/download-artifact@v4
with:
name: switchboardbridge-build_node${{matrix.node-version}}_php${{ matrix.php-version }} # node version not relevant for this job
- name: Extract workspace
run: |
mkdir apps/switchboardbridge
tar xf switchboardbridge-build_node${{matrix.node-version}}_php${{ matrix.php-version }}.zip -C apps/switchboardbridge
- name: Install PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
ini-file: apps/switchboardbridge/tests/php.ini
tools: phpcs, phpcbf
- name: Configure NC
run: |
mkdir data
./occ maintenance:install --database-name $DB_DATABASE --database-user oc_autotest --admin-user admin --admin-pass admin --database mysql --database-pass=''
- name: Deploy switchboardbridge plugin
run: |
./occ app:enable switchboardbridge
commit:
needs: [build, deploy]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20.x ]
php-version: [ 8.3 ]
name: Commit from PHP${{ matrix.php-version}} and Node${{ matrix.node-version }}
steps:
- uses: actions/checkout@v4
name: Checkout switchboardbridge
- name: Get switchboardbridge build job workspace
uses: actions/download-artifact@v4
with:
name: switchboardbridge-build_node${{ matrix.node-version }}_php${{ matrix.php-version }}
- name: Extract job build workspace
run: tar xvf switchboardbridge-build_node${{ matrix.node-version }}_php${{ matrix.php-version }}.zip -C . --exclude=.git --exclude=node_modules
- name: Commit lint fixes and target Js
uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: .
file_pattern: '*.php *.js *.map *.css'
disable_globbing: true
commit_message: Apply PHP, CSS and JS auto fix changes