Skip to content

Commit 179763e

Browse files
Add CWL conformance tests to CI (#205)
This commit adds the full suite of CWL v1.3 conformance tests to the CI pipeline, in order to prevent regressions with real usage.
1 parent 1669db5 commit 179763e

File tree

8 files changed

+174
-15
lines changed

8 files changed

+174
-15
lines changed

.github/workflows/ci-tests.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,74 @@ jobs:
2222
config-file: .github/codeql/config.yml
2323
languages: python
2424
- uses: github/codeql-action/analyze@v4
25+
cwl-conformance:
26+
name: "CWL conformance tests"
27+
strategy:
28+
matrix:
29+
on: [ "ubuntu-24.04", "macos-15-intel" ]
30+
runs-on: ${{ matrix.on }}
31+
env:
32+
POSTGRES_DB: streamflow
33+
POSTGRES_PASSWORD: streamflow
34+
POSTGRES_USER: streamflow
35+
POSTGRES_HOST: 127.0.0.1
36+
steps:
37+
- uses: actions/checkout@v6
38+
- uses: astral-sh/setup-uv@v7
39+
with:
40+
version: "0.9.16"
41+
- uses: actions/setup-python@v6
42+
with:
43+
python-version: 3.14
44+
- uses: actions/setup-node@v6
45+
with:
46+
node-version: "24"
47+
- name: "Install Docker (MacOS X)"
48+
uses: douglascamata/setup-docker-macos-action@v1
49+
with:
50+
colima-additional-options: '--mount /private/var/folders:w'
51+
if: ${{ startsWith(matrix.on, 'macos-') }}
52+
- uses: docker/setup-qemu-action@v3
53+
if: ${{ startsWith(matrix.on, 'ubuntu-') }}
54+
- name: "Start PostgreSQL Docker container"
55+
run: |
56+
docker run \
57+
--rm \
58+
--detach \
59+
--env POSTGRES_DB=${{ env.POSTGRES_DB }} \
60+
--env POSTGRES_PASSWORD=${{ env.POSTGRES_DB }} \
61+
--env POSTGRES_USER=${{ env.POSTGRES_DB }} \
62+
--publish 5432:5432 \
63+
postgres:18.1-alpine
64+
- name: "Install Postgresql client"
65+
run: brew install libpq@17
66+
if: ${{ startsWith(matrix.on, 'macos-') }}
67+
- name: "Download CWL conformance test script from StreamFlow"
68+
run: |
69+
curl -fsSL https://raw.githubusercontent.com/alpha-unito/streamflow/refs/tags/0.2.0.dev14/cwl-conformance-test.sh -o cwl-conformance-test.sh
70+
chmod 755 cwl-conformance-test.sh
71+
- name: "Test CWL v1.3 conformance"
72+
env:
73+
VERSION: "v1.3"
74+
COMMIT: "2063e9095f421f2a2ce12abaf196b2ba06ca5aae"
75+
EXCLUDE: "docker_entrypoint,modify_file_content,iwd-container-entryname1"
76+
DOCKER: "docker"
77+
run: ./cwl-conformance-test.sh
78+
- name: "Upload test results"
79+
if: ${{ !cancelled() }}
80+
uses: codecov/codecov-action@v5
81+
with:
82+
flags: ${{ startsWith(matrix.on, 'macos-') && 'macos' || 'ubuntu' }}
83+
report_type: test_results
84+
token: ${{ secrets.CODECOV_TOKEN }}
85+
- name: "Upload coverage report for conformance tests"
86+
uses: actions/upload-artifact@v6
87+
with:
88+
name: ${{ format('{0}-py3.14-cwlv1.3-docker-conformance-tests', matrix.on) }}
89+
path: |
90+
./coverage.xml
91+
retention-days: 1
92+
if-no-files-found: error
2593
static-checks:
2694
name: "Static checks"
2795
runs-on: ubuntu-24.04

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ jobs:
2121
version: "0.9.16"
2222
- uses: actions/setup-python@v6
2323
with:
24-
python-version: 3.13
24+
python-version: 3.14
2525
- name: "Install plugin"
2626
run: |
2727
uv venv
2828
uv pip install .
2929
- name: "Get version"
3030
run: |
3131
source .venv/bin/activate
32-
echo "STREAMFLOW_VERSION=$(python -c "from streamflow.plugins.unito.postgresql.version import VERSION; print(VERSION)")" >> $GITHUB_ENV
32+
echo "PLUGIN_VERSION=$(python -c "from streamflow.plugins.unito.postgresql.version import VERSION; print(VERSION)")" >> $GITHUB_ENV
3333
- name: "Check tag existence"
3434
uses: mukunku/tag-exists-action@v1.7.0
3535
id: check-tag
@@ -70,7 +70,7 @@ jobs:
7070
- name: "Get local version"
7171
run: |
7272
source .venv/bin/activate
73-
echo "STREAMFLOW_VERSION=$(python -c "from streamflow.plugins.unito.postgresql.version import VERSION; print(VERSION)")" >> $GITHUB_ENV
73+
echo "PLUGIN_VERSION=$(python -c "from streamflow.plugins.unito.postgresql.version import VERSION; print(VERSION)")" >> $GITHUB_ENV
7474
- name: "Get PyPI version"
7575
run: echo "PYPI_VERSION=$(pip index versions --pre streamflow-postgresql | grep streamflow-postgresql | sed 's/.*(\(.*\))/\1/')" >> $GITHUB_ENV
7676
- name: "Build Python packages"

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ lint = [
5959
"pyupgrade==3.21.2"
6060
]
6161
test = [
62+
"cwltest==2.6.20251216093331",
6263
"pytest==9.0.2",
6364
"pytest-asyncio==1.3.0",
6465
"pytest-cov==7.0.0",

streamflow/plugins/unito/postgresql/database.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import hashlib
34
import json
45
from collections.abc import MutableMapping, MutableSequence
56
from importlib.resources import files
@@ -54,12 +55,17 @@ async def __aenter__(self):
5455
)
5556
async with self._pool.acquire() as conn:
5657
async with conn.transaction():
57-
await conn.execute(
58+
schema = (
5859
files(__package__)
5960
.joinpath("schemas")
6061
.joinpath("postgresql.sql")
6162
.read_text("utf-8")
6263
)
64+
schema_checksum = hashlib.new("sha1", usedforsecurity=False)
65+
schema_checksum.update(schema.encode("utf-8"))
66+
lock_key = int(schema_checksum.hexdigest(), 16) % (2**63 - 1)
67+
await conn.execute(f"SELECT pg_advisory_xact_lock({lock_key})")
68+
await conn.execute(schema)
6369
return self._pool
6470

6571
async def __aexit__(self, exc_type, exc_val, exc_tb):
@@ -148,17 +154,17 @@ async def add_deployment(
148154
json.dumps(wraps) if wraps else None,
149155
)
150156

151-
async def add_execution(self, step_id: int, tag: str, cmd: str) -> int:
157+
async def add_execution(self, step_id: int, job_token_id: int, cmd: str) -> int:
152158
async with self.pool as pool:
153159
async with pool.acquire() as conn:
154160
async with conn.transaction():
155161
return await conn.fetchval(
156-
"INSERT INTO execution(step, tag, cmd) "
162+
"INSERT INTO execution(step, job_token, cmd) "
157163
"VALUES($1, $2, $3) "
158164
"RETURNING id",
159165
step_id,
160-
tag,
161-
cmd.encode("utf-8"),
166+
job_token_id,
167+
cmd,
162168
)
163169

164170
async def add_filter(

streamflow/plugins/unito/postgresql/schemas/postgresql.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ CREATE TABLE IF NOT EXISTS token
6969
);
7070

7171

72+
CREATE TABLE IF NOT EXISTS recoverable
73+
(
74+
id SERIAL PRIMARY KEY,
75+
FOREIGN KEY (id) REFERENCES token (id)
76+
);
77+
78+
7279
CREATE TABLE IF NOT EXISTS provenance
7380
(
7481
dependee INTEGER,
@@ -106,13 +113,6 @@ CREATE TABLE IF NOT EXISTS target
106113
);
107114

108115

109-
CREATE TABLE IF NOT EXISTS recoverable
110-
(
111-
id SERIAL PRIMARY KEY,
112-
FOREIGN KEY (id) REFERENCES token (id)
113-
);
114-
115-
116116
CREATE TABLE IF NOT EXISTS filter
117117
(
118118
id SERIAL PRIMARY KEY,

tests/cwl-conformance/conftest.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from __future__ import annotations
2+
3+
import io
4+
import json
5+
import os
6+
from contextlib import redirect_stdout
7+
from typing import Any
8+
9+
from cwltest import utils
10+
11+
12+
def pytest_cwl_execute_test(
13+
config: utils.CWLTestConfig, processfile: str, jobfile: str | None
14+
) -> tuple[int, dict[str, Any] | None]:
15+
from streamflow.core.exception import WorkflowException
16+
from streamflow.cwl.runner import main
17+
18+
this_directory = os.path.abspath(os.path.dirname(__file__))
19+
args = [
20+
"--streamflow-file",
21+
os.path.join(this_directory, "streamflow.yml"),
22+
"--outdir",
23+
config.outdir,
24+
processfile,
25+
]
26+
if jobfile is not None:
27+
args.append(jobfile)
28+
29+
try:
30+
f = io.StringIO()
31+
with redirect_stdout(f):
32+
result = main(args)
33+
out = f.getvalue()
34+
return result, json.loads(out) if out else {}
35+
except WorkflowException:
36+
return 1, {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: v1.0
2+
database:
3+
type: unito.postgresql
4+
config:
5+
dbname: streamflow
6+
username: streamflow
7+
password: streamflow
8+
hostname: 127.0.0.1

uv.lock

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)