This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (72 loc) · 2.28 KB
/
python-test.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
name: Python 🐍 CI/CD tests
on:
push:
branches: [main, develop]
paths-ignore: # prevents workflow execution when only these types of files are modified
- "**.md" # wildcards prevent file in any repo dir from trigering workflow
- "**.bib"
- "**.ya?ml" # captures both .yml and .yaml
- "LICENSE"
- ".gitignore"
pull_request:
branches: [main, develop]
types: [opened, reopened] # excludes syncronize to avoid redundant trigger from commits on PRs
paths-ignore:
- "**.md"
- "**.bib"
- "**.ya?ml"
- "LICENSE"
- ".gitignore"
workflow_dispatch: # also allow manual trigger, for testing purposes
defaults:
run:
shell: bash -l {0}
jobs:
build:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
DATABASE_URL: postgresql+psycopg://user:password@localhost:5432/testdb
API_KEY: test_api_key
strategy:
matrix:
python-version: ["3.11", "3.12"]
os: [ubuntu-latest]
services:
postgres:
image: postgres
env:
POSTGRES_DB: testdb
POSTGRES_USER: user
POSTGRES_PASSWORD: password
ports:
- 5432:5432
# Use health checks to wait until postgres is ready
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: pip install .[test]
- name: Wait for PostgreSQL to start
run: |
until pg_isready -h localhost -p 5432 -U user; do
echo "Waiting for PostgreSQL to start..."
sleep 2
done
- name: Run unit tests
run: pytest tests/unit
- name: Run integrations tests
run: pytest tests/integration
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}