Skip to content

Commit 0703344

Browse files
committed
Expose GLPI over HTTP during PHPUnit step
1 parent 52b5924 commit 0703344

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

.github/workflows/continuous-integration.yml

+31-12
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ jobs:
2121
name: "Continuous integration"
2222
runs-on: "ubuntu-latest"
2323
container:
24-
image: "ghcr.io/glpi-project/githubactions-glpi:php-${{ inputs.php-version }}-glpi-${{ inputs.glpi-version }}"
24+
image: "ghcr.io/glpi-project/githubactions-glpi-apache:php-${{ inputs.php-version }}-glpi-${{ inputs.glpi-version }}"
25+
# `--user github-actions-runner` is mandatory to prevent rights issues on mounted volume during checkout operation
2526
options: >-
26-
--volume ${{ github.workspace }}:/var/glpi/plugins:rw
27+
--volume ${{ github.workspace }}:/var/www/glpi/plugins:rw
28+
--user github-actions-runner
2729
services:
2830
db:
2931
image: "ghcr.io/glpi-project/githubactions-${{ inputs.db-image }}"
@@ -34,29 +36,41 @@ jobs:
3436
--shm-size=1g
3537
defaults:
3638
run:
37-
shell: "bash"
38-
working-directory: "/var/glpi/plugins/${{ inputs.plugin-key }}"
39+
# By default, execute commands using the `www-data` user to prevent rights issues on GLPI generated files.
40+
shell: "sudo --set-home --user=www-data bash --noprofile --norc -eo pipefail {0}"
41+
working-directory: "/var/www/glpi/plugins/${{ inputs.plugin-key }}"
42+
env:
43+
CACHE_DIR: "/home/www-data/.cache/continuous-integration-workflow"
3944
steps:
4045
- name: "Checkout"
4146
uses: "actions/checkout@v4"
4247
with:
4348
path: "${{ inputs.plugin-key }}"
44-
- name: "Get dependencies cache directories"
45-
id: "composer-cache"
49+
- name: "Configure cache directories"
50+
# Use default `bash` shell with `github-actions-runner` user
51+
shell: "bash"
4652
run: |
47-
echo "composer_cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
48-
echo "npm_cache_dir=$(npm config get cache)" >> $GITHUB_OUTPUT
49-
- name: "Restore dependencies cache"
53+
sudo mkdir --parents "${{ env.CACHE_DIR }}/npm"
54+
sudo mkdir --parents "${{ env.CACHE_DIR }}/composer"
55+
sudo chown --recursive github-actions-runner "${{ env.CACHE_DIR }}"
56+
npm config set cache "${{ env.CACHE_DIR }}/npm"
57+
composer config cache-dir "${{ env.CACHE_DIR }}/composer"
58+
- name: "Restore cache"
5059
uses: "actions/cache@v4"
5160
with:
5261
path: |
53-
${{ steps.composer-cache.outputs.composer_cache_dir }}
54-
${{ steps.composer-cache.outputs.npm_cache_dir }}
62+
${{ env.CACHE_DIR }}
5563
key: "${{ inputs.plugin-key }}-dependencies-${{ inputs.php-version }}-${{ github.job }}-${{ hashFiles('**/composer.lock', '**/package-lock.json') }}"
5664
restore-keys: |
5765
${{ inputs.plugin-key }}-dependencies-${{ inputs.php-version }}-${{ github.job }}-
5866
${{ inputs.plugin-key }}-dependencies-${{ inputs.php-version }}-
5967
${{ inputs.plugin-key }}-dependencies-
68+
- name: "Fix directories ACL"
69+
# Use default `bash` shell with `github-actions-runner` user
70+
shell: "bash"
71+
run: |
72+
sudo setfacl --recursive --modify u:www-data:rwx "${{ env.CACHE_DIR }}"
73+
sudo setfacl --recursive --modify u:www-data:rwx /var/www/glpi/plugins
6074
- name: "Install dependencies"
6175
run: |
6276
if [[ -f "composer.json" ]]; then
@@ -114,11 +128,16 @@ jobs:
114128
echo -e "\033[0;33mLicence headers checks skipped.\033[0m"
115129
fi
116130
- name: "Install plugin"
117-
working-directory: "/var/glpi"
131+
working-directory: "/var/www/glpi"
118132
run: |
119133
bin/console database:install --ansi --no-interaction --db-name=glpi --db-host=db --db-user=root --strict-configuration
120134
bin/console plugin:install --ansi --no-interaction --username=glpi ${{ inputs.plugin-key }}
121135
bin/console plugin:activate --ansi --no-interaction ${{ inputs.plugin-key }}
136+
- name: "Run apache"
137+
# Use default `bash` shell with `github-actions-runner` user
138+
shell: "bash"
139+
run: |
140+
sudo service apache2 start
122141
- name: "PHPUnit"
123142
run: |
124143
if [[ -f "vendor/bin/phpunit" && -f "phpunit.xml" ]]; then

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ This workflow will execute the following actions as long as they are available o
1515
| PHPUnit | [phpunit/phpunit](https://packagist.org/packages/phpunit/phpunit) | `phpunit.xml` |
1616
| Jest | [jest](https://www.npmjs.com/package/jest) | `jest.config.js` |
1717

18+
During the `PHPUnit` tests execution, GLPI will be accessible over HTTP (`http://localhost/`).
19+
1820
```yaml
1921
name: "Continuous integration"
2022

0 commit comments

Comments
 (0)