Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
name: CI

on: [push, pull_request]
on:
pull_request:
push:
branches: [master]

jobs:

test:
runs-on: ubuntu-latest
strategy:
matrix:
pg-version: ['12', '13', '14', '15', '16', '17', '18', '19']
pg-version: ["12", "13", "14", "15", "16", "17", "18", "19"]

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand All @@ -23,16 +25,16 @@ jobs:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Build
run: nix-shell --run "xpg -v ${{ matrix.pg-version }} build"
run: nix-shell --argstr pgVersion "${{ matrix.pg-version }}" --arg cassert false --run "xpg -v ${{ matrix.pg-version }} build"

- name: Run tests
run: nix-shell --run "xpg -v ${{ matrix.pg-version }} test"
run: nix-shell --argstr pgVersion "${{ matrix.pg-version }}" --arg cassert false --run "xpg -v ${{ matrix.pg-version }} test"

test-on-macos:
runs-on: macos-15
strategy:
matrix:
pg-version: ['17']
pg-version: ["17"]
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

Expand All @@ -48,16 +50,21 @@ jobs:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Build
run: nix-shell --run "xpg -v ${{ matrix.pg-version }} build"
run: nix-shell --argstr pgVersion "${{ matrix.pg-version }}" --arg cassert false --run "xpg -v ${{ matrix.pg-version }} build"

- name: Run tests
run: nix-shell --run "xpg -v ${{ matrix.pg-version }} test"
run: nix-shell --argstr pgVersion "${{ matrix.pg-version }}" --arg cassert false --run "xpg -v ${{ matrix.pg-version }} test"

loadtest:
runs-on: ubuntu-latest
strategy:
matrix:
params: [ {reqs: 10000, batch: 200}, {reqs: 20000, batch: 400}, {reqs: 40000, batch: 800} ]
params:
[
{ reqs: 10000, batch: 200 },
{ reqs: 20000, batch: 400 },
{ reqs: 40000, batch: 800 },
]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

Expand All @@ -71,19 +78,18 @@ jobs:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Build
run: nix-shell --run "xpg build"
run: nix-shell --argstr pgVersion "17" --arg cassert false --run "xpg build"

- name: Run load test
run: |
nix-shell --run "net-loadtest ${{ matrix.params.reqs }} ${{ matrix.params.batch }}" >> "$GITHUB_STEP_SUMMARY"
nix-shell --argstr pgVersion "17" --arg cassert false --run "net-loadtest ${{ matrix.params.reqs }} ${{ matrix.params.batch }}" >> "$GITHUB_STEP_SUMMARY"

coverage:

runs-on: ubuntu-latest

strategy:
matrix:
pg-version: ['17']
pg-version: ["17"]

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand All @@ -98,7 +104,7 @@ jobs:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Coverage
run: nix-shell --run "xpg -v ${{ matrix.pg-version }} coverage"
run: nix-shell --argstr pgVersion "${{ matrix.pg-version }}" --arg cassert false --run "xpg -v ${{ matrix.pg-version }} coverage"

- name: Send coverage to Coveralls
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
Expand All @@ -107,7 +113,6 @@ jobs:
files: ./build-${{ matrix.pg-version }}/coverage.info

style:

runs-on: ubuntu-latest

steps:
Expand Down
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ $ xpg -v 13 test

This will spawn a local db and an nginx server for testing.

To run a single test , set `PYTEST_ARGS` to `-k test_function_name`. For example:

```bash
$ nix develop
$ PYTEST_ARGS="-k test_connect" xpg test
```

Will run the `test_connect` test only. `PYTEST_ARGS` is passed through to pytest, so you can pass other arguments to pytest as well. in fact you can pass any args via `PYTEST_ARGS`. You can e.g. run all tests in a file:

```bash
$ nix develop
$ PYTEST_ARGS="PYTEST_ARGS="test/test_user_db.py" xpg test
```

Will run tests in `test/test_user_db.py`, or:


### Debugging

You can turn on logging level to see curl traces with
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ include $(PGXS)

.PHONY: test
test:
net-with-nginx python -m pytest -s -vv
net-with-nginx python -m pytest -s -vv $(PYTEST_ARGS)
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# 2025-11-13
nixpkgs.url = "github:NixOS/nixpkgs/91c9a64ce2a84e648d0cf9671274bb9c2fb9ba60";
xpg = {
url = "github:steve-chavez/xpg/v2.4.0";
url = "github:steve-chavez/xpg/v2.5.0";
};
};

Expand Down
4 changes: 3 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ in
inherit (xpgLock) owner repo rev;
sha256 = xpgLock.narHash;
})
, pgVersion ? null
, cassert ? true
}:
let
nginxCustom = pkgs.callPackage ./nix/nginxCustom.nix {};
Expand All @@ -36,7 +38,7 @@ in
pkgs.mkShell {
buildInputs =
[
xpgPkgs.xpg
(if pgVersion == null then xpgPkgs.xpg else xpgPkgs.xpg.forVersions { versions = [ pgVersion ]; inherit cassert; })
pythonDeps
nginxCustom.nginxScript
pkgs.curlWithGnuTls
Expand Down
Loading
Loading