Skip to content

Commit b9ad275

Browse files
committed
Update github actions
1 parent 36ae4aa commit b9ad275

File tree

3 files changed

+574
-522
lines changed

3 files changed

+574
-522
lines changed

.github/workflows/ci.yml

Lines changed: 70 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,85 @@
11
name: CI
2+
3+
env:
4+
POSTGRES_USER: location_api
5+
POSTGRES_DB: location_api
6+
POSTGRES_PASSWORD: location_api
7+
28
on:
39
pull_request:
410
branches:
511
- main
612
push:
713
branches:
8-
- main
14+
- '**'
915
jobs:
1016
test:
1117
strategy:
1218
matrix:
1319
python-version: ["3.12"]
1420
os: [ubuntu-latest]
1521
runs-on: ${{ matrix.os }}
22+
23+
services:
24+
postgres:
25+
image: postgis/postgis
26+
env:
27+
POSTGRES_USER: ${{ env.POSTGRES_USER }}
28+
POSTGRES_DB: ${{ env.POSTGRES_DB }}
29+
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
30+
options: >-
31+
--health-cmd pg_isready
32+
--health-interval 10s
33+
--health-timeout 5s
34+
--health-retries 5
35+
ports:
36+
- 5432:5432
37+
1638
steps:
17-
- name: Check out repository
18-
uses: actions/checkout@v3
19-
- name: "Set up python ${{ matrix.python-version }}"
20-
id: setup-python
21-
uses: actions/setup-python@v4
22-
with:
23-
python-version: ${{ matrix.python-version }}
24-
#----------------------------------------------
25-
# ----- install & configure poetry -----
26-
#----------------------------------------------
27-
- name: Install Poetry
28-
uses: snok/install-poetry@v1
29-
with:
30-
virtualenvs-create: true
31-
virtualenvs-in-project: true
32-
#----------------------------------------------
33-
# load cached venv if cache exists
34-
#----------------------------------------------
35-
- name: Load cached venv
36-
id: cached-poetry-dependencies
37-
uses: actions/cache@v3
38-
with:
39-
path: .venv
40-
key: venv-${{ matrix.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
41-
#----------------------------------------------
42-
# install dependencies if cache does not exist
43-
#----------------------------------------------
44-
- name: Install dependencies
45-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
46-
run: poetry install --no-interaction --no-root
47-
#----------------------------------------------
48-
# install your root project, if required
49-
#----------------------------------------------
50-
- name: Install library
51-
run: poetry install --no-interaction
52-
#----------------------------------------------
53-
# Run tests
54-
#----------------------------------------------
55-
- name: Run tests
56-
run: poetry run invoke test
57-
#----------------------------------------------
58-
# Build docs
59-
#----------------------------------------------
60-
- name: Build docs
61-
run: poetry run invoke docs
62-
#----------------------------------------------
63-
# Deploy docs (if on main)
64-
#----------------------------------------------
65-
- name: Deploy docs 🚀
66-
if: github.ref == 'refs/heads/main'
67-
uses: JamesIves/github-pages-deploy-action@v4
68-
with:
69-
folder: docs/_build
39+
- uses: actions/checkout@v4
40+
- name: Install poetry
41+
run: pipx install poetry
42+
- name: "Set up python ${{ matrix.python-version }}"
43+
id: setup-python
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: ${{ matrix.python-version }}
47+
cache: 'poetry'
48+
#----------------------------------------------
49+
# ----- cache and install os packages -----
50+
#----------------------------------------------
51+
- name: Cache APT packages
52+
uses: actions/cache@v4
53+
with:
54+
path: /var/cache/apt
55+
key: ${{ runner.os }}-apt-${{ hashFiles('**/Dockerfile') }}
56+
restore-keys: |
57+
${{ runner.os }}-apt-
58+
- name: Cache APT package lists
59+
uses: actions/cache@v4
60+
with:
61+
path: /var/lib/apt/lists
62+
key: ${{ runner.os }}-apt-lists-${{ hashFiles('**/Dockerfile') }}
63+
restore-keys: |
64+
${{ runner.os }}-apt-lists-
65+
- name: Install system dependencies
66+
run: |
67+
sudo apt-get update
68+
sudo apt-get install -y --no-install-recommends binutils libproj-dev gdal-bin libgeoip1 python3-gdal
69+
#----------------------------------------------
70+
# install dependencies
71+
#----------------------------------------------
72+
- name: Install dependencies
73+
run: poetry install --no-interaction --no-root
74+
#----------------------------------------------
75+
# install your root project, if required
76+
#----------------------------------------------
77+
- name: Install library
78+
run: poetry install --no-interaction
79+
#----------------------------------------------
80+
# Run tests
81+
#----------------------------------------------
82+
- name: Run tests
83+
env:
84+
DATABASE_URL: "postgres://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@localhost:5432/${{ env.POSTGRES_DB }}"
85+
run: poetry run python ./runtests.py

0 commit comments

Comments
 (0)