forked from hotosm/fAIr
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (94 loc) · 3.31 KB
/
test_backend_build.yml
File metadata and controls
103 lines (94 loc) · 3.31 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
# .github/workflows/test_backend_build.yml
name: Backend Tests with UV and Python Matrix
on:
push:
branches:
- master
- develop
paths:
- "backend/**"
- ".github/workflows/test_backend_build.yml"
pull_request:
branches:
- master
- develop
paths:
- "backend/**"
- ".github/workflows/test_backend_build.yml"
jobs:
test_with_uv_matrix:
runs-on: ubuntu-latest
services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
ports:
- 6379:6379
postgres:
image: postgis/postgis:14-3.2
env:
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
POSTGRES_DB: ai
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 2
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
permissions:
id-token: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} and uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install gdal
run: |
sudo apt-get update && sudo apt-get -y install gdal-bin libgdal-dev python3-gdal && sudo apt-get -y autoremove && sudo apt-get clean
- name: Install Dependencies
working-directory: ./backend
run: |
uv sync --group test
- name: Clone Ramp
run: git clone https://github.com/kshitijrajsharma/ramp-code-fAIr.git ramp-code
- name: Set up environment variables
run: |
echo "DATABASE_URL=postgis://admin:password@localhost:5432/ai" >> $GITHUB_ENV
echo "RAMP_HOME=${{ github.workspace }}" >> $GITHUB_ENV
echo "TRAINING_WORKSPACE=${{ github.workspace }}/backend/training" >> $GITHUB_ENV
- name: Run migrations
env:
TESTING_TOKEN: ${{ secrets.TESTING_TOKEN }}
OSM_CLIENT_ID: ${{ secrets.OSM_CLIENT_ID }}
OSM_CLIENT_SECRET: ${{ secrets.OSM_CLIENT_SECRET }}
OSM_SECRET_KEY: ${{ secrets.OSM_SECRET_KEY }}
SECRET_KEY: "TEST_DJANGO_APP_SECRET_KEY"
DEBUG: "True"
# DATABASE_URL, RAMP_HOME, TRAINING_WORKSPACE are available from the previous step via $GITHUB_ENV
working-directory: ./backend
run: |
uv run python manage.py makemigrations
uv run python manage.py makemigrations core
uv run python manage.py makemigrations login
uv run python manage.py migrate
uv run python manage.py migrate login
uv run python manage.py migrate core
- name: Run tests
env:
TESTING_TOKEN: ${{ secrets.TESTING_TOKEN }}
OSM_CLIENT_ID: ${{ secrets.OSM_CLIENT_ID }}
OSM_CLIENT_SECRET: ${{ secrets.OSM_CLIENT_SECRET }}
OSM_SECRET_KEY: ${{ secrets.OSM_SECRET_KEY }}
SECRET_KEY: "TEST_DJANGO_APP_SECRET_KEY"
DEBUG: "True"
# DATABASE_URL, RAMP_HOME, TRAINING_WORKSPACE are available from $GITHUB_ENV
working-directory: ./backend
run: uv run coverage run manage.py test tests