Skip to content

Commit aebf829

Browse files
committed
Change PHP GitHub Action to use docker container for entire PHPUnit job
1 parent 4fc7618 commit aebf829

File tree

1 file changed

+41
-32
lines changed

1 file changed

+41
-32
lines changed

.github/workflows/php.yml

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ on:
1010
- '.config/phpcs.xml.dist'
1111
- '.config/phpunit.xml.dist'
1212
- '.github/workflows/php.yml'
13-
- 'composer.json'
14-
- 'composer.lock'
13+
- 'solid/composer.json'
14+
- 'solid/composer.lock'
1515
branches: [ main ]
1616
types: [ opened, reopened, synchronize ]
1717
# This event occurs when there is a push to the repository.
@@ -21,8 +21,8 @@ on:
2121
- '.config/phpcs.xml.dist'
2222
- '.config/phpunit.xml.dist'
2323
- '.github/workflows/php.yml'
24-
- 'composer.json'
25-
- 'composer.lock'
24+
- 'solid/composer.json'
25+
- 'solid/composer.lock'
2626
# Allow manually triggering the workflow.
2727
workflow_dispatch:
2828

@@ -57,14 +57,27 @@ jobs:
5757
steps:
5858
- uses: actions/checkout@v4
5959
- run: >-
60-
composer validate
61-
--check-lock
62-
--no-plugins
63-
--no-scripts
64-
--strict
60+
composer validate
61+
--check-lock
62+
--no-plugins
63+
--no-scripts
64+
--strict
6565
working-directory: "solid"
6666
# 02.test.php.test-unit.yml
6767
php-unittest:
68+
container:
69+
image: ghcr.io/${{ github.repository }}:main-${{ matrix.nextcloud_version }}
70+
env:
71+
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
72+
NEXTCLOUD_PATH: /usr/src/nextcloud/
73+
NEXTCLOUD_UPDATE: 1
74+
XDEBUG_MODE: coverage
75+
volumes:
76+
- /usr/bin/composer:/usr/bin/composer
77+
defaults:
78+
run:
79+
shell: bash
80+
working-directory: /usr/src/nextcloud/apps/solid
6881
name: PHP Unit Tests
6982
needs:
7083
- lint-php-syntax
@@ -78,27 +91,23 @@ jobs:
7891
- 29
7992
- 30
8093
steps:
81-
- uses: actions/checkout@v4
82-
- uses: shivammathur/setup-php@v2
83-
with:
84-
ini-values: error_reporting=E_ALL, display_errors=On
85-
php-version: 8.3
94+
- uses: actions/checkout@v5
95+
# @CHECKME: cp site.conf /etc/apache2/sites-enabled/000-default.conf (?)
96+
- name: Setup Test Environment
97+
run: |
98+
git config --global --add safe.directory "${NEXTCLOUD_PATH}/apps"
99+
/entrypoint.sh "echo"
100+
bash "${GITHUB_WORKSPACE}/init.sh"
101+
rm -r "${NEXTCLOUD_PATH}/apps/solid/"
102+
cp --archive --verbose "${GITHUB_WORKSPACE}/." "${NEXTCLOUD_PATH}/apps/"
86103
- name: Install and Cache Composer dependencies
87-
uses: "ramsey/composer-install@v2"
104+
uses: ramsey/composer-install@v3
88105
with:
89-
working-directory: "solid"
106+
working-directory: /usr/src/nextcloud/apps/solid
90107
env:
91108
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
92-
- run: |
93-
docker run \
94-
--env 'XDEBUG_MODE=coverage' \
95-
--rm \
96-
--volume="./solid:/var/www/html/apps/solid" \
97-
ghcr.io/${{ github.repository }}:main-${{ matrix.nextcloud_version }} \
98-
bash -c 'NEXTCLOUD_UPDATE=1 /entrypoint.sh "echo" \
99-
&& sudo -u www-data bash /init.sh \
100-
&& cd /var/www/html/apps/solid \
101-
&& bin/phpunit --configuration phpunit.xml'
109+
- name: Run PHPUnit
110+
run: bin/phpunit --configuration phpunit.xml
102111

103112
# 03.quality.php.scan.dependencies-vulnerabilities.yml
104113
scan-dependencies-vulnerabilities:
@@ -109,12 +118,12 @@ jobs:
109118
steps:
110119
- uses: actions/checkout@v4
111120
- run: >-
112-
composer audit
113-
--abandoned=report
114-
--locked
115-
--no-dev
116-
--no-plugins
117-
--no-scripts
121+
composer audit
122+
--abandoned=report
123+
--locked
124+
--no-dev
125+
--no-plugins
126+
--no-scripts
118127
working-directory: "solid"
119128
# 03.quality.php.lint-quality.yml
120129
php-lint-quality:

0 commit comments

Comments
 (0)