Skip to content

Commit

Permalink
ZO-4513: Run tests (with batou) via GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
wosc committed Feb 5, 2024
1 parent 5a69789 commit 3225e3e
Showing 1 changed file with 117 additions and 0 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/testrunner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Testrunner

on:
push:
branches:
- main
pull_request:

env:
PROJECT: vivi
BUILD_URL: "${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}"

concurrency: test_branch_${{github.ref_name}}

jobs:
test:
runs-on: zon-ubuntu-general-dind
permissions:
contents: read
checks: write

steps:
- uses: actions/[email protected]
- name: determine deployment branch
run: |
if [[ "${{github.ref_name}}" = "main" ]]; then
branch="main"
else
branch=$(echo -e "${{github.event.pull_request.body}}" | \
sed -ne '/JENKINS_BATOU_BRANCH=/s/JENKINS_BATOU_BRANCH=//p' | \
tr --delete ' \r\n')
if [[ -z "$branch" ]]; then
branch=main
fi
fi
echo "DEPLOYMENT_BRANCH=$branch" >> $GITHUB_ENV
- name: checkout deployment
uses: actions/[email protected]
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: actions/[email protected]
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: |
deployment/components/source/*.txt
- name: setup firefox
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get -y install --no-install-recommends \
firefox \
build-essential graphviz-dev
- name: ./batou deploy local
run: |
mkdir -p deployment/work/source
ln -s $PWD deployment/work/source/vivi
cd deployment
./batou deploy gha
- name: bin/test
run: |
# `pendulum` requires local timezone configuration
export TZ="Europe/Berlin"
set +e
deployment/bin/test -n 6 -m 'not selenium' -r a \
--junitxml=report.xml --cov=.
result=$?
deployment/bin/test -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/[email protected]
if: always()
with:
comment_mode: "off"
files: "deployment/work/source/report*.xml"

- name: Publish coverage
uses: actions/[email protected]
id: coverage
with:
name: coverage-${{env.PROJECT}}
path: deployment/work/source/coverage-report
if-no-files-found: ignore
- name: Annotate coverage
uses: louisbrunner/[email protected]
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/[email protected]
if: failure() && github.ref_name == 'main'
with:
channel-id: "${{secrets.SLACK_TEAM_CONTENT_CHANNEL_ID}}"
slack-message: ":small_red_triangle_down: <${{env.BUILD_URL}}|${{env.PROJECT}}> tests failed"
env:
SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}}

0 comments on commit 3225e3e

Please sign in to comment.