Skip to content

Commit 6fb2dfa

Browse files
committed
Modify to single CI pipeline
1 parent 9fa3fb0 commit 6fb2dfa

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# This workflow will install Python dependencies, lint and run test suite for all branches
2+
# And bandit security checks for master branch
3+
4+
name: Lint and test
5+
6+
on:
7+
push:
8+
9+
10+
env:
11+
API_KEY: ${{ secrets.API_KEY }}
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Set up Python 3.x
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.13'
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -r requirements-lint.txt
27+
- name: Run ruff check
28+
run: ruff check .
29+
- name: Run black check
30+
run: black --check .
31+
- name: Run isort check
32+
run: isort --check .
33+
34+
test:
35+
if: ${{ !(github.ref == 'refs/heads/main') }}
36+
runs-on: ubuntu-latest
37+
needs: lint
38+
39+
steps:
40+
- uses: actions/checkout@v3
41+
- name: Set up Python 3.x
42+
uses: actions/setup-python@v4
43+
with:
44+
python-version: '3.13'
45+
- name: Install dependencies
46+
run: |
47+
python -m pip install --upgrade pip
48+
pip install -r requirements.txt
49+
pip install pytest pytest-cov
50+
- name: Run test suite
51+
run: |
52+
pytest --cov=api tests/
53+
54+
test_main:
55+
if: github.ref == 'refs/heads/main'
56+
runs-on: ubuntu-latest
57+
needs: lint
58+
env:
59+
API_KEY: ${{ secrets.API_KEY }}
60+
61+
strategy:
62+
matrix:
63+
os: [ ubuntu-latest, macos-latest, windows-latest ]
64+
python-version: [ 3.9, 3.11, 3.13 ]
65+
66+
steps:
67+
- uses: actions/checkout@v3
68+
- name: Set up Python ${{ matrix.python-version }}
69+
uses: actions/setup-python@v4
70+
with:
71+
python-version: ${{ matrix.python-version }}
72+
- name: Display Python version
73+
run: python -c "import sys; print(sys.version)"
74+
- name: Install dependencies
75+
run: |
76+
python -m pip install --upgrade pip
77+
pip install -r requirements.txt
78+
pip install pytest pytest-cov
79+
- name: Run test suite
80+
run: |
81+
pytest --cov=api tests/
82+
83+
bandit-scan:
84+
if: github.ref == 'refs/heads/main'
85+
runs-on: ubuntu-latest
86+
needs: test_main
87+
steps:
88+
- uses: actions/checkout@v3
89+
# Runs a pre configured Bandit scan
90+
- name: Run bandit
91+
uses: jpetrucciani/bandit-check@master
92+
with:
93+
# only scans under this path
94+
path: './api'

0 commit comments

Comments
 (0)