Skip to content

Commit 2b0aea9

Browse files
authored
Merge pull request #90 from CompOmics/feature/new-api
Initial work for new 4.0 API
2 parents 0409a78 + dff9b59 commit 2b0aea9

66 files changed

Lines changed: 3949 additions & 66814 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish.yml

Lines changed: 91 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -1,204 +1,107 @@
1-
name: Publish to PyPI and GitHub release
1+
name: Publish
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
4+
release:
5+
types: [created]
76
workflow_dispatch:
8-
inputs:
9-
ref:
10-
description: 'Git ref (branch, tag, or SHA) to build from'
11-
required: true
12-
default: 'master' # ← was 'main'
13-
type: string
14-
15-
# Least-privilege defaults for all jobs (override per-job if needed)
16-
permissions:
17-
contents: write # to create releases and read code
18-
packages: write # to push container images to ghcr.io
19-
id-token: write # for PyPI OIDC publish
207

218
jobs:
22-
python-package:
9+
build-python-package:
2310
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
2413

2514
steps:
26-
- name: Select ref
27-
id: select-ref
28-
run: |
29-
if [ -n "${{ github.event.inputs.ref }}" ]; then
30-
echo "ref=${{ github.event.inputs.ref }}" >> $GITHUB_OUTPUT
31-
else
32-
# Fallback to the event ref (e.g. refs/tags/v1.2.3 on tag pushes)
33-
echo "ref=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
34-
fi
35-
36-
- uses: actions/checkout@v4
37-
with:
38-
# Checkout the chosen ref for manual runs; for tag-push runs this will be that tag
39-
ref: ${{ steps.select-ref.outputs.ref }}
40-
41-
- name: Derive version
42-
id: version
43-
shell: bash
44-
run: |
45-
# If the ref looks like a release tag (v*), use it as version (strip refs/tags/ if present)
46-
REF="${{ steps.select-ref.outputs.ref }}"
47-
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
48-
VER="${GITHUB_REF#refs/tags/}"
49-
elif [[ "$REF" == refs/tags/v* ]]; then
50-
VER="${REF#refs/tags/}"
51-
elif [[ "$REF" == v* ]]; then
52-
VER="$REF"
53-
else
54-
# Fallback for non-tag manual runs
55-
VER="manual-${{ github.run_number }}"
56-
fi
57-
echo "version=$VER" >> $GITHUB_OUTPUT
58-
echo "Resolved version: $VER"
59-
60-
- name: Set up Python
61-
uses: actions/setup-python@v5
62-
with:
63-
python-version: '3.11'
64-
65-
- name: Install dependencies
66-
run: |
67-
python -m pip install --upgrade pip
68-
pip install build flake8
69-
70-
- name: Check for syntax errors
71-
run: |
72-
flake8 ./deeplc --count --select=E9,F63,F7,F82 --show-source --statistics
15+
- uses: actions/checkout@v6
7316

74-
- name: Build package
75-
run: |
76-
python -m build . --sdist --wheel
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version-file: "pyproject.toml"
7720

78-
- name: Publish to PyPI
79-
uses: pypa/gh-action-pypi-publish@release/v1
80-
with:
81-
skip-existing: true
21+
- uses: astral-sh/setup-uv@v7
22+
with:
23+
enable-cache: true
8224

83-
- name: Upload compiled wheels
84-
uses: actions/upload-artifact@v4
85-
with:
86-
name: python-wheels
87-
path: dist/*.whl
25+
- name: Build
26+
run: uv build --no-sources
8827

89-
windows-installer:
90-
runs-on: windows-latest
91-
needs: python-package
92-
steps:
93-
- uses: actions/checkout@v4
94-
with:
95-
# Match the same ref used for building the Python package
96-
ref: ${{ needs.python-package.outputs.ref || github.ref }}
97-
# If you want to avoid recomputing the ref/version here, you can
98-
# alternatively repeat the "Select ref" + "Derive version" steps as above
99-
- uses: actions/setup-python@v5
100-
with:
101-
python-version: '3.11'
102-
- name: Install dependencies
103-
run: |
104-
python -m pip install --upgrade pip
105-
pip install .[gui] pyinstaller
106-
- name: Install Inno Setup
107-
uses: crazy-max/ghaction-chocolatey@v3
108-
with:
109-
args: install innosetup -y --allow-unofficial --force
110-
- name: Run pyinstaller
111-
run: pyinstaller ./deeplc_pyinstaller.spec --clean --noconfirm
112-
- name: Test built DeepLC exe
113-
run: dist/deeplc/deeplc.exe --ignore-gooey --help
114-
- name: Derive version (Windows)
115-
id: version
116-
shell: bash
117-
run: |
118-
REF="${{ github.event.inputs.ref }}"
119-
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
120-
VER="${GITHUB_REF#refs/tags/}"
121-
elif [[ "$REF" == refs/tags/v* ]]; then
122-
VER="${REF#refs/tags/}"
123-
elif [[ "$REF" == v* ]]; then
124-
VER="$REF"
125-
else
126-
VER="manual-${{ github.run_number }}"
127-
fi
128-
echo "version=$VER" >> $GITHUB_OUTPUT
129-
echo "Resolved version: $VER"
130-
- name: Run Inno Setup
131-
run: ISCC.exe ./deeplc_innosetup.iss /DAppVersion=${{ steps.version.outputs.version }}
132-
- name: Upload installer
133-
uses: actions/upload-artifact@v4
134-
with:
135-
name: windows-installer
136-
path: dist/*.exe
28+
- name: Upload dists
29+
uses: actions/upload-artifact@v7
30+
with:
31+
name: python-package-distributions
32+
path: dist/
33+
if-no-files-found: error
13734

138-
git-release:
35+
publish-python-package:
36+
needs: build-python-package
13937
runs-on: ubuntu-latest
140-
needs: [python-package, windows-installer]
141-
# Only create a GitHub Release when the ref is a v* tag (either push or manual)
142-
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.event.inputs.ref, 'v')
143-
steps:
144-
- uses: actions/checkout@v4
145-
146-
- name: Resolve version/tag
147-
id: version
148-
shell: bash
149-
run: |
150-
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
151-
VER="${GITHUB_REF#refs/tags/}"
152-
elif [[ "${{ github.event.inputs.ref }}" == v* ]]; then
153-
VER="${{ github.event.inputs.ref }}"
154-
else
155-
echo "This job should only run for v* tags."
156-
exit 1
157-
fi
158-
echo "version=$VER" >> $GITHUB_OUTPUT
159-
echo "Resolved version: $VER"
38+
permissions:
39+
id-token: write
16040

161-
- name: Download artifacts
162-
uses: actions/download-artifact@v4
163-
with:
164-
path: dist
165-
166-
- name: Create GitHub Release
167-
# The docker action infers the tag from GITHUB_REF; set it explicitly for manual runs.
168-
uses: docker://antonyurchenko/git-release:v6
169-
env:
170-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171-
DRAFT_RELEASE: "false"
172-
PRE_RELEASE: "false"
173-
CHANGELOG_FILE: "CHANGELOG.md"
174-
# Provide a synthetic tag ref for manual runs with input v*
175-
GITHUB_REF: refs/tags/${{ steps.version.outputs.version }}
176-
with:
177-
args: |
178-
dist/**/*.exe
179-
dist/**/*.whl
180-
181-
build-streamlit-image:
182-
runs-on: ubuntu-latest
183-
needs: python-package
18441
steps:
185-
- uses: actions/checkout@v4
186-
- id: latest_release
187-
uses: pozetroninc/github-action-get-latest-release@master
188-
with:
189-
owner: compomics
190-
repo: DeepLC
191-
- name: Login to GitHub Container Registry
192-
uses: docker/login-action@v3
193-
with:
194-
registry: ghcr.io
195-
username: ${{ github.repository_owner }}
196-
password: ${{ secrets.GITHUB_TOKEN }}
197-
- name: Build and push to ghcr.io
198-
uses: docker/build-push-action@v5
199-
with:
200-
context: streamlit
201-
push: true
202-
tags: |
203-
ghcr.io/compomics/deeplc-streamlit:${{ steps.latest_release.outputs.release }}
204-
ghcr.io/compomics/deeplc-streamlit:latest
42+
- name: Download dists
43+
uses: actions/download-artifact@v8
44+
with:
45+
name: python-package-distributions
46+
path: dist/
47+
48+
- name: Publish to PyPI
49+
uses: pypa/gh-action-pypi-publish@release/v1
50+
51+
# windows-installer:
52+
# runs-on: windows-latest
53+
# needs: python-package
54+
# steps:
55+
# - uses: actions/checkout@v6
56+
# - uses: actions/setup-python@v5
57+
# with:
58+
# python-version: '3.11'
59+
# - name: Install dependencies
60+
# run: |
61+
# python -m pip install --upgrade pip
62+
# pip install .[gui] pyinstaller
63+
# - name: Install Inno Setup
64+
# uses: crazy-max/ghaction-chocolatey@v3
65+
# with:
66+
# args: install innosetup -y --allow-unofficial --force
67+
# - name: Run pyinstaller
68+
# run: pyinstaller ./deeplc_pyinstaller.spec --clean --noconfirm
69+
# - name: Test built DeepLC exe
70+
# run: dist/deeplc/deeplc.exe --ignore-gooey --help
71+
# - name: Run Inno Setup
72+
# run: ISCC.exe ./deeplc_innosetup.iss /DAppVersion=${{ github.ref_name }}
73+
# - name: Upload installer
74+
# uses: actions/upload-artifact@v4
75+
# with:
76+
# name: windows-installer
77+
# path: dist/*.exe
78+
# - name: Upload installer to release
79+
# uses: svenstaro/upload-release-action@v2
80+
# with:
81+
# repo_token: ${{ secrets.GITHUB_TOKEN }}
82+
# tag: ${{ github.ref }}
83+
# file_glob: true
84+
# file: dist/*.exe
85+
86+
# build-streamlit-image:
87+
# runs-on: ubuntu-latest
88+
# needs: publish-python-package
89+
90+
# steps:
91+
# - uses: actions/checkout@v6
92+
93+
# - name: Login to GitHub Container Registry
94+
# uses: docker/login-action@v3
95+
# with:
96+
# registry: ghcr.io
97+
# username: ${{ github.repository_owner }}
98+
# password: ${{ secrets.GITHUB_TOKEN }}
99+
100+
# - name: Build and push to ghcr.io
101+
# uses: docker/build-push-action@v5
102+
# with:
103+
# context: streamlit
104+
# push: true
105+
# tags: |
106+
# ghcr.io/compomics/deeplc-streamlit:${{ github.ref }}
107+
# ghcr.io/compomics/deeplc-streamlit:latest

.github/workflows/test.yml

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python package test
1+
name: Test
22

33
on:
44
push:
@@ -7,29 +7,50 @@ on:
77
pull_request:
88
workflow_dispatch:
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
11-
test:
14+
lint-python-package:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- name: Lint
20+
uses: astral-sh/ruff-action@v3
21+
with:
22+
src: "deeplc"
23+
24+
- name: Check formatting
25+
uses: astral-sh/ruff-action@v3
26+
with:
27+
args: "format --check --diff deeplc"
28+
src: "deeplc"
29+
30+
test-python-package:
31+
needs: lint-python-package
32+
runs-on: ubuntu-latest
1233
strategy:
34+
fail-fast: false
1335
matrix:
14-
system: [["3.11", "ubuntu-latest"], ["3.12", "ubuntu-latest"]]
15-
runs-on: ${{ matrix.system[1] }}
36+
python-version: ["3.11", "3.12", "3.13", "3.14"]
37+
1638
steps:
17-
- uses: actions/checkout@v4
18-
- name: Set up Python ${{ matrix.system[0] }}
19-
uses: actions/setup-python@v5
39+
- uses: actions/checkout@v6
40+
41+
- uses: actions/setup-python@v6
42+
with:
43+
python-version: ${{ matrix.python-version }}
44+
45+
- uses: astral-sh/setup-uv@v7
2046
with:
21-
python-version: ${{ matrix.system[0] }}
22-
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install flake8 pytest
26-
pip install --editable .[test]
27-
- name: Lint with flake8
28-
run: |
29-
# stop the build if there are Python syntax errors or undefined names
30-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
31-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
32-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
33-
- name: Test with pytest
34-
run: |
35-
pytest
47+
enable-cache: true
48+
49+
- name: Install the project
50+
run: uv sync --all-extras --dev
51+
52+
- name: Run tests
53+
run: uv run pytest
54+
55+
- name: Prune cache
56+
run: uv cache prune --ci

0 commit comments

Comments
 (0)