Skip to content

Commit 3d134a9

Browse files
author
Henry Webel
authored
Cicd (#4)
* 🎨 update actions and triggers - master is now main - also on push to any branch * 🎨 format __init__ * ✨ extend workflow - add build artifacts - optionally push to Test PyPI - schedule automatic runs (weekly) * 🎨 combine both workflow files
1 parent bc8e59d commit 3d134a9

File tree

4 files changed

+130
-53
lines changed

4 files changed

+130
-53
lines changed

.github/workflows/black.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/cicd.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python application
5+
6+
on:
7+
push:
8+
pull_request:
9+
branches: [ "main" ]
10+
schedule:
11+
- cron: '0 2 * * 3'
12+
13+
permissions:
14+
contents: read
15+
16+
17+
jobs:
18+
format:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: psf/black@stable
23+
lint:
24+
name: Lint with ruff
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: "3.11"
32+
- name: Install ruff
33+
run: |
34+
pip install ruff
35+
- name: Lint with ruff
36+
run: |
37+
# stop the build if there are Python syntax errors or undefined names
38+
ruff check .
39+
test:
40+
name: Test
41+
runs-on: ubuntu-latest
42+
strategy:
43+
matrix:
44+
python-version: ["3.11", "3.12"]
45+
steps:
46+
- uses: actions/checkout@v4
47+
- name: Set up Python ${{ matrix.python-version }}
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
cache: 'pip' # caching pip dependencies
52+
cache-dependency-path: '**/pyproject.toml'
53+
- name: Install dependencies
54+
run: |
55+
python -m pip install --upgrade pip
56+
pip install pytest
57+
pip install -e .
58+
- name: Run tests
59+
run: python -m pytest tests
60+
61+
build_source_dist:
62+
name: Build source distribution
63+
if: startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/tags')
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@v4
67+
68+
- uses: actions/setup-python@v5
69+
with:
70+
python-version: "3.10"
71+
72+
- name: Install build
73+
run: python -m pip install build
74+
75+
- name: Run build
76+
run: python -m build --sdist
77+
78+
- uses: actions/upload-artifact@v4
79+
with:
80+
path: ./dist/*.tar.gz
81+
# Needed in case of building packages with external binaries (e.g. Cython, RUst-extensions, etc.)
82+
# build_wheels:
83+
# name: Build wheels on ${{ matrix.os }}
84+
# if: startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/tags')
85+
# runs-on: ${{ matrix.os }}
86+
# strategy:
87+
# matrix:
88+
# os: [ubuntu-20.04, windows-2019, macOS-10.15]
89+
90+
# steps:
91+
# - uses: actions/checkout@v4
92+
93+
# - uses: actions/setup-python@v5
94+
# with:
95+
# python-version: "3.10"
96+
97+
# - name: Install cibuildwheel
98+
# run: python -m pip install cibuildwheel==2.3.1
99+
100+
# - name: Build wheels
101+
# run: python -m cibuildwheel --output-dir wheels
102+
103+
# - uses: actions/upload-artifact@v4
104+
# with:
105+
# path: ./wheels/*.whl
106+
107+
publish:
108+
name: Publish package
109+
if: startsWith(github.ref, 'refs/tags')
110+
needs:
111+
- format
112+
- lint
113+
- test
114+
- build_source_dist
115+
# - build_wheels
116+
runs-on: ubuntu-latest
117+
118+
steps:
119+
- uses: actions/download-artifact@v4
120+
with:
121+
name: artifact
122+
path: ./dist
123+
124+
- uses: pypa/gh-action-pypi-publish@release/v1
125+
with:
126+
# remove repository key to set the default to pypi (not test.pypi.org)
127+
repository-url: https://test.pypi.org/legacy/
128+
user: __token__
129+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/unittest.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/mockup/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44

55
from importlib import metadata
6+
67
__version__ = metadata.version("rasmussenlab-mockup")
78

89
from .mockup import add_one, Circle

0 commit comments

Comments
 (0)