-
Notifications
You must be signed in to change notification settings - Fork 72
133 lines (118 loc) · 4.41 KB
/
ci-test.yml
File metadata and controls
133 lines (118 loc) · 4.41 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
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
name: Test
on:
pull_request:
branches: [master]
push:
branches: [master]
schedule:
# * is a special character in YAML so you have to quote this string
# min hours day(month) month day(week)
- cron: "0 0 * * 0"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
pytester:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
backend: ["local", "mongodb", "postgres"]
exclude:
# ToDo: take if back when the connection become stable
# or resolve using `InMemoryMongoClient`
- { os: "macOS-latest", backend: "mongodb" }
- { os: "macOS-latest", backend: "postgres" }
- { os: "windows-latest", backend: "postgres" }
env:
CACHIER_TEST_HOST: "localhost"
CACHIER_TEST_PORT: "27017"
#CACHIER_TEST_DB: "dummy_db"
#CACHIER_TEST_USERNAME: "myuser"
#CACHIER_TEST_PASSWORD: "yourpassword"
CACHIER_TEST_VS_DOCKERIZED_MONGO: "true"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e . -r tests/requirements.txt
- name: Unit tests (local)
if: matrix.backend == 'local'
run: pytest -m "not mongo and not sql" --cov=cachier --cov-report=term --cov-report=xml:cov.xml
- name: Setup docker (missing on MacOS)
if: runner.os == 'macOS' && matrix.backend == 'mongodb'
run: |
brew install docker
colima start
# For testcontainers to find the Colima socket
sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
# ToDo: find a way to cache docker images
#- name: Cache Container Images
# if: matrix.backend == 'mongodb'
# uses: borda/cache-container-images-action@b32a5e804cb39af3c3d134fc03ab76eac0bfcfa9
# with:
# prefix-key: "mongo-db"
# images: mongo:latest
- name: Start MongoDB in docker
if: matrix.backend == 'mongodb'
run: |
# start MongoDB in a container
docker run -d -p ${{ env.CACHIER_TEST_PORT }}:27017 --name mongodb mongo:latest
# wait for MongoDB to start, which is in average 5 seconds
sleep 5
# show running containers
docker ps -a
- name: Unit tests (DB)
if: matrix.backend == 'mongodb'
run: pytest -m "mongo" --cov=cachier --cov-report=term --cov-report=xml:cov.xml
- name: Speed eval
run: python tests/speed_eval.py
- name: Start PostgreSQL in docker
if: matrix.backend == 'postgres'
run: |
docker run -d \
-e POSTGRES_USER=testuser \
-e POSTGRES_PASSWORD=testpass \
-e POSTGRES_DB=testdb \
-p 5432:5432 \
--name postgres postgres:15
# wait for PostgreSQL to start
sleep 10
docker ps -a
- name: Install SQL core test dependencies (SQL/Postgres)
if: matrix.backend == 'postgres'
run: |
python -m pip install -e . -r tests/sql_requirements.txt
- name: Unit tests (SQL/Postgres)
if: matrix.backend == 'postgres'
env:
SQLALCHEMY_DATABASE_URL: postgresql://testuser:testpass@localhost:5432/testdb
run: pytest -m sql --cov=cachier --cov-report=term --cov-report=xml:cov.xml
- name: Upload coverage to Codecov
continue-on-error: true
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
name: codecov-umbrella
token: ${{ secrets.CODECOV_TOKEN }} # required
flags: ${{ matrix.backend }}
testing-guardian:
runs-on: ubuntu-latest
needs: pytester
if: always()
steps:
- run: echo "${{ needs.pytester.result }}"
- name: failing...
if: needs.pytester.result == 'failure'
run: exit 1
- name: cancelled or skipped...
if: contains(fromJSON('["cancelled", "skipped"]'), needs.pytester.result)
timeout-minutes: 1
run: sleep 90