Fast tests #2397
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: Fast tests | |
on: | |
# Run on every PR to master that is ready to review (i.e., not draft). | |
pull_request: | |
# https://github.saobby.my.eu.orgmunity/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.saobby.my.eu.orgmunity/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 }} |