Skip to content

Commit a7b356f

Browse files
CICD through GitHub Actions (#31)
* Publish coverage to codacy * Remove distribution files * Publish to PyPI, TestPyPI * Bump version to 2024.12.1
1 parent c3a4776 commit a7b356f

File tree

6 files changed

+117
-4
lines changed

6 files changed

+117
-4
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Publish to PyPI and TestPyPI
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: Build Distribution Package
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Set up Python 3.12
12+
uses: actions/setup-python@v2
13+
with:
14+
python-version: 3.12
15+
- name: Install dependencies and build package
16+
run: |
17+
python3 -m pip install --upgrade pip
18+
python3 -m pip install poetry
19+
python3 -m poetry install
20+
python3 -m poetry build
21+
- name: Store the distribution packages
22+
uses: actions/upload-artifact@v4
23+
with:
24+
name: python-distribution-packages
25+
path: dist/*
26+
publish-testpypi:
27+
name: Publish to TestPyPI
28+
needs: build
29+
runs-on: ubuntu-latest
30+
environment:
31+
name: testpypi
32+
url: https://test.pypi.org/p/torchvinecopulib/
33+
permissions:
34+
id-token: write
35+
# contents: write
36+
37+
steps:
38+
- name: Download the distribution packages
39+
uses: actions/download-artifact@v4
40+
with:
41+
name: python-distribution-packages
42+
path: dist/
43+
- name: Publish distribution
44+
uses: pypa/gh-action-pypi-publish@release/v1
45+
with:
46+
verbose: true
47+
skip-existing: true
48+
repository-url: https://test.pypi.org/legacy/
49+
50+
publish-pypi:
51+
name: Publish to PyPI
52+
if: startsWith(github.ref, 'refs/tags/')
53+
needs: publish-testpypi
54+
runs-on: ubuntu-latest
55+
environment:
56+
name: pypi
57+
url: https://pypi.org/project/torchvinecopulib/
58+
permissions:
59+
id-token: write
60+
# contents: write
61+
62+
steps:
63+
- name: Download the distribution packages
64+
uses: actions/download-artifact@v4
65+
with:
66+
name: python-distribution-packages
67+
path: dist/
68+
- name: Publish distribution
69+
uses: pypa/gh-action-pypi-publish@release/v1
70+
with:
71+
verbose: true
72+
skip-existing: true
73+
74+
github-release:
75+
name: Create GitHub Release
76+
if: startsWith(github.ref, 'refs/tags/')
77+
needs: publish-testpypi
78+
runs-on: ubuntu-latest
79+
permissions:
80+
id-token: write
81+
contents: write
82+
83+
steps:
84+
- name: Download the distribution packages
85+
uses: actions/download-artifact@v4
86+
with:
87+
name: python-distribution-packages
88+
path: dist/
89+
- name: Sign the distribution packages
90+
uses: sigstore/[email protected]
91+
with:
92+
inputs: >-
93+
./dist/*.tar.gz
94+
./dist/*.whl
95+
- name: Github Release
96+
env:
97+
GITHUB_TOKEN: ${{ github.token }}
98+
run: >-
99+
gh release create
100+
'${{ github.ref_name }}'
101+
--repo '${{ github.repository }}'
102+
--notes ""

.github/workflows/python-package.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
pull_request:
1010
branches: ["main"]
1111

12+
workflow_dispatch:
13+
1214
jobs:
1315
build:
1416
runs-on: ${{ matrix.os }}
@@ -29,7 +31,7 @@ jobs:
2931
run: |
3032
python -m pip install --upgrade pip
3133
python -m pip install "pyvinecopulib==0.6.6"
32-
python -m pip install flake8 pytest numpy scipy torch pot matplotlib scikit-learn pandas
34+
python -m pip install flake8 pytest numpy scipy torch pot matplotlib scikit-learn pandas coverage
3335
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3436
- name: Lint with flake8
3537
run: |
@@ -41,4 +43,14 @@ jobs:
4143
run: |
4244
python -c "import sys; print(sys.version)"
4345
python -c "import torch; print(torch.cuda.is_available())"
44-
pytest ./tests --verbose
46+
coverage run -m pytest ./tests
47+
coverage xml
48+
coverage report
49+
coverage html
50+
51+
- name: Upload test coverage to Codacy
52+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' }}
53+
run: |
54+
export CODACY_API_BASE_URL=${{ secrets.CODACY_API_BASE_URL }}
55+
export CODACY_PROJECT_TOKEN=${{ secrets.CODACY_PROJECT_TOKEN }}
56+
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r ./coverage.xml
-55.6 KB
Binary file not shown.
-51.1 KB
Binary file not shown.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
package-mode = true
33
license = "GNU GPLv3"
44
name = "torchvinecopulib"
5-
version = "2024.10.1"
5+
version = "2024.12.1"
66
description = "yet another vine copula library for PyTorch."
77
authors = ["Tuoyuan Cheng <[email protected]>"]
88
maintainers = ["Xiaosheng You <[email protected]>"]

torchvinecopulib/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
"util",
66
"vinecop",
77
]
8-
__version__ = "2024.10.1"

0 commit comments

Comments
 (0)