Skip to content

Commit 04e44b1

Browse files
committed
chore(ci): add s3 phpunit
Signed-off-by: Robin Appelman <[email protected]>
1 parent 9dafb41 commit 04e44b1

File tree

1 file changed

+210
-0
lines changed

1 file changed

+210
-0
lines changed
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
name: PHPUnit SQLite - S3
10+
11+
on: pull_request
12+
13+
permissions:
14+
contents: read
15+
16+
concurrency:
17+
group: phpunit-sqlite-s3-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
matrix:
22+
runs-on: ubuntu-latest-low
23+
outputs:
24+
php-version: ${{ steps.versions.outputs.php-available-list }}
25+
server-max: ${{ steps.versions.outputs.branches-max-list }}
26+
steps:
27+
- name: Checkout app
28+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29+
with:
30+
persist-credentials: false
31+
32+
- name: Get version matrix
33+
id: versions
34+
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
35+
36+
changes:
37+
runs-on: ubuntu-latest-low
38+
permissions:
39+
contents: read
40+
pull-requests: read
41+
42+
outputs:
43+
src: ${{ steps.changes.outputs.src}}
44+
45+
steps:
46+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
47+
id: changes
48+
continue-on-error: true
49+
with:
50+
filters: |
51+
src:
52+
- '.github/workflows/**'
53+
- 'appinfo/**'
54+
- 'lib/**'
55+
- 'templates/**'
56+
- 'tests/**'
57+
- 'vendor/**'
58+
- 'vendor-bin/**'
59+
- '.php-cs-fixer.dist.php'
60+
- 'composer.json'
61+
- 'composer.lock'
62+
63+
phpunit-sqlite:
64+
runs-on: ubuntu-latest
65+
66+
needs: [changes, matrix]
67+
if: needs.changes.outputs.src != 'false'
68+
69+
strategy:
70+
matrix:
71+
php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
72+
server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
73+
74+
name: SQLite PHP S3 ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}
75+
76+
services:
77+
minio:
78+
image: bitnami/minio@sha256:50cec18ac4184af4671a78aedd5554942c8ae105d51a465fa82037949046da01 # v2025.4.22
79+
env:
80+
MINIO_ROOT_USER: nextcloud
81+
MINIO_ROOT_PASSWORD: bWluaW8tc2VjcmV0LWtleS1uZXh0Y2xvdWQ=
82+
MINIO_DEFAULT_BUCKETS: nextcloud
83+
ports:
84+
- "9000:9000"
85+
86+
steps:
87+
- name: Set app env
88+
if: ${{ env.APP_NAME == '' }}
89+
run: |
90+
# Split and keep last
91+
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
92+
93+
- name: Checkout server
94+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
95+
with:
96+
persist-credentials: false
97+
submodules: true
98+
repository: nextcloud/server
99+
ref: ${{ matrix.server-versions }}
100+
101+
- name: Checkout Circles
102+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
103+
with:
104+
repository: nextcloud/circles
105+
ref: master
106+
path: apps/circles
107+
108+
- name: Checkout app
109+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
110+
with:
111+
persist-credentials: false
112+
path: apps/${{ env.APP_NAME }}
113+
114+
- name: Set up php ${{ matrix.php-versions }}
115+
uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # v2.34.1
116+
with:
117+
php-version: ${{ matrix.php-versions }}
118+
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
119+
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
120+
coverage: none
121+
ini-file: development
122+
# Temporary workaround for missing pcntl_* in PHP 8.3
123+
ini-values: disable_functions=
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126+
127+
- name: Check composer file existence
128+
id: check_composer
129+
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
130+
with:
131+
files: apps/${{ env.APP_NAME }}/composer.json
132+
133+
- name: Set up Circles dependencies
134+
working-directory: apps/circles
135+
run: composer i
136+
137+
- name: Set up dependencies
138+
# Only run if phpunit config file exists
139+
if: steps.check_composer.outputs.files_exists == 'true'
140+
working-directory: apps/${{ env.APP_NAME }}
141+
run: |
142+
composer remove nextcloud/ocp --dev --no-scripts
143+
composer i
144+
145+
- name: Set up Nextcloud
146+
env:
147+
DB_PORT: 4444
148+
run: |
149+
mkdir data
150+
echo '<?php $CONFIG=["objectstore" => ["class" => "OC\Files\ObjectStore\S3", "arguments" => ["bucket" => "nextcloud", "autocreate" => true, "key" => "nextcloud", "secret" => "bWluaW8tc2VjcmV0LWtleS1uZXh0Y2xvdWQ=", "hostname" => "localhost", "port" => 9000, "use_ssl" => false, "use_path_style" => true, "uploadPartSize" => 52428800]]];' > config/config.php
151+
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
152+
./occ app:enable --force circles
153+
./occ app:enable --force ${{ env.APP_NAME }}
154+
155+
- name: Check PHPUnit script is defined
156+
id: check_phpunit
157+
continue-on-error: true
158+
working-directory: apps/${{ env.APP_NAME }}
159+
run: |
160+
composer run --list | grep '^ test:unit ' | wc -l | grep 1
161+
162+
- name: PHPUnit
163+
# Only run if phpunit config file exists
164+
if: steps.check_phpunit.outcome == 'success'
165+
working-directory: apps/${{ env.APP_NAME }}
166+
run: composer run test:unit
167+
168+
- name: Check PHPUnit integration script is defined
169+
id: check_integration
170+
continue-on-error: true
171+
working-directory: apps/${{ env.APP_NAME }}
172+
run: |
173+
composer run --list | grep '^ test:integration ' | wc -l | grep 1
174+
175+
- name: Run Nextcloud
176+
# Only run if phpunit integration config file exists
177+
if: steps.check_integration.outcome == 'success'
178+
run: php -S localhost:8080 &
179+
180+
- name: PHPUnit integration
181+
# Only run if phpunit integration config file exists
182+
if: steps.check_integration.outcome == 'success'
183+
working-directory: apps/${{ env.APP_NAME }}
184+
run: composer run test:integration
185+
186+
- name: Print logs
187+
if: always()
188+
run: |
189+
cat data/nextcloud.log
190+
191+
- name: Skipped
192+
# Fail the action when neither unit nor integration tests ran
193+
if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure'
194+
run: |
195+
echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts'
196+
exit 1
197+
198+
summary:
199+
permissions:
200+
contents: none
201+
runs-on: ubuntu-latest-low
202+
needs: [changes, phpunit-sqlite]
203+
204+
if: always()
205+
206+
name: phpunit-sqlite-summary
207+
208+
steps:
209+
- name: Summary status
210+
run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-sqlite.result != 'success' }}; then exit 1; fi

0 commit comments

Comments
 (0)