Skip to content

Commit 6b28c39

Browse files
committed
Decrease running time of phpstan job
The job used the baseinstall script which does the setup of a whole installation but we only need composer for phpstan. I've removed & renamed that script as it wasn't used anywhere else. In the future we can add the relevant sections again and toggle the needed steps to make sure we don't replicate the needed steps. For example the unit tests don't need a judgehost installed, neither do the webstandard jobs. Another solution would have been to use our container but as we need docker there and some other parts (phpstan action builds it own container inside ours in that case) this was the easier solution. The different shell functions are now fully POSIX complaint as we ran with bash first together with some aliases which we can't easily expand.
1 parent a585991 commit 6b28c39

File tree

3 files changed

+58
-111
lines changed

3 files changed

+58
-111
lines changed

.github/jobs/baseinstall.sh

Lines changed: 0 additions & 109 deletions
This file was deleted.

.github/jobs/composer_setup.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh
2+
3+
set -eux
4+
5+
# Store artifacts/logs
6+
export ARTIFACTS="/tmp/artifacts"
7+
mkdir -p "$ARTIFACTS"
8+
9+
# Functions to annotate the Github actions logs
10+
trace_on () {
11+
set -x
12+
}
13+
14+
trace_off () {
15+
{
16+
set +x
17+
} 2>/dev/null
18+
}
19+
20+
section_start_internal () {
21+
echo "::group::$1"
22+
trace_on
23+
}
24+
25+
section_end_internal () {
26+
echo "::endgroup::"
27+
trace_on
28+
}
29+
30+
section_start () {
31+
if [ "$#" -ne 1 ]; then
32+
echo "Only 1 argument is needed for GHA, 2 was needed for GitLab."
33+
exit 1
34+
fi
35+
trace_off
36+
section_start_internal "$1"
37+
}
38+
39+
section_end () {
40+
trace_off
41+
section_end_internal
42+
}
43+
44+
section_start "Configure PHP"
45+
PHPVERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')
46+
export PHPVERSION
47+
echo "$PHPVERSION" | tee -a "$ARTIFACTS"/phpversion.txt
48+
section_end
49+
50+
section_start "Run composer"
51+
composer install --no-scripts 2>&1 | tee -a "$ARTIFACTS/composer_log.txt"
52+
section_end

.github/workflows/phpstan.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17-
- name: Install DOMjudge
18-
run: .github/jobs/baseinstall.sh admin
17+
- name: Setup composer dependencies
18+
run: .github/jobs/composer_setup.sh
1919
- uses: php-actions/phpstan@v3
2020
with:
2121
configuration: phpstan.dist.neon
2222
path: webapp/src webapp/tests
2323
php_extensions: gd intl mysqli pcntl zip
24+
- uses: actions/upload-artifact@v4
25+
if: always()
26+
with:
27+
path: /tmp/artifacts

0 commit comments

Comments
 (0)