Skip to content

Commit 2599f9b

Browse files
ci : refactor to add uv
1 parent ff8608e commit 2599f9b

File tree

4 files changed

+2005
-2109
lines changed

4 files changed

+2005
-2109
lines changed

.github/workflows/backend_build.yml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -46,46 +46,6 @@ jobs:
4646
- name: Install uv
4747
run: pip install uv
4848

49-
- name: Download Basemodel
50-
run: wget https://api-prod.fair.hotosm.org/api/v1/workspace/download/ramp/baseline.zip
51-
52-
- name: Unzip and Move Basemodel
53-
run: unzip baseline.zip -d ramp-code/ramp
54-
- name: Install gdal
55-
run: |
56-
sudo apt-get update && sudo apt-get -y install gdal-bin libgdal-dev python3-gdal && sudo apt-get -y autoremove && sudo apt-get clean
57-
pip install GDAL==$(gdal-config --version)
58-
- name: Install ramp dependecies
59-
run: |
60-
cd ramp-code && cd colab && make install
61-
62-
- name: Install tensorflow
63-
run: pip install tensorflow==2.9.2
64-
65-
- name: Install fair utilities
66-
run: pip install hot-fair-utilities
67-
68-
- name: Install Psycopg2
69-
run: |
70-
sudo apt-get install python3-psycopg2
71-
72-
- name: Install redis
73-
run: |
74-
sudo apt install lsb-release
75-
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
76-
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
77-
sudo apt-get update
78-
sudo apt-get install redis
79-
redis-cli ping
80-
81-
- name: Install Dependencies
82-
working-directory: ./backend
83-
run: |
84-
uv pip compile --python-version=3.8 pyproject.toml -o requirements.txt --group api --group base-workers --group ramp-workers
85-
pip install --no-cache-dir -r requirements.txt
86-
pip install coverage
87-
pip install factory-boy
88-
8949
- name: Create env
9050
working-directory: ./backend
9151
run: |
@@ -100,18 +60,6 @@ jobs:
10060
- name: Run flower dashboard
10161
working-directory: ./backend
10262
run: celery -A aiproject --broker=redis://localhost:6379/ flower &
103-
104-
- name: Fix gdal array
105-
run: |
106-
pip uninstall -y gdal
107-
pip install numpy
108-
pip install GDAL==$(gdal-config --version) --global-option=build_ext --global-option="-I/usr/include/gdal"
109-
110-
- name: Check Opencv version
111-
run: |
112-
pip freeze | grep opencv
113-
pip install opencv-python-headless==4.7.0.68
114-
11563
- name: Run migrations
11664
env:
11765
TESTING_TOKEN: ${{ secrets.TESTING_TOKEN }}

.github/workflows/docker_build.yml

Lines changed: 0 additions & 159 deletions
This file was deleted.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# .github/workflows/test_backend_build.yml
2+
name: Backend Tests with UV and Python Matrix
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
- develop
9+
paths:
10+
- "backend/**"
11+
- ".github/workflows/test_backend_build.yml"
12+
pull_request:
13+
branches:
14+
- master
15+
- develop
16+
paths:
17+
- "backend/**"
18+
- ".github/workflows/test_backend_build.yml"
19+
20+
jobs:
21+
test_with_uv_matrix:
22+
runs-on: ubuntu-latest
23+
services:
24+
postgres:
25+
image: postgis/postgis:14-3.2
26+
env:
27+
POSTGRES_USER: admin
28+
POSTGRES_PASSWORD: password
29+
POSTGRES_DB: ai
30+
ports:
31+
- 5432:5432
32+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 2
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
python-version: ["3.10", "3.11"]
37+
permissions:
38+
id-token: write
39+
40+
steps:
41+
- name: Check out code
42+
uses: actions/checkout@v4
43+
44+
- name: Set up Python ${{ matrix.python-version }} and uv
45+
uses: astral-sh/setup-uv@v6
46+
with:
47+
python-version: ${{ matrix.python-version }}
48+
enable-cache: true
49+
cache-dependency-glob: "uv.lock"
50+
51+
- name: Install Dependencies
52+
working-directory: ./backend
53+
run: |
54+
uv add coverage factory-boy
55+
56+
- name: Clone Ramp
57+
run: git clone https://github.com/kshitijrajsharma/ramp-code-fAIr.git ramp-code
58+
59+
- name: Set up environment variables
60+
run: |
61+
echo "DATABASE_URL=postgis://admin:password@localhost:5432/ai" >> $GITHUB_ENV
62+
echo "RAMP_HOME=${{ github.workspace }}" >> $GITHUB_ENV
63+
echo "TRAINING_WORKSPACE=${{ github.workspace }}/backend/training" >> $GITHUB_ENV
64+
65+
- name: Run migrations
66+
env:
67+
TESTING_TOKEN: ${{ secrets.TESTING_TOKEN }}
68+
OSM_CLIENT_ID: ${{ secrets.OSM_CLIENT_ID }}
69+
OSM_CLIENT_SECRET: ${{ secrets.OSM_CLIENT_SECRET }}
70+
OSM_SECRET_KEY: ${{ secrets.OSM_SECRET_KEY }}
71+
# DATABASE_URL, RAMP_HOME, TRAINING_WORKSPACE are available from the previous step via $GITHUB_ENV
72+
working-directory: ./backend
73+
run: |
74+
uv run python manage.py makemigrations
75+
uv run python manage.py makemigrations core
76+
uv run python manage.py makemigrations login
77+
uv run python manage.py migrate
78+
uv run python manage.py migrate login
79+
uv run python manage.py migrate core
80+
81+
- name: Run tests
82+
env:
83+
TESTING_TOKEN: ${{ secrets.TESTING_TOKEN }}
84+
OSM_CLIENT_ID: ${{ secrets.OSM_CLIENT_ID }}
85+
OSM_CLIENT_SECRET: ${{ secrets.OSM_CLIENT_SECRET }}
86+
OSM_SECRET_KEY: ${{ secrets.OSM_SECRET_KEY }}
87+
# DATABASE_URL, RAMP_HOME, TRAINING_WORKSPACE are available from $GITHUB_ENV
88+
working-directory: ./backend
89+
run: uv run coverage run manage.py test tests

0 commit comments

Comments
 (0)