Skip to content

Commit 6703b9a

Browse files
Merge pull request #1 from ThomasWollmann/tw-cicd
add test to ci
2 parents 64dd819 + c15ca29 commit 6703b9a

3 files changed

Lines changed: 148 additions & 0 deletions

File tree

.github/workflows/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "pip"
9+
directory: "/"
10+
schedule:
11+
interval: "monthly"
12+
reviewers:
13+
- "thomaswollmann"
14+
15+
- package-ecosystem: "github-actions"
16+
directory: "/"
17+
schedule:
18+
interval: "weekly"

.github/workflows/release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Python 3.10
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: "3.10"
20+
21+
- name: Install Poetry
22+
run: |
23+
curl -sSL https://install.python-poetry.org | python - -y
24+
- name: Update PATH
25+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
26+
27+
- name: Build project for distribution
28+
run: poetry build
29+
30+
- name: Check Version
31+
id: check-version
32+
run: |
33+
[[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT
34+
35+
- name: Create Release
36+
uses: ncipollo/release-action@v1
37+
with:
38+
artifacts: "dist/*"
39+
token: ${{ secrets.GITHUB_TOKEN }}
40+
draft: false
41+
prerelease: steps.check-version.outputs.prerelease == 'true'
42+
43+
- name: Publish to PyPI
44+
env:
45+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI }}
46+
run: poetry publish

.github/workflows/test.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches:
8+
- '**'
9+
10+
concurrency:
11+
group: tests-${{ github.head_ref || github.ref }}
12+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
13+
14+
jobs:
15+
test:
16+
name: ${{ matrix.os }} / ${{ matrix.python-version }}
17+
runs-on: ${{ matrix.image }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [Ubuntu, macOS, Windows]
22+
python-version: ["3.9", "3.10", "3.11"]
23+
include:
24+
- os: Ubuntu
25+
image: ubuntu-22.04
26+
- os: Windows
27+
image: windows-2022
28+
- os: macOS
29+
image: macos-12
30+
defaults:
31+
run:
32+
shell: bash
33+
steps:
34+
- uses: actions/checkout@v3
35+
36+
- uses: actions/setup-python@v4
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
40+
- name: Get full Python version
41+
id: full-python-version
42+
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
43+
44+
- name: Bootstrap poetry
45+
run: |
46+
curl -sSL https://install.python-poetry.org | python - -y
47+
48+
- name: Update PATH
49+
if: ${{ matrix.os != 'Windows' }}
50+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
51+
52+
- name: Update Path for Windows
53+
if: ${{ matrix.os == 'Windows' }}
54+
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
55+
56+
- name: Configure poetry
57+
run: poetry config virtualenvs.in-project true
58+
59+
- name: Set up cache
60+
uses: actions/cache@v3
61+
id: cache
62+
with:
63+
path: .venv
64+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
65+
66+
- name: Ensure cache is healthy
67+
if: steps.cache.outputs.cache-hit == 'true'
68+
run: |
69+
# `timeout` is not available on macOS, so we define a custom function.
70+
[ "$(command -v timeout)" ] || function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
71+
# Using `timeout` is a safeguard against the Poetry command hanging for some reason.
72+
timeout 10s poetry run pip --version || rm -rf .venv
73+
74+
- name: Check lock file
75+
run: poetry lock --check
76+
77+
- name: Install dependencies
78+
run: poetry install --with github-actions
79+
80+
- name: Run pre-commit hooks
81+
uses: pre-commit/action@v3.0.0
82+
83+
- name: Run tests
84+
run: poetry run pytest -v

0 commit comments

Comments
 (0)