Skip to content

Commit ce04c76

Browse files
author
Michael Vasseur
committed
Stash the first part
1 parent fc5045a commit ce04c76

File tree

3 files changed

+44
-20
lines changed

3 files changed

+44
-20
lines changed

.github/jobs/baseinstall.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
export version="$1"
66
db=${2:-install}
77

8+
# If this script is called from unit.sh, we use the test environment
9+
export APP_ENV="${3:-prod}"
10+
11+
# In the test environment, we need to use a different database
12+
[ "$APP_ENV" = "prod" ] && DATABASE_NAME=domjudge || DATABASE_NAME=domjudge_test
13+
814
set -eux
915

1016
PHPVERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')

.github/jobs/unit-tests.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
. gitlab/ci_settings.sh
3+
. .github/jobs/ci_settings.sh
44

55
export version=$1
66
unittest=$2
@@ -10,7 +10,8 @@ show_phpinfo $version
1010

1111
# Set up
1212
export unit=1
13-
"$( dirname "${BASH_SOURCE[0]}" )"/base.sh test
13+
14+
"$( dirname "${BASH_SOURCE[0]}" )"/baseinstall.sh else_domserver_only install test
1415

1516
# Add team to admin user
1617
echo "UPDATE user SET teamid = 1 WHERE userid = 1;" | mysql domjudge_test
@@ -32,14 +33,14 @@ if [ "$CODECOVERAGE" -eq 1 ]; then
3233
pcov="--coverage-html=${CI_PROJECT_DIR}/coverage-html --coverage-clover coverage.xml"
3334
fi
3435
set +e
35-
php $phpcov webapp/bin/phpunit -c webapp/phpunit.xml.dist webapp/tests/$unittest --log-junit ${CI_PROJECT_DIR}/unit-tests.xml --colors=never $pcov > "$GITLABARTIFACTS"/phpunit.out
36+
php $phpcov webapp/bin/phpunit -c webapp/phpunit.xml.dist webapp/tests/$unittest --log-junit ${CI_PROJECT_DIR}/unit-tests.xml --colors=never $pcov > "$ARTIFACTS"/phpunit.out
3637
UNITSUCCESS=$?
3738
set -e
3839
CNT=0
3940
if [ $CODECOVERAGE -eq 1 ]; then
40-
CNT=$(sed -n '/Generating code coverage report/,$p' "$GITLABARTIFACTS"/phpunit.out | grep -v DoctrineTestBundle | grep -cv ^$)
41+
CNT=$(sed -n '/Generating code coverage report/,$p' "$ARTIFACTS"/phpunit.out | grep -v DoctrineTestBundle | grep -cv ^$)
4142
FILE=deprecation.txt
42-
sed -n '/Generating code coverage report/,$p' "$GITLABARTIFACTS"/phpunit.out > ${CI_PROJECT_DIR}/$FILE
43+
sed -n '/Generating code coverage report/,$p' "$ARTIFACTS"/phpunit.out > ${CI_PROJECT_DIR}/$FILE
4344
if [ $CNT -le 32 ]; then
4445
STATE=success
4546
else
@@ -59,7 +60,7 @@ if [ $UNITSUCCESS -eq 0 ]; then
5960
else
6061
STATE=failure
6162
fi
62-
cp webapp/var/log/test.log "$GITLABARTIFACTS"/test.log
63+
cp webapp/var/log/test.log "$ARTIFACTS"/test.log
6364

6465
curl https://api.github.com/repos/domjudge/domjudge/statuses/$CI_COMMIT_SHA \
6566
-X POST \

.github/workflows/unit-tests.yml

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Unit tests
2+
# We can speedup with: https://github.com/actions/cache
23
on:
34
merge_group:
45
pull_request:
@@ -7,25 +8,41 @@ on:
78
- '[0-9]+.[0-9]+'
89

910
jobs:
10-
check-static-codecov:
11+
unit-tests:
1112
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
PHPVERSION: 8.1
16+
TEST: UNIT
17+
services:
18+
sqlserver:
19+
image: mariadb
20+
ports:
21+
- 3306:3306
22+
env:
23+
MYSQL_ROOT_PASSWORD: password
24+
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
1225
steps:
1326
- uses: actions/checkout@v4
14-
- name: Download latest codecov upload script
15-
run: wget https://codecov.io/bash -O newcodecov
16-
- name: Detect changes to manually verify
17-
run: diff newcodecov .github/jobs/uploadcodecov.sh
27+
- name: Run the unit tests
28+
run: .github/jobs/unit-tests.sh ${{ matrix.PHPVERSION }} ${{ matrix.TEST }}
29+
#- name: Download latest codecov upload script
30+
# run: wget https://codecov.io/bash -O newcodecov
31+
#- name: Detect changes to manually verify
32+
# run: diff newcodecov .github/jobs/uploadcodecov.sh
33+
#- name: Publish Test Results
34+
# uses: EnricoMi/publish-unit-test-result-action@v2
35+
# if: always()
36+
# with:
37+
# files: |
38+
# test-results/**/*.xml
39+
- name: Upload artifact for debugging
40+
uses: actions/upload-artifact@v3
41+
with:
42+
name: unit-test-output
43+
path: /tmp/artifacts
1844

1945
#.unit_job:
20-
# extends: [.normal_job,.cached_vendor]
21-
# stage: unit
22-
# # Disabled for now as it drastically speeds up running unit tests and we don't use it yet
23-
# # before_script:
24-
# # - apt-get update -yqq
25-
# # - apt-get install php-xdebug -yqq
26-
# variables:
27-
# MYSQL_ROOT_PASSWORD: password
28-
# MARIADB_PORT_3306_TCP_ADDR: sqlserver
2946
# script:
3047
# - set -eux
3148
# - if [ -z ${PHPVERSION+x} ]; then export PHPVERSION=8.1; fi

0 commit comments

Comments
 (0)