Skip to content

Commit 361335d

Browse files
committed
add CI workflows
1 parent 8c3a07d commit 361335d

File tree

7 files changed

+211
-3
lines changed

7 files changed

+211
-3
lines changed
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-FileCopyrightText: 2025 DB Systel GmbH
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: "Reusable Poetry build workflow"
6+
inputs:
7+
python:
8+
default: "3.10"
9+
description: "Value for 'python-version'"
10+
required: false
11+
type: string
12+
poetry_args:
13+
default: ""
14+
description: "Additional arguments for the poetry install step'"
15+
required: false
16+
type: string
17+
runs:
18+
using: "composite"
19+
steps:
20+
- name: Install poetry
21+
run: pipx install poetry
22+
shell: bash
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ inputs.python }}
27+
cache: "poetry"
28+
- name: Install dependencies
29+
run: poetry install --no-interaction ${{ inputs.poetry_args }}
30+
shell: bash

.github/workflows/publish.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-FileCopyrightText: 2025 DB Systel GmbH
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: Publish release on PyPI
6+
on:
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Build and publish to PyPI
16+
uses: JRubics/[email protected]
17+
with:
18+
pypi_token: ${{ secrets.PYPI_TOKEN }}

.github/workflows/test.yaml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# SPDX-FileCopyrightText: 2025 DB Systel GmbH
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: Test suites
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
13+
jobs:
14+
# Test using the tool via poetry on different OSes and python versions
15+
test-os-python-matrix:
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
max-parallel: 10
19+
# do not abort the whole test job if one combination in the matrix fails
20+
fail-fast: false
21+
matrix:
22+
python-version: ["3.10", "3.11", "3.12", "3.13"]
23+
os: [ubuntu-22.04]
24+
include:
25+
- python-version: "3.10"
26+
os: macos-latest
27+
- python-version: "3.10"
28+
os: windows-latest
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: ./.github/actions/poetrybuild
33+
with:
34+
python: ${{ matrix.python-version }}
35+
poetry_args: --only main
36+
- name: Execute purl-tools
37+
run: poetry run purl-tools --help
38+
39+
# Test building the package and installing it via pip3
40+
test-build-install:
41+
runs-on: ubuntu-22.04
42+
steps:
43+
- uses: actions/checkout@v4
44+
- name: Install poetry
45+
run: pipx install poetry
46+
- name: Set up Python
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: "3.10"
50+
cache: "poetry"
51+
- name: Build package
52+
run: poetry build
53+
- name: Install package
54+
run: pip3 install dist/purl_tools-*.tar.gz
55+
- name: Run package
56+
run: |
57+
purl-tools --version
58+
purl-tools --help
59+
60+
# Formatting
61+
pylint:
62+
runs-on: ubuntu-22.04
63+
steps:
64+
- uses: actions/checkout@v4
65+
- uses: ./.github/actions/poetrybuild
66+
- name: Lint with pylint
67+
run: poetry run pylint --disable=fixme purltools/ tests/
68+
69+
formatting:
70+
runs-on: ubuntu-22.04
71+
steps:
72+
- uses: actions/checkout@v4
73+
- uses: ./.github/actions/poetrybuild
74+
- name: Test formatting with isort and black
75+
run: |
76+
poetry run isort --check purltools/ tests/
77+
poetry run black --check .
78+
79+
mypy:
80+
runs-on: ubuntu-22.04
81+
steps:
82+
- uses: actions/checkout@v4
83+
- uses: ./.github/actions/poetrybuild
84+
- name: Test typing with mypy
85+
run: poetry run mypy
86+
87+
pytest:
88+
runs-on: ubuntu-22.04
89+
steps:
90+
- uses: actions/checkout@v4
91+
- uses: ./.github/actions/poetrybuild
92+
- name: Test with pytest
93+
run: poetry run pytest
94+
95+
# REUSE
96+
reuse:
97+
runs-on: ubuntu-latest
98+
steps:
99+
- uses: actions/checkout@v4
100+
- name: Check REUSE Compliance
101+
uses: fsfe/reuse-action@v3

poetry.lock

+58-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ isort = "^6.0.0"
1919
pytest = "^8.3.4"
2020
types-requests = "^2.32.0.20241016"
2121
bump-my-version = "^0.32.0"
22+
black = "^25.1.0"
2223

2324
[tool.poetry.scripts]
2425
purl-tools = "purltools.main:_cli"
@@ -36,7 +37,7 @@ line-length = 100
3637

3738
# MYPY settings
3839
[tool.mypy]
39-
files = ["purltools/*.py"]
40+
files = ["purltools/*.py", "tests/*.py"]
4041
disable_error_code = ["import-untyped"]
4142

4243
# Bump-My-Version

tests/test_purl2cd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_purl2cd_github_tag():
9090
"""GitHub PURLs using a tag"""
9191
purl = "pkg:github/openrailassociation/[email protected]"
9292
expected_coordinates = (
93-
"git/github/openrailassociation/github-org-manager/d61ee9a40e258ead9fa44642bfad49307498c343"
93+
"git/github/openrailassociation/github-org-manager/1004ad1ac52465b97602a93d25d3ea1713d4b5d8"
9494
)
9595

9696
assert purl2clearlydefined(purl) == expected_coordinates

tests/test_url_purl.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def test_purl2url():
1010

1111
assert convert_purl2url(purl) == expected_url
1212

13+
1314
def test_url2purl():
1415
"""Test url2purl conversion"""
1516
url = "http://pypi.org/project/github-org-manager/0.5.6/"

0 commit comments

Comments
 (0)