-
Notifications
You must be signed in to change notification settings - Fork 8
163 lines (143 loc) · 5.74 KB
/
backend.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Backend Checks
on:
push:
branches:
- main
- nextjs
- prod-deploy
pull_request:
paths:
- "training/**"
jobs:
lint:
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up mamba env
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Setup Mamba
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-version: latest
use-mamba: true
activate-environment: dlp
- name: Cache Mamba env
id: cached-mamba-env
uses: actions/cache@v3
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
with:
path: /usr/share/miniconda3/envs/
key:
mamba-${{ runner.os }}-${{env.CACHE_NUMBER }}-${{hashFiles('**/training/environment.yml') }}
- name: Update environment
run:
mamba env update -n dlp -f
training/environment.yml
if: steps.cached-mamba-env.outputs.cache-hit != 'true'
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: /usr/share/miniconda3/envs/dlp
key: training-venv-${{ runner.os }}-${{ hashFiles('**/training/poetry.lock') }}
restore-keys: training-venv-${{ runner.os }}-
#---------------------------------------------------
# install dependencies if cache does not exist
#---------------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: pwd && cd training && poetry install --no-interaction --no-root && poetry env info -p
shell: bash -el {0}
- name: Add Poetry env to PATH
run: cd training && echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
shell: bash -el {0}
#----------------------------------------------
# pyright static checker
#----------------------------------------------
- name: Run Pyright Static Checker
id: pyright-static-checker
uses: jordemort/action-pyright@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }} # You need this
reporter: github-pr-review # Change reporter.
#----------------------------------------------
# black formatter
#----------------------------------------------
- uses: rickstaa/action-black@v1
id: action_black
with:
black_args: "."
- uses: stefanzweifel/git-auto-commit-action@v4
if: steps.action_black.outputs.is_formatted == 'true'
with:
commit_message: ":art: Format Python code with psf/black"
commit_options: '--no-verify'
commit_user_name: github-actions
commit_user_email: [email protected]
test:
needs: lint
runs-on: ubuntu-22.04
steps:
#----------------------------------------------
# check-out repo and set-up mamba env
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Setup Mamba
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-version: latest
use-mamba: true
activate-environment: dlp
- name: Cache Mamba env
id: cached-mamba-env
uses: actions/cache@v3
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
with:
path: /usr/share/miniconda3/envs/
key:
mamba-${{ runner.os }}-${{env.CACHE_NUMBER }}-${{hashFiles('**/training/environment.yml') }}
- name: Update environment
run:
mamba env update -n dlp -f
training/environment.yml
if: steps.cached-mamba-env.outputs.cache-hit != 'true'
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: /usr/share/miniconda3/envs/dlp
key: training-venv-${{ runner.os }}-${{ hashFiles('**/training/poetry.lock') }}
restore-keys: training-venv-${{ runner.os }}-
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: cd training && poetry install --no-interaction --no-root
shell: bash -el {0}
- name: Add Poetry env to PATH
run: cd training && echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
shell: bash -el {0}
#----------------------------------------------
# run test suite
#----------------------------------------------
- name: Run tests with moto
run: |
export AWS_ACCESS_KEY_ID=testing
export AWS_SECRET_ACCESS_KEY=testing
export AWS_DEFAULT_REGION=us-west-2
cd training && poetry run pytest tests
shell: bash -el {0}