-
Notifications
You must be signed in to change notification settings - Fork 75
136 lines (125 loc) · 5.87 KB
/
fast_tests.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
136
name: Fast tests
on:
# Run on every PR to master that is ready to review (i.e., not draft).
pull_request:
# https://github.community/t/dont-run-actions-on-draft-pull-requests/16817/19
types: [opened, synchronize, reopened, ready_for_review]
branches:
- master
# Run for every change in master.
push:
branches:
# Comment this out to run when committing on the branch.
- master
# Run manually.
workflow_dispatch:
schedule:
# Run this once a day even if there are no commit.
- cron: '0 0 */1 * *'
jobs:
run_fast_tests:
runs-on: ubuntu-latest
steps:
# Pass AWS credentials via GH secrets. This is needed to pull the Docker image
# that will be used to run the action.
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.CK_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.CK_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.CK_AWS_DEFAULT_REGION }}
# This is needed to pull the Docker image.
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
# Make everything accessible by any user to avoid permission errors.
- name: Cleanup
run: sudo chmod 777 -R .
# Check out the code from GitHub so that we can run the action inside
# the Docker container.
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: true
token: ${{ secrets.GITHUB_TOKEN }}
# Install packages that are required to run the job via GH.
- name: Install dependencies
if: github.event.pull_request.draft == false
run: |
python -m pip install --upgrade pip
pip install -r .github/gh_requirements.txt
# Pull the latest Docker image to run the regressions on.
- name: Pull image
if: github.event.pull_request.draft == false
env:
CK_ECR_BASE_PATH: ${{ secrets.CK_ECR_BASE_PATH }}
run: invoke docker_pull
# Run the `invoke` target `run_fast_tests` to run tests that are under 5 seconds.
# See the corresponding documentation for more information.
- name: Run fast tests
# https://github.community/t/dont-run-actions-on-draft-pull-requests/16817/19
# Do not run on draft pull requests.
if: github.event.pull_request.draft == false
env:
AM_AWS_ACCESS_KEY_ID: ${{ secrets.AM_AWS_ACCESS_KEY_ID }}
AM_AWS_SECRET_ACCESS_KEY: ${{ secrets.AM_AWS_SECRET_ACCESS_KEY }}
AM_AWS_DEFAULT_REGION: ${{ secrets.AM_AWS_DEFAULT_REGION }}
AM_ECR_BASE_PATH: ${{ secrets.AM_ECR_BASE_PATH }}
AM_AWS_S3_BUCKET: ${{ secrets.AM_AWS_S3_BUCKET }}
AM_TELEGRAM_TOKEN: ${{ secrets.AM_TELEGRAM_TOKEN }}
CK_AWS_ACCESS_KEY_ID: ${{ secrets.CK_AWS_ACCESS_KEY_ID }}
CK_AWS_SECRET_ACCESS_KEY: ${{ secrets.CK_AWS_SECRET_ACCESS_KEY }}
CK_AWS_DEFAULT_REGION: ${{ secrets.CK_AWS_DEFAULT_REGION }}
CK_ECR_BASE_PATH: ${{ secrets.CK_ECR_BASE_PATH }}
CK_AWS_S3_BUCKET: ${{ secrets.CK_AWS_S3_BUCKET }}
CK_TELEGRAM_TOKEN: ${{ secrets.CK_TELEGRAM_TOKEN }}
GH_ACTION_ACCESS_TOKEN: ${{ secrets.GH_ACTION_ACCESS_TOKEN }}
run: invoke run_fast_tests
# TODO(gp): Run a single test. You need to disable the `push` on master.
#run: invoke run_fast_tests --pytest-opts="./helpers/test/test_lib_tasks.py::TestGhLogin1 -s --dbg"
#run: invoke run_fast_tests --pytest-opts="helpers/test/test_git.py::Test_git_modified_files1::test_get_modified_files_in_branch1 -s --dbg"
# In case of manual run, this workflow step will not be skipped and
# info in the step will be in format as seen in `with` statement.
# Blank with no info and skipped otherwise.
- name: Post status if was triggered manually
if: ${{ always() && github.event_name == 'workflow_dispatch' }}
uses: Sibz/github-status-action@v1
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: "run_fast_tests"
description: 'Job is done (manual run)'
state: ${{ job.status }}
sha: ${{ github.sha }}
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# TODO(vr): Bring back in #340.
# - name: Send Telegram notification for success
# if: ${{ success() && github.ref_name == 'master' }}
# uses: appleboy/telegram-action@master
# with:
# to: ${{ secrets.AM_TG_BUILDBOT_CHATID }}
# token: ${{ secrets.AM_TG_BUILDBOT_TOKEN }}
# message: |
# 🎉 Fast tests succeded at master
# Build failure '${{ github.workflow }}'
# Repo: '${{ github.repository }}'
# Branch: '${{ github.ref_name }}'
# Event: '${{ github.event_name }}'
# https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
# Notify the team via Telegram in case of failure.
- name: Send Telegram notification for failure
# Need to use ref_name as it contains the branch that triggered the
# workflow run.
# Alternative, head_ref is only available when the event that triggers a
# workflow run is either pull_request or pull_request_target.
if: ${{ failure() && github.ref_name == 'master' }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.AM_TG_BUILDBOT_CHATID }}
token: ${{ secrets.AM_TG_BUILDBOT_TOKEN }}
message: |
💣 FAST TESTS FAILED
Build failure '${{ github.workflow }}'
Repo: '${{ github.repository }}'
Branch: '${{ github.ref_name }}'
Event: '${{ github.event_name }}'
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}