Skip to content

Commit 11f46ed

Browse files
nh13clintval
andauthored
ci: rename pythonpackage to tests, upate action versions (#223)
Co-authored-by: Clint Valentine <[email protected]>
1 parent 9a6bcf3 commit 11f46ed

File tree

7 files changed

+353
-111
lines changed

7 files changed

+353
-111
lines changed

.github/workflows/publish_fgpyo.yml

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: publish fgpyo
2+
3+
on:
4+
push:
5+
tags: '[0-9]+.[0-9]+.[0-9]+'
6+
7+
env:
8+
POETRY_VERSION: 1.8.2
9+
10+
jobs:
11+
on-main-branch-check:
12+
runs-on: ubuntu-24.04
13+
outputs:
14+
on_main: ${{ steps.contains_tag.outputs.retval }}
15+
steps:
16+
# TODO: remove this and the `git branch -a` when the following PR
17+
# is merged and released:
18+
# https://github.com/rickstaa/action-contains-tag/pull/18
19+
- name: git config --global remote.origin.followRemoteHEAD never
20+
shell: bash
21+
run: git config --global remote.origin.followRemoteHEAD never
22+
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- uses: rickstaa/action-contains-tag@v1
28+
id: contains_tag
29+
with:
30+
reference: "main"
31+
tag: "${{ github.ref_name }}"
32+
33+
tests:
34+
name: tests
35+
needs: on-main-branch-check
36+
if: ${{ needs.on-main-branch-check.outputs.on_main == 'true' }}
37+
uses: "./.github/workflows/tests.yml"
38+
39+
build-wheels:
40+
name: build wheels
41+
needs: tests
42+
uses: "./.github/workflows/wheels.yml"
43+
44+
build-sdist:
45+
name: build source distribution
46+
needs: tests
47+
runs-on: ubuntu-24.04
48+
steps:
49+
- uses: actions/checkout@v4
50+
with:
51+
fetch-depth: 0
52+
53+
- uses: actions/setup-python@v5
54+
with:
55+
python-version: 3.12
56+
57+
- name: Install and configure Poetry
58+
uses: snok/install-poetry@v1
59+
with:
60+
version: ${{env.POETRY_VERSION}}
61+
installer-parallel: true
62+
virtualenvs-in-project: true
63+
64+
- name: Install dependencies
65+
run: poetry install --no-interaction --no-root --without=dev
66+
67+
- name: Install project
68+
run: poetry install --no-interaction --without=dev
69+
70+
- name: Build package
71+
run: poetry build --format=sdist
72+
73+
- uses: actions/upload-artifact@v4
74+
with:
75+
name: fgpyo-sdist
76+
path: dist/*.tar.gz
77+
78+
publish-to-pypi:
79+
runs-on: ubuntu-24.04
80+
needs: [build-wheels, build-sdist]
81+
environment: pypi
82+
permissions:
83+
id-token: write
84+
steps:
85+
- uses: actions/download-artifact@v4
86+
with:
87+
path: packages
88+
pattern: 'fgpyo-*'
89+
merge-multiple: true
90+
91+
- uses: pypa/gh-action-pypi-publish@release/v1
92+
with:
93+
packages-dir: packages/
94+
skip-existing: true
95+
verbose: true
96+
97+
make-changelog:
98+
runs-on: ubuntu-24.04
99+
needs: publish-to-pypi
100+
outputs:
101+
release_body: ${{ steps.git-cliff.outputs.content }}
102+
steps:
103+
- name: Checkout the Repository at the Tagged Commit
104+
uses: actions/checkout@v4
105+
with:
106+
fetch-depth: 0
107+
ref: ${{ github.ref_name }}
108+
109+
- name: Generate a Changelog
110+
uses: orhun/git-cliff-action@v3
111+
id: git-cliff
112+
with:
113+
config: pyproject.toml
114+
args: --latest --verbose
115+
env:
116+
GITHUB_REPO: ${{ github.repository }}
117+
118+
make-github-release:
119+
runs-on: ubuntu-24.04
120+
environment: github
121+
permissions:
122+
contents: write
123+
pull-requests: read
124+
needs: make-changelog
125+
steps:
126+
- name: Create Release
127+
id: create_release
128+
uses: softprops/action-gh-release@v2
129+
with:
130+
name: ${{ github.ref_name }}
131+
body: ${{ needs.make-changelog.outputs.release_body }}
132+
draft: false
133+
prerelease: false

.github/workflows/pythonpackage.yml

-90
This file was deleted.
File renamed without changes.

.github/workflows/tests.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
tags:
8+
- "!**"
9+
workflow_call:
10+
11+
12+
env:
13+
POETRY_VERSION: 1.8.2
14+
15+
permissions:
16+
pull-requests: write
17+
18+
jobs:
19+
Tests:
20+
runs-on: ubuntu-24.04
21+
strategy:
22+
matrix:
23+
PYTHON_VERSION: ["3.9", "3.10", "3.11", "3.12", "3.13"]
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Set up Python ${{matrix.PYTHON_VERSION}}
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{matrix.PYTHON_VERSION}}
31+
32+
- name: Get full Python version
33+
id: full-python-version
34+
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
35+
36+
- name: Install and configure Poetry
37+
uses: snok/install-poetry@v1
38+
with:
39+
version: ${{env.POETRY_VERSION}}
40+
installer-parallel: true
41+
virtualenvs-in-project: true
42+
43+
- name: Set up cache
44+
uses: actions/cache@v4
45+
id: cache
46+
with:
47+
path: .venv
48+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
49+
50+
- name: Ensure cache is healthy
51+
if: steps.cache.outputs.cache-hit == 'true'
52+
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
53+
54+
- name: Check that the lock file is up to date
55+
run: |
56+
poetry lock --check
57+
58+
- name: Install deps
59+
run: |
60+
poetry install
61+
62+
- name: Style checking
63+
run: |
64+
poetry run ruff format --check fgpyo tests
65+
66+
- name: Run lint
67+
run: |
68+
poetry run ruff check fgpyo tests
69+
70+
- name: Run mypy
71+
run: |
72+
poetry run mypy fgpyo tests --config=pyproject.toml
73+
74+
- name: Run pytest
75+
run: |
76+
poetry run python -m pytest --cov=fgpyo --cov-report=xml --cov-branch
77+
78+
- name: Run docs
79+
run: |
80+
set -euo pipefail
81+
poetry run mkdocs build --strict
82+
83+
- name: Upload code coverage
84+
uses: codecov/[email protected]
85+
with:
86+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/wheels.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: build wheels
2+
3+
on:
4+
pull_request:
5+
workflow_call:
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-wheels:
10+
name: Build wheels for ${{ matrix.python }}
11+
runs-on: ubuntu-24.04
12+
strategy:
13+
matrix:
14+
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python }}
23+
24+
- name: Build wheels
25+
run: pip wheel --no-deps -w wheelhouse .
26+
27+
- name: Upload wheels
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: fgpyo-wheels-${{ matrix.python }}
31+
path: ./wheelhouse/fgpyo*.whl
32+
if-no-files-found: error

0 commit comments

Comments
 (0)