-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (84 loc) · 2.62 KB
/
commit-stage.yaml
File metadata and controls
98 lines (84 loc) · 2.62 KB
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
name: Commit Stage
run-name: Commit Stage - ${{ github.ref }}
on:
push:
branches:
- '*'
- '!main'
workflow_call:
# Allows for workflow reusability
# Avoids running the same workflow concurrently on the same branch
concurrency:
group: ${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-22.04
name: Build Application
steps:
- uses: actions/checkout@v4
# ------------------------------- Project + Cache Setup ------------------------------- #
- name: Set up Python 3.12.1
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.12.1'
cache: 'pip'
- name: Set up cache
id: setup-cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
pip-${{ hashFiles('**/requirements.txt') }}
pip-
- name: Install dependencies
id: install-dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
test:
runs-on: ubuntu-22.04
needs: build
name: Unit Test
steps:
- uses: actions/checkout@v4
# ------------------------------- Unit Tests ------------------------------- #
- name: Restore cache from the build stage
id: restore-cache
uses: actions/cache/restore@v4
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('**/requirements.txt') }}
- name: Install cached dependencies
id: restore-dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Unit Testing with pytest
id: unit_test
run: pytest app/tests/services/
analyze:
runs-on: ubuntu-22.04
needs: build
name: Static Analysis
steps:
- uses: actions/checkout@v4
# ------------------------------- Static Analysis ------------------------------- #
- name: Restore cache from the build stage
id: restore-cache
uses: actions/cache/restore@v4
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('**/requirements.txt') }}
- name: Install cached dependencies
id: restore-dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint and Format code
id: lint
run: pre-commit run --all-files