21
21
name : " Continuous integration"
22
22
runs-on : " ubuntu-latest"
23
23
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
25
26
options : >-
26
- --volume ${{ github.workspace }}:/var/glpi/plugins:rw
27
+ --volume ${{ github.workspace }}:/var/www/glpi/plugins:rw
28
+ --user github-actions-runner
27
29
services :
28
30
db :
29
31
image : " ghcr.io/glpi-project/githubactions-${{ inputs.db-image }}"
@@ -34,29 +36,41 @@ jobs:
34
36
--shm-size=1g
35
37
defaults :
36
38
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"
39
44
steps :
40
45
- name : " Checkout"
41
46
uses : " actions/checkout@v4"
42
47
with :
43
48
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"
46
52
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"
50
59
uses : " actions/cache@v4"
51
60
with :
52
61
path : |
53
- ${{ steps.composer-cache.outputs.composer_cache_dir }}
54
- ${{ steps.composer-cache.outputs.npm_cache_dir }}
62
+ ${{ env.CACHE_DIR }}
55
63
key : " ${{ inputs.plugin-key }}-dependencies-${{ inputs.php-version }}-${{ github.job }}-${{ hashFiles('**/composer.lock', '**/package-lock.json') }}"
56
64
restore-keys : |
57
65
${{ inputs.plugin-key }}-dependencies-${{ inputs.php-version }}-${{ github.job }}-
58
66
${{ inputs.plugin-key }}-dependencies-${{ inputs.php-version }}-
59
67
${{ 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
60
74
- name : " Install dependencies"
61
75
run : |
62
76
if [[ -f "composer.json" ]]; then
@@ -114,11 +128,16 @@ jobs:
114
128
echo -e "\033[0;33mLicence headers checks skipped.\033[0m"
115
129
fi
116
130
- name : " Install plugin"
117
- working-directory : " /var/glpi"
131
+ working-directory : " /var/www/ glpi"
118
132
run : |
119
133
bin/console database:install --ansi --no-interaction --db-name=glpi --db-host=db --db-user=root --strict-configuration
120
134
bin/console plugin:install --ansi --no-interaction --username=glpi ${{ inputs.plugin-key }}
121
135
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
122
141
- name : " PHPUnit"
123
142
run : |
124
143
if [[ -f "vendor/bin/phpunit" && -f "phpunit.xml" ]]; then
0 commit comments