Skip to content

Commit 4526e6d

Browse files
committed
chore(CI): Update master php testing versions and workflow templates
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent e86b820 commit 4526e6d

9 files changed

Lines changed: 216 additions & 125 deletions

.github/workflows/appstore-build-publish.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
types: [published]
1111

1212
env:
13-
PHP_VERSION: 7.4
13+
PHP_VERSION: 8.1
1414

1515
jobs:
1616
build_and_publish:
@@ -21,42 +21,42 @@ jobs:
2121

2222
steps:
2323
- name: Check actor permission
24-
uses: skjnldsv/check-actor-permission@v2
24+
uses: skjnldsv/check-actor-permission@e591dbfe838300c007028e1219ca82cc26e8d7c5 # v2.1
2525
with:
2626
require: write
2727

2828
- name: Set app env
2929
run: |
30-
# Split and keep last
30+
# Split and keep last
3131
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
3232
echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
3333
3434
- name: Checkout
35-
uses: actions/checkout@v3
35+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
3636
with:
3737
path: ${{ env.APP_NAME }}
3838

3939
- name: Get appinfo data
4040
id: appinfo
41-
uses: skjnldsv/xpath-action@master
41+
uses: skjnldsv/xpath-action@7e6a7c379d0e9abc8acaef43df403ab4fc4f770c # master
4242
with:
4343
filename: ${{ env.APP_NAME }}/appinfo/info.xml
4444
expression: "//info//dependencies//nextcloud/@min-version"
4545

4646
- name: Read package.json node and npm engines version
47-
uses: skjnldsv/read-package-engines-version-actions@v1.2
47+
uses: skjnldsv/read-package-engines-version-actions@1bdcee71fa343c46b18dc6aceffb4cd1e35209c6 # v1.2
4848
id: versions
4949
# Continue if no package.json
5050
continue-on-error: true
5151
with:
5252
path: ${{ env.APP_NAME }}
53-
fallbackNode: "^12"
54-
fallbackNpm: "^6"
53+
fallbackNode: "^16"
54+
fallbackNpm: "^7"
5555

5656
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
5757
# Skip if no package.json
5858
if: ${{ steps.versions.outputs.nodeVersion }}
59-
uses: actions/setup-node@v3
59+
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
6060
with:
6161
node-version: ${{ steps.versions.outputs.nodeVersion }}
6262

@@ -66,14 +66,16 @@ jobs:
6666
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
6767

6868
- name: Set up php ${{ env.PHP_VERSION }}
69-
uses: shivammathur/setup-php@v2
69+
uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2
7070
with:
7171
php-version: ${{ env.PHP_VERSION }}
7272
coverage: none
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7375

7476
- name: Check composer.json
7577
id: check_composer
76-
uses: andstor/file-existence-action@v1
78+
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
7779
with:
7880
files: "${{ env.APP_NAME }}/composer.json"
7981

@@ -93,15 +95,15 @@ jobs:
9395
9496
- name: Check Krankerl config
9597
id: krankerl
96-
uses: andstor/file-existence-action@v1
98+
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
9799
with:
98100
files: ${{ env.APP_NAME }}/krankerl.toml
99101

100102
- name: Install Krankerl
101103
if: steps.krankerl.outputs.files_exists == 'true'
102104
run: |
103-
wget https://github.com/ChristophWurst/krankerl/releases/download/v0.13.0/krankerl_0.13.0_amd64.deb
104-
sudo dpkg -i krankerl_0.13.0_amd64.deb
105+
wget https://github.com/ChristophWurst/krankerl/releases/download/v0.14.0/krankerl_0.14.0_amd64.deb
106+
sudo dpkg -i krankerl_0.14.0_amd64.deb
105107
106108
- name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with krankerl
107109
if: steps.krankerl.outputs.files_exists == 'true'
@@ -124,7 +126,7 @@ jobs:
124126
unzip latest-$NCVERSION.zip
125127
126128
- name: Checkout server master fallback
127-
uses: actions/checkout@v3
129+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
128130
if: ${{ steps.server-checkout.outcome != 'success' }}
129131
with:
130132
repository: nextcloud/server
@@ -146,7 +148,7 @@ jobs:
146148
tar -zcvf ${{ env.APP_NAME }}.tar.gz ${{ env.APP_NAME }}
147149
148150
- name: Attach tarball to github release
149-
uses: svenstaro/upload-release-action@v2
151+
uses: svenstaro/upload-release-action@133984371c30d34e38222a64855679a414cb7575 # v2
150152
id: attach_to_release
151153
with:
152154
repo_token: ${{ secrets.GITHUB_TOKEN }}
@@ -156,7 +158,7 @@ jobs:
156158
overwrite: true
157159

158160
- name: Upload app to Nextcloud appstore
159-
uses: nextcloud-releases/nextcloud-appstore-push-action@v1
161+
uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1 # v1
160162
with:
161163
app_name: ${{ env.APP_NAME }}
162164
appstore_token: ${{ secrets.APPSTORE_TOKEN }}

.github/workflows/command-rebase.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ on:
99
issue_comment:
1010
types: created
1111

12-
permissions:
13-
contents: read
12+
permissions:
13+
contents: read
1414

1515
jobs:
1616
rebase:
@@ -23,26 +23,26 @@ jobs:
2323

2424
steps:
2525
- name: Add reaction on start
26-
uses: peter-evans/create-or-update-comment@v2
26+
uses: peter-evans/create-or-update-comment@5adcb0bb0f9fb3f95ef05400558bdb3f329ee808 # v2.1.0
2727
with:
2828
token: ${{ secrets.COMMAND_BOT_PAT }}
2929
repository: ${{ github.event.repository.full_name }}
3030
comment-id: ${{ github.event.comment.id }}
3131
reaction-type: "+1"
3232

3333
- name: Checkout the latest code
34-
uses: actions/checkout@v3
34+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
3535
with:
3636
fetch-depth: 0
3737
token: ${{ secrets.COMMAND_BOT_PAT }}
3838

3939
- name: Automatic Rebase
40-
uses: cirrus-actions/rebase@1.7
40+
uses: cirrus-actions/rebase@6e572f08c244e2f04f9beb85a943eb618218714d # 1.7
4141
env:
4242
GITHUB_TOKEN: ${{ secrets.COMMAND_BOT_PAT }}
4343

4444
- name: Add reaction on failure
45-
uses: peter-evans/create-or-update-comment@v2
45+
uses: peter-evans/create-or-update-comment@5adcb0bb0f9fb3f95ef05400558bdb3f329ee808 # v2.1.0
4646
if: failure()
4747
with:
4848
token: ${{ secrets.COMMAND_BOT_PAT }}

.github/workflows/phpunit-mysql.yml

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,17 @@ on:
2828
permissions:
2929
contents: read
3030

31-
concurrency:
31+
concurrency:
3232
group: phpunit-mysql-${{ github.head_ref || github.run_id }}
3333
cancel-in-progress: true
3434

35-
env:
36-
# Location of the phpunit.xml and phpunit.integration.xml files
37-
PHPUNIT_CONFIG: ./tests/phpunit.xml
38-
PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml
39-
4035
jobs:
4136
phpunit-mysql:
4237
runs-on: ubuntu-latest
4338

4439
strategy:
4540
matrix:
46-
php-versions: ['7.4', '8.0', '8.1']
41+
php-versions: ['8.0', '8.1']
4742
server-versions: ['master']
4843

4944
services:
@@ -67,32 +62,33 @@ jobs:
6762
echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
6863
6964
- name: Checkout server
70-
uses: actions/checkout@v3
65+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
7166
with:
7267
submodules: true
7368
repository: nextcloud/server
7469
ref: ${{ matrix.server-versions }}
7570

7671
- name: Checkout app
77-
uses: actions/checkout@v3
72+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
7873
with:
7974
path: apps/${{ env.APP_NAME }}
8075

8176
- name: Set up php ${{ matrix.php-versions }}
82-
uses: shivammathur/setup-php@v2
77+
uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2
8378
with:
8479
php-version: ${{ matrix.php-versions }}
85-
tools: phpunit
8680
extensions: mbstring, iconv, fileinfo, intl, mysql, pdo_mysql
8781
coverage: none
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8884

8985
- name: Check composer file existence
9086
id: check_composer
91-
uses: andstor/file-existence-action@v1
87+
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
9288
with:
9389
files: apps/${{ env.APP_NAME }}/composer.json
9490

95-
- name: Set up PHPUnit
91+
- name: Set up dependencies
9692
# Only run if phpunit config file exists
9793
if: steps.check_composer.outputs.files_exists == 'true'
9894
working-directory: apps/${{ env.APP_NAME }}
@@ -106,34 +102,43 @@ jobs:
106102
./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
107103
./occ app:enable --force ${{ env.APP_NAME }}
108104
109-
- name: Check PHPUnit config file existence
105+
- name: Check PHPUnit script is defined
110106
id: check_phpunit
111-
uses: andstor/file-existence-action@v1
112-
with:
113-
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }}
107+
continue-on-error: true
108+
working-directory: apps/${{ env.APP_NAME }}
109+
run: |
110+
composer run --list | grep "^ test:unit " | wc -l | grep 1
114111
115112
- name: PHPUnit
116113
# Only run if phpunit config file exists
117-
if: steps.check_phpunit.outputs.files_exists == 'true'
114+
if: steps.check_phpunit.outcome == 'success'
118115
working-directory: apps/${{ env.APP_NAME }}
119-
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }}
116+
run: composer run test:unit
120117

121-
- name: Check PHPUnit integration config file existence
118+
- name: Check PHPUnit integration script is defined
122119
id: check_integration
123-
uses: andstor/file-existence-action@v1
124-
with:
125-
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }}
120+
continue-on-error: true
121+
working-directory: apps/${{ env.APP_NAME }}
122+
run: |
123+
composer run --list | grep "^ test:integration " | wc -l | grep 1
126124
127125
- name: Run Nextcloud
128126
# Only run if phpunit integration config file exists
129-
if: steps.check_integration.outputs.files_exists == 'true'
127+
if: steps.check_integration.outcome == 'success'
130128
run: php -S localhost:8080 &
131129

132130
- name: PHPUnit integration
133131
# Only run if phpunit integration config file exists
134-
if: steps.check_integration.outputs.files_exists == 'true'
132+
if: steps.check_integration.outcome == 'success'
135133
working-directory: apps/${{ env.APP_NAME }}
136-
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }}
134+
run: composer run test:integration
135+
136+
- name: Skipped
137+
# Fail the action when neither unit nor integration tests ran
138+
if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure'
139+
run: |
140+
echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts'
141+
exit 1
137142
138143
summary:
139144
permissions:

0 commit comments

Comments
 (0)