marintosti12 commited on
Commit
13744c7
·
1 Parent(s): 510cb07
Files changed (1) hide show
  1. .github/workflows/ci.yaml +32 -16
.github/workflows/ci.yaml CHANGED
@@ -11,50 +11,66 @@ jobs:
11
  runs-on: ubuntu-latest
12
  timeout-minutes: 10
13
 
14
- strategy:
15
- matrix:
16
- python-version: [ "3.12" ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  steps:
19
- # Récuperation du code
20
  - name: Checkout
21
  uses: actions/checkout@v4
22
 
23
- # Configuration de python
24
  - name: Set up Python
25
  uses: actions/setup-python@v5
26
  with:
27
- python-version: ${{ matrix.python-version }}
28
 
29
- # Installation de poetry
30
  - name: Install Poetry
31
  uses: abatilo/actions-poetry@v3
32
  with:
33
  poetry-version: "1.8.3"
34
 
35
- # Setup cache poety et env
36
  - name: Cache Poetry virtualenv
37
  uses: actions/cache@v4
38
  with:
39
  path: |
40
  ~/.cache/pypoetry
41
  .venv
42
- key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
43
- restore-keys: |
44
- ${{ runner.os }}-poetry-${{ matrix.python-version }}-
45
-
46
 
47
- # Install de poetry
48
- - name: Install deps (no dev)
49
  run: poetry install --no-interaction --no-ansi
50
 
51
- # Ruff est un linter et formateur de code Python
 
 
 
 
 
 
 
 
 
 
52
  - name: Lint (ruff)
53
  run: |
54
  poetry run python -m pip install ruff
55
  poetry run ruff check .
56
 
57
- # Test avec pytest
58
  - name: Tests (pytest + coverage)
59
  run: |
60
  poetry run python -m pip install pytest pytest-cov
 
11
  runs-on: ubuntu-latest
12
  timeout-minutes: 10
13
 
14
+ services:
15
+ postgres:
16
+ image: postgres:16
17
+ env:
18
+ POSTGRES_USER: ci
19
+ POSTGRES_PASSWORD: ci
20
+ POSTGRES_DB: futurisys_ci
21
+ ports:
22
+ - 5432:5432
23
+ options: >-
24
+ --health-cmd="pg_isready -U ci -d futurisys_ci"
25
+ --health-interval=5s
26
+ --health-timeout=5s
27
+ --health-retries=20
28
+
29
+ env:
30
+ DATABASE_URL: postgresql+psycopg2://ci:ci@localhost:5432/futurisys_ci
31
+ ALEMBIC_DATABASE_URL: postgresql+asyncpg://ci:ci@localhost:5432/futurisys_ci
32
 
33
  steps:
 
34
  - name: Checkout
35
  uses: actions/checkout@v4
36
 
 
37
  - name: Set up Python
38
  uses: actions/setup-python@v5
39
  with:
40
+ python-version: "3.12"
41
 
 
42
  - name: Install Poetry
43
  uses: abatilo/actions-poetry@v3
44
  with:
45
  poetry-version: "1.8.3"
46
 
 
47
  - name: Cache Poetry virtualenv
48
  uses: actions/cache@v4
49
  with:
50
  path: |
51
  ~/.cache/pypoetry
52
  .venv
53
+ key: ${{ runner.os }}-poetry-3.12-${{ hashFiles('**/poetry.lock') }}
 
 
 
54
 
55
+ - name: Install deps
 
56
  run: poetry install --no-interaction --no-ansi
57
 
58
+ - name: Wait for Postgres
59
+ run: |
60
+ sudo apt-get update && sudo apt-get install -y postgresql-client
61
+ for i in {1..30}; do
62
+ pg_isready -h localhost -p 5432 -U ci -d futurisys_ci && break
63
+ sleep 2
64
+ done
65
+
66
+ - name: Run Alembic migrations
67
+ run: PYTHONPATH=./src poetry run alembic upgrade head
68
+
69
  - name: Lint (ruff)
70
  run: |
71
  poetry run python -m pip install ruff
72
  poetry run ruff check .
73
 
 
74
  - name: Tests (pytest + coverage)
75
  run: |
76
  poetry run python -m pip install pytest pytest-cov