Skip to content

Testrunner

Testrunner #1267

Workflow file for this run

name: Testrunner
on:
push:
branches:
- main
pull_request:
schedule:
# XXX GHA unfortunately does not support randomize, so https://xkcd.com/221/
- cron: "22 4 * * *"
env:
project: vivi
build_url: "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}"
team_content_alerts: C06JB4PMALW
concurrency: test_branch_${{github.ref_name}}
jobs:
test:
runs-on: zon-ubuntu-general-dind
permissions:
contents: read
checks: write
id-token: write
steps:
- uses: actions/checkout@v4.1.7
- name: determine deployment branch
run: |
if [[ "${{github.ref_name}}" = "main" ]]; then
branch="main"
else
branch=$(awk -F= '/DEPLOYMENT_BRANCH *=/ { gsub(/ /, "", $2); printf $2 }' <<'EOF'
${{github.event.pull_request.body}}
EOF
)
if [[ -z "$branch" ]]; then
branch=main
fi
fi
echo "DEPLOYMENT_BRANCH=$branch" >> $GITHUB_ENV
- name: checkout deployment
uses: actions/checkout@v4.1.7
with:
repository: ZeitOnline/vivi-deployment
ref: ${{env.DEPLOYMENT_BRANCH}}
path: deployment
# Has been added manually (both the key in vivi-deployment and
# the GHA secret in vivi)
ssh-key: ${{secrets.DEPLOY_KEY_DEPLOYMENT}}
- uses: ZeitOnline/gh-action-baseproject@v0.10.3
with:
project_name: ${{env.project}}
environment: staging
gar_docker_auth: true # for docker pull dav-server
vault_export_token: true
- name: checkout vivi
run: |
mkdir -p deployment/work/source
ln -s $PWD deployment/work/source/vivi
# Keys have been added manually (both the key in the target repo and
# the GHA+Dependabot secret in vivi and vivi-deployment)
- name: checkout zeit.ldap
uses: actions/checkout@v4.1.7
with:
repository: ZeitOnline/zeit.ldap
path: deployment/work/source/zeit.ldap
ssh-key: ${{secrets.DEPLOY_KEY_LDAP}}
- uses: actions/setup-python@v5.1.0
with:
python-version: "3.12.3"
cache: "pip"
cache-dependency-path: |
deployment/components/source/*.txt
- uses: actions/setup-node@v4.0.2 # for jshint
with:
node-version: "20"
- name: setup apt
# firefox dependencies see https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/registry/nativeDeps.ts
# gcc for e.g. `pygraphviz`
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get -y install --no-install-recommends \
libasound2 libatk1.0-0 libcairo-gobject2 libcairo2 libdbus-1-3 libdbus-glib-1-2 libfontconfig1 libfreetype6 libgdk-pixbuf-2.0-0 libglib2.0-0 libgtk-3-0 libpango-1.0-0 libpangocairo-1.0-0 libx11-6 libx11-xcb1 libxcb-shm0 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxtst6 \
build-essential graphviz-dev \
pandoc
- uses: browser-actions/setup-firefox@v1.5.1
- name: setup geckodriver
run: |
curl -fsSL https://github.com/mozilla/geckodriver/releases/download/v0.34.0/geckodriver-v0.34.0-linux64.tar.gz \
| tar -xzv geckodriver && sudo mv geckodriver /usr/local/bin/geckodriver
- name: ./batou deploy gha
run: |
cd deployment
./batou deploy gha
- name: test local server process
run: |
health=$(curl -w "%{http_code}" --unix-socket deployment/work/zope/zope.sock http://localhost/@@health-check)
if [[ "$health" != "OK200" ]]; then
exit 1
fi
- name: display log output
if: failure()
run: |
for i in deployment/work/supervisor/var/log/*.log; do
echo $i
cat $i
done
- name: bin/test
run: |
# `pendulum` requires local timezone configuration
export TZ="Europe/Berlin"
if [[ "${{github.event_name}}" = "schedule" ]]; then
not_selenium='not selenium'
else
not_selenium='not selenium and not integration'
fi
set +e
deployment/bin/test -v -n 6 -m "$not_selenium" -r a \
--junitxml=report.xml --cov=. --cov-report=
result=$?
deployment/bin/test -v -n 4 -m 'selenium' --reruns=3 -r aR \
--junitxml=report_selenium.xml --cov=. \
--cov-append --cov-report=html
selenium=$?
if [[ "$result" = "0" ]]; then
result=$selenium
fi
exit $result
- name: Publish test result
uses: enricomi/publish-unit-test-result-action@v2.16.1
if: always()
with:
comment_mode: "off"
files: "deployment/work/source/report*.xml"
- name: Publish coverage
uses: actions/upload-artifact@v4.3.3
id: coverage
with:
name: coverage-${{env.project}}
path: deployment/work/source/coverage-report
if-no-files-found: ignore
- name: Annotate coverage
uses: louisbrunner/checks-action@v2.0.0
with:
token: ${{secrets.GITHUB_TOKEN}} # unfortunately required
name: Coverage Report
conclusion: success
output: |
{"summary": "[Download](${{env.build_url}}/artifacts/${{steps.coverage.outputs.artifact-id}})"}
- uses: slackapi/slack-github-action@v1.26.0
if: failure() && github.ref_name == 'main' && github.event_name != 'schedule'
with:
channel-id: "${{env.team_content_alerts}}"
slack-message: ":small_red_triangle_down: <${{env.build_url}}|${{env.project}}> tests failed"
env:
SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}}