ZO-4513: Run tests (with batou) via GHA #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
id-token: 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: ZeitOnline/[email protected] | |
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.jabber | |
uses: actions/[email protected] | |
with: | |
repository: ZeitOnline/zeit.jabber | |
path: deployment/work/source/zeit.jabber | |
ssh-key: ${{secrets.DEPLOY_KEY_JABBER}} | |
- name: checkout zeit.ldap | |
uses: actions/[email protected] | |
with: | |
repository: ZeitOnline/zeit.ldap | |
path: deployment/work/source/zeit.ldap | |
ssh-key: ${{secrets.DEPLOY_KEY_LDAP}} | |
- name: checkout zeit.newsimport | |
uses: actions/[email protected] | |
with: | |
repository: ZeitOnline/zeit.newsimport | |
path: deployment/work/source/zeit.newsimport | |
ssh-key: ${{secrets.DEPLOY_KEY_NEWSIMPORT}} | |
- 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: | | |
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}} |