-
Notifications
You must be signed in to change notification settings - Fork 61
135 lines (116 loc) · 4.97 KB
/
integration-test-nightly.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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: [goth, ubuntu-18.04]
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
uses: actions/setup-python@v2
with:
python-version: '3.8.0'
- name: Configure Poetry
uses: Gr1N/setup-poetry@v8
with:
poetry-version: 1.2.2
- name: Install dependencies
run: |
poetry config experimental.new-installer false
poetry install --no-root
- 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: Run test suite
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry run poe goth-assets
# 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@v2
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 python3.8
- 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.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 }}>'