Repository navigation
127 lines (122 loc) · 5.14 KB
/
Copy pathpython-package.yml
File metadata and controls
127 lines (122 loc) · 5.14 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
name: tests
on:
push:
branches:
- master
pull_request:
branches:
- '*'
jobs:
build:
runs-on: ubuntu-latest
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# The official pgvector image: postgres plus the pgvector extension,
# which articles.topic_embedding needs. pg17 also matches production
# (frida runs PostgreSQL 17 since 2026-08-17); plain postgres:NN
# images do not ship pgvector.
image: pgvector/pgvector:pg17
# Provide the password for postgres
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST: localhost
PGPASSWORD: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
# CPython 3.14 is what production runs and what a fresh `uv sync`
# selects by default -- uv prefers the newest managed interpreter --
# so it is what developers get on their own machines unless they say
# otherwise.
#
# PyPy 3.11 was dropped from the matrix 2026-08-17: production
# migrated to CPython and is not going back, so the PyPy leg only
# guarded a floor no deployment uses, at the cost of a second slow
# test run. The requires-python = ">=3.11" floor is now nominal
# rather than CI-enforced; if it ever matters again, restore a
# matrix entry rather than trusting it.
python-version: ["3.14"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up Icelandic locale
run: |
sudo locale-gen is_IS.UTF-8
sudo update-locale
- name: Install dependencies
run: |
pip install uv
# psycopg2 is built from source (not psycopg2-binary), so libpq headers
# and pg_config must be present before the sync, not after.
sudo apt-get install -y libpq-dev
# --frozen: install exactly what uv.lock pins, and fail rather than
# silently re-resolving if the lock is out of date with pyproject.toml.
# Bind to the interpreter setup-python provisioned above, so uv does
# not go and fetch a different one.
uv sync --frozen --python "$(which python)"
sudo npm i -g jshint
sudo apt-get install shellcheck
- name: Set up database
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
POSTGRES_HOST: localhost
PGPASSWORD: postgres
run: |
PGPASSWORD=postgres psql -h localhost -U postgres -c "create user reynir with password 'reynir';"
PGPASSWORD=postgres psql -h localhost -U postgres -c "create database scraper with encoding 'UTF8' TEMPLATE=template0;"
PGPASSWORD=postgres psql -h localhost -U postgres -d scraper -c "create extension if not exists \"uuid-ossp\";"
PGPASSWORD=postgres psql -h localhost -U postgres -d scraper -c "create extension if not exists vector;"
PGPASSWORD=postgres psql -h localhost -U postgres -d scraper -c "alter database scraper owner to reynir;"
uv run scraper.py --init
psql -f tests/files/populate_testdb.sql postgresql://postgres:postgres@localhost:5432/scraper
- name: Create API keys
run: |
cat "tests/files/dummy_greynir_api_key.txt" > "resources/GreynirServerKey.txt"
cat "tests/files/dummy_atm_data.json" > "queries/resources/isb_locations.json"
echo '${{ secrets.AWSPOLLY_KEY_JSON }}' > "resources/AWSPollyServerKey.json"
echo '${{ secrets.AZURE_KEY_JSON }}' > "resources/AzureSpeechServerKey.json"
- name: Test with pytest
# -ra: short summary of everything except passes. Not -rP: replaying
# passing tests' captured logs floods the output with the *intentional*
# ERROR lines from misconfiguration-path tests (bad
# GREYNIR_SUMMARY_MAX_AGE_DAYS, missing API key files), which read as
# failures to anyone scanning the log. Failed tests still print their
# captured logs in full.
run: |
uv run python -m pytest -vv -ra
- name: Run curlylint on templates
run: |
uv run curlylint templates/*
uv run curlylint templates/*/*
- name: Run jshint on JavaScript files
run: |
jshint static/js/common.js
jshint --prereq static/js/common.js static/js/page.js
- name: Run shellcheck on shell scripts
run: |
shellcheck -x scripts/*.sh
- name: Slack notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: Integration Testing (Python ${{ matrix.python-version }})
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: failure() # Pick up event if the job fails