Skip to content

Commit

Permalink
Decrease running time of phpstan job
Browse files Browse the repository at this point in the history
The job used the baseline which does the setup of a whole installation
but we only need composer for phpstan. Currently no other job used the
baseline.sh so we can decrease this and re-add the parts when needed for
future jobs which do use the full installation (unit tests, integration
& webstandard for example).

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.
  • Loading branch information
vmcj committed Jun 16, 2024
1 parent 3002fb3 commit b192973
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 111 deletions.
109 changes: 0 additions & 109 deletions .github/jobs/baseinstall.sh

This file was deleted.

52 changes: 52 additions & 0 deletions .github/jobs/composer_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh

set -eux

# Store artifacts/logs
export ARTIFACTS="/tmp/artifacts"
mkdir -p "$ARTIFACTS"

# Functions to annotate the Github actions logs
trace_on () {
set -x
}

trace_off () {
{
set +x
} 2>/dev/null
}

section_start_internal () {
echo "::group::$1"
trace_on
}

section_end_internal () {
echo "::endgroup::"
trace_on
}

section_start () {
if [ "$#" -ne 1 ]; then
echo "Only 1 argument is needed for GHA, 2 was needed for GitLab."
exit 1
fi
trace_off
section_start_internal "$1"
}

section_end () {
trace_off
section_end_internal
}

section_start "Configure PHP"
PHPVERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')
export PHPVERSION
echo "$PHPVERSION" | tee -a "$ARTIFACTS"/phpversion.txt
section_end

section_start "Run composer"
composer install --no-scripts 2>&1 | tee -a "$ARTIFACTS/composer_log.txt"
section_end
8 changes: 6 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install DOMjudge
run: .github/jobs/baseinstall.sh admin
- name: Setup composer dependencies
run: .github/jobs/composer_setup.sh
- uses: php-actions/phpstan@v3
with:
configuration: phpstan.dist.neon
path: webapp/src webapp/tests
php_extensions: gd intl mysqli pcntl zip
- uses: actions/upload-artifact@v4
if: always()
with:
path: /tmp/artifacts

0 comments on commit b192973

Please sign in to comment.