-
Notifications
You must be signed in to change notification settings - Fork 5
100 lines (81 loc) · 3.49 KB
/
rootski-ci.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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: build
on:
push:
# CI is triggered when commits enter these branches (on the GitHub remote server, not locally)
branches: [ trunk ]
pull_request:
# CI is triggered when PRs are opened with these branches as targets
branches: [ trunk ]
jobs:
build:
runs-on: ubuntu-latest
steps:
# checkout the code
- uses: actions/checkout@v2
# allow tests and other automated steps to interact with the rootski AWS account
- name: configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.CI__AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.CI__AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: install 3.9
uses: actions/setup-python@v2
with:
python-version: "3.9"
# cache the python environment for faster dependency installation
# it's important to create a key based on files that will change dependencies
# any changes to the files to the python env or hashes of files listed will invalidate the cache
# when the cache is invalidated a new key will be created based on the new hashfiles and used for future runs
- name: cache dependencies
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('**/aws-cdk/**/setup.py', '**/rootski_api/setup.cfg')}}
# cache the python environment for faster pre-commit
- name: cache pre-commit
uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: ~/.cache/pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
# - name: install docker
# uses: docker-practice/[email protected]
- name: run lambda handler tests
run: |
cd infrastructure/iac/aws-cdk/cognito/cognito/resources/jwks_ssm_custom_resource_lambda/
make install
make test
#############################
# --- Backend API Tests --- #
#############################
- name: install dependencies
run: |
# install global python dependencies
make install
# install python dependencies specific to the backend code
cd rootski_api
make install
- name: checkout trunk and current branches
run: |
# these steps are necessary for darker to compare diffs properly
# fetches all remote branches
git fetch
# creates a local branch of rootski remote default trunk branch
git checkout -b trunk origin/trunk || echo "trunk already exists"
# creates a local branch of the current running branch in pipeline
git checkout -b ${GITHUB_HEAD_REF} origin/${GITHUB_HEAD_REF} || echo "${GITHUB_HEAD_REF} already exists"
- name: run tests and other code quality checks
run: |
# run the backend tests
make --directory rootski_api/ test-ci
# check the code quality across the entire project (formatting, linting, static code checks)
make check-code-quality-ci
# upload the test report generated by pytest to the codecov service
- name: codecov
uses: codecov/[email protected]
with:
# directory to search for coverage reports
# directory: ./rootski_api/test-reports/
name: rootski backend tests