Skip to content

Commit ef83e9f

Browse files
committed
refine CICD
1 parent 615c527 commit ef83e9f

File tree

3 files changed

+54
-63
lines changed

3 files changed

+54
-63
lines changed

.github/workflows/cd.yaml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
name: CD
22

33
on:
4-
push:
5-
tags:
6-
- '*'
4+
release:
5+
types: [published]
76

87
jobs:
9-
build:
10-
name: Build distribution
8+
release-build:
119
runs-on: ubuntu-latest
1210

1311
steps:
14-
- uses: actions/checkout@v4
15-
- name: Set up Python
16-
uses: actions/setup-python@v4
17-
with:
18-
python-version: "3.10"
19-
- name: Install pypa/build
20-
run: >-
21-
python3 -m
22-
pip install
23-
build
24-
--user
25-
- name: Build a binary wheel and a source tarball
26-
run: python3 -m build
27-
- name: Store the distribution packages
28-
uses: actions/upload-artifact@v3
29-
with:
30-
name: python-package-distributions
31-
path: dist/
32-
33-
publish-to-pypi:
34-
name: >-
35-
Publish Python distribution 📦 to PyPI
36-
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
37-
needs:
38-
- build
12+
- uses: actions/checkout@v4
13+
14+
- uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.x"
17+
18+
- name: Build release distributions
19+
run: |
20+
# NOTE: put your own distribution build steps here.
21+
python -m pip install build
22+
python -m build
23+
24+
- name: Upload distributions
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: release-dists
28+
path: dist/
29+
30+
pypi-publish:
3931
runs-on: ubuntu-latest
32+
33+
needs:
34+
- release-build
35+
36+
permissions:
37+
# IMPORTANT: this permission is mandatory for trusted publishing
38+
id-token: write
39+
40+
# Dedicated environments with protections for publishing are strongly recommended.
4041
environment:
4142
name: pypi
4243
url: https://pypi.org/p/wpodnet-pytorch
43-
permissions:
44-
id-token: write # IMPORTANT: mandatory for trusted publishing
4544

4645
steps:
47-
- name: Download all the dists
48-
uses: actions/download-artifact@v3
49-
with:
50-
name: python-package-distributions
51-
path: dist/
52-
- name: Publish distribution to PyPI
53-
uses: pypa/gh-action-pypi-publish@release/v1
46+
- name: Retrieve release distributions
47+
uses: actions/download-artifact@v4
48+
with:
49+
name: release-dists
50+
path: dist/
51+
52+
- name: Publish release distributions to PyPI
53+
uses: pypa/gh-action-pypi-publish@6f7e8d9c0b1a2c3d4e5f6a7b8c9d0e1f2a3b4c5d

.github/workflows/ci.yaml

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,28 @@
11
name: CI
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v3
10-
- name: Set up Python
11-
uses: actions/setup-python@v4
12-
with:
13-
python-version: "3.10"
14-
- name: Install dependencies
15-
run: |
16-
pip install --upgrade pip
17-
pip install -r requirements.txt
18-
- name: Lint with Ruff
19-
run: |
20-
pip install ruff
21-
ruff -- --format=github .
22-
continue-on-error: true
9+
- uses: actions/checkout@v4
10+
- uses: astral-sh/ruff-action@v3
2311
test:
2412
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
2516
steps:
26-
- uses: actions/checkout@v3
27-
- name: Set up Python
28-
uses: actions/setup-python@v4
17+
- uses: actions/checkout@v4
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v5
2920
with:
30-
python-version: "3.10"
21+
python-version: ${{ matrix.python-version }}
3122
- name: Install dependencies
3223
run: |
33-
pip install --upgrade pip
34-
pip install -r requirements.txt
24+
python -m pip install --upgrade pip
25+
pip install -e .[test]
3526
- name: Test with pytest
3627
run: |
37-
pip install pytest pytest-cov pytest-mock
38-
python -m pytest --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html
28+
pytest --junitxml=junit/test-results.xml --cov --cov-report=xml --cov-report=html

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ dependencies = ["numpy", "Pillow", "torch", "torchvision"]
4747
packages.find.include = ["wpodnet"]
4848

4949
[tool.setuptools_scm]
50+
fallback_version = "0.1.0"
5051

5152
[project.optional-dependencies]
52-
test = ["pytest", "pooch"]
53+
test = ["pytest", "pytest-cov", "pooch"]
5354

5455
[project.urls]
5556
Source = "https://github.com/Pandede/WPODNet-Pytorch"

0 commit comments

Comments
 (0)