Goth nightly #1200
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 nightly | |
on: | |
schedule: | |
# run this workflow every day at 1:00 AM UTC | |
- cron: '0 1 * * *' | |
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@v3 | |
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 '^b[0-9]+(\.[0-9]+)+$' | sort -Vr | head -1) | |
echo "branch=$branch" >> $GITHUB_OUTPUT | |
# prepares JSON object representing strategy matrix which contains two 'branch' variants: master and latest stable | |
- name: Get matrix JSON | |
id: get-matrix | |
run: echo "matrix={\"include\":[{\"branch\":\"master\"},{\"branch\":\"${{ steps.latest-stable.outputs.branch }}\"}]}" >> $GITHUB_OUTPUT | |
goth-tests: | |
runs-on: [goth, ubuntu-18.04] | |
needs: prepare-matrix | |
strategy: | |
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix-json) }} | |
fail-fast: false | |
name: Run integration tests (nightly) on ${{ matrix.branch }} | |
steps: | |
- name: install docker-compose | |
run: | | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.28.4/docker-compose-Linux-x86_64" -o /usr/local/bin/docker-compose | |
sudo chmod a+x /usr/local/bin/docker-compose | |
- name: install ffi and gcc | |
run: sudo apt-get install -y libffi-dev build-essential | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Configure python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install and configure Poetry | |
run: python -m pip install -U pip setuptools poetry==1.3.2 | |
- name: Install dependencies | |
run: | | |
poetry env use python3.9 | |
poetry install | |
- name: Disconnect Docker containers from default network | |
continue-on-error: true | |
# related to this issue: https://github.com/moby/moby/issues/23302 | |
run: | | |
docker network inspect docker_default | |
sudo apt-get install -y jq | |
docker network inspect docker_default | jq ".[0].Containers | map(.Name)[]" | tee /dev/stderr | xargs --max-args 1 -- docker network disconnect -f docker_default | |
- name: Remove Docker containers | |
continue-on-error: true | |
run: docker rm -f $(docker ps -a -q) | |
- name: Restart Docker daemon | |
# related to this issue: https://github.com/moby/moby/issues/23302 | |
run: sudo systemctl restart docker | |
- name: Log in to GitHub Docker repository | |
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{github.actor}} --password-stdin | |
- name: Initialize the test suite | |
run: poetry run poe tests_integration_init | |
- name: Run test suite | |
env: | |
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: poetry run poe tests_integration | |
- name: Upload test logs | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: goth-logs | |
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 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 python3.9 | |
- name: Send Discord notification on failure | |
uses: Ilshidur/action-discord@0.3.2 | |
if: failure() | |
env: | |
BRANCH_NAME: ${{ matrix.branch }} | |
DISCORD_AVATAR: https://i.imgur.com/EOX16Mx.jpg | |
DISCORD_USERNAME: 'Goth night watch' | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
REPO_NAME: ${{ github.repository }} | |
WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
with: | |
# <@&717623005911580713> = @sdk-integrations | |
args: '<@&717623005911580713> Goth nightly run failed for `{{ REPO_NAME }}` on branch `{{ BRANCH_NAME }}`! <{{ WORKFLOW_URL }}>' |