-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (71 loc) · 2.68 KB
/
Copy pathpython.yml
File metadata and controls
82 lines (71 loc) · 2.68 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
name: Python
on:
push:
branches: ["main"]
tags: ["*"]
pull_request:
branches: ["*"]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Tests and coverage
runs-on: ubuntu-latest
# Workaround for read-only dependabot GITHUB_TOKEN in meow-coverage
permissions:
issues: write
pull-requests: write
contents: read
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
database: ["sqlite", "postgres"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@c8813ba1bc76ebf779b911ad8ffccbf2e449cb48
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install hatch
- name: Set up PostgreSQL 15
# 1. Mount postgres data files onto a tmpfs in-memory filesystem to reduce overhead of docker's overlayfs layer.
# 2. Expose the unix socket for postgres. This removes latency of using docker-proxy for connections.
run: |
docker run -d -p 5432:5432 \
--tmpfs /var/lib/postgres:rw,size=6144m \
--mount 'type=bind,src=/var/run/postgresql,dst=/var/run/postgresql' \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_INITDB_ARGS="--lc-collate C --lc-ctype C --encoding UTF8" \
postgres:15
- name: Type checking and Formatting
run: hatch fmt --check
- name: Prepare lint
shell: bash
run: echo PYTHON_TARGET="py${{ matrix.python-version }}" | sed -r "s/\.//" >> $GITHUB_ENV
- name: Lint
uses: chartboost/ruff-action@1ec810db51b3ebdd902c812e962d2f7aafe85fcf
with:
args: check --target-version ${{ env.PYTHON_TARGET }}
- name: Tests and coverage
shell: bash
run: hatch test --python ${{ matrix.python-version }} -p -c
env:
# These two options can always be populated, as unless the third below
# is also enabled they are just ignored.
SYNAPSE_POSTGRES_USER: "postgres"
SYNAPSE_POSTGRES_PASSWORD: "postgres"
# Although the options are 'postgres' and 'sqlite', we only populate this when
# it is 'postgres'
SYNAPSE_POSTGRES: ${{ matrix.database == 'postgres' || ''}}
- name: Codecov - Upload coverage
uses: codecov/codecov-action@ca0a928a4cb3911011e868128a5cd90437c12db1
with:
token: ${{secrets.CODECOV_TOKEN}}
files: "lcov.info"