Goth integration tests (nightly) #1158
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: Goth integration tests (nightly) | |
on: | |
workflow_dispatch: | |
inputs: | |
warning: | |
description: 'Choosing the branch is not supported yet.' | |
required: true | |
default: 'Predefined branches will be used' | |
schedule: | |
# run this workflow every day at 3:00 AM UTC | |
- cron: '0 3 * * *' | |
jobs: | |
prepare-matrix: | |
name: Prepare matrix JSON | |
runs-on: ubuntu-latest | |
outputs: | |
matrix-json: ${{ steps.get-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
# finds branches with names matching the release branch convention (e.g. release/v0.7) and returns one with highest version | |
- name: Get latest stable branch | |
id: latest-stable | |
# second sed expression removes leading whitespaces and '*' characters (git uses it to indicate the current branch) | |
run: | | |
branch=$(git branch -a | sed -e 's:remotes/origin/::' -e 's:^[ \t*]*::' | grep -E '^release\/v[0-9]+(\.[0-9]+)+$' | sort -Vr | head -1) | |
echo "::set-output name=branch::$branch" | |
# prepares JSON object representing strategy matrix which contains two 'branch' variants: master and latest stable | |
- name: Get matrix JSON | |
id: get-matrix | |
run: echo "::set-output name=matrix::{\"include\":[{\"branch\":\"master\"},{\"branch\":\"${{ steps.latest-stable.outputs.branch }}\"}]}" | |
integration-test: | |
needs: prepare-matrix | |
strategy: | |
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix-json) }} | |
fail-fast: false | |
runs-on: [ goth2 ] | |
name: Integration Tests (nightly) @ ${{ matrix.branch }} | |
defaults: | |
run: | |
working-directory: './goth_tests' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ matrix.branch }} | |
- name: Configure Python | |
continue-on-error: true | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
ln -sf $HOME/.local/bin/poetry /usr/bin/poetry | |
- name: Install dependencies | |
run: | | |
poetry install --no-root | |
- name: Cleanup Docker | |
if: always() | |
run: | | |
c=$(docker ps -q) && [[ $c ]] && docker kill $c | |
docker system prune -af | |
- name: Log in to GitHub Docker repository | |
run: | | |
rm -rf ~/.docker/config.json | |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{github.actor}} --password-stdin | |
- name: Run test suite | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Runs on branches defined within matrix | |
poetry run poe goth-tests --config-override docker-compose.build-environment.branch=${{ matrix.branch }} | |
- name: Convert branch name to valid file name ( replace / with - ) | |
id: branch_as | |
if: always() | |
run: echo "::set-output name=file_name::$(echo '${{ matrix.branch }}' | sed 's/\//-/g')" | |
- name: Upload test logs | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: goth-logs_${{ steps.branch_as.outputs.file_name }} | |
path: /tmp/goth-tests | |
# Only relevant for self-hosted runners | |
- name: Remove test logs | |
if: always() | |
run: rm -rf /tmp/goth-tests | |
# Only relevant for self-hosted runners | |
- name: Remove Poetry virtual env | |
if: always() | |
# Python version below should agree with the version set up by this job. | |
# In the future we'll be able to use the `--all` flag here to remove envs for | |
# all Python versions (https://github.com/python-poetry/poetry/issues/3208). | |
run: poetry env remove --all | |
- name: Send Discord notification on failure | |
uses: Ilshidur/[email protected] | |
if: failure() | |
env: | |
BRANCH_NAME: ${{ matrix.branch }} | |
DISCORD_AVATAR: https://i.imgur.com/EOX16Mx.jpg | |
DISCORD_USERNAME: 'Goth night watch' | |
DISCORD_WEBHOOK: ${{ secrets.GOTH_DISCORD_WEBHOOK }} | |
REPO_NAME: ${{ github.repository }} | |
WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
with: | |
# <@&717621825957396540> = @core | |
args: '<@&717621825957396540> Goth nightly run failed for `{{ REPO_NAME }}` on branch `{{ BRANCH_NAME }}`! <{{ WORKFLOW_URL }}>' |