Skip to content

Commit 13d3e6b

Browse files
chore: add CI (#2)
* chore: add CI Signed-off-by: Michele Dolfi <[email protected]> * build single-thread Signed-off-by: Michele Dolfi <[email protected]> * add ldap deps Signed-off-by: Michele Dolfi <[email protected]> * reduce number of CI jobs Signed-off-by: Michele Dolfi <[email protected]> * make build.py raise on errors Signed-off-by: Michele Dolfi <[email protected]> * remove ldap deps Signed-off-by: Michele Dolfi <[email protected]> * improve gitignore Signed-off-by: Michele Dolfi <[email protected]> * more exclude Signed-off-by: Michele Dolfi <[email protected]> * fix: unit-tests (#3) Signed-off-by: Peter Staar <[email protected]> Signed-off-by: Michele Dolfi <[email protected]> * add lib64 as deps Signed-off-by: Michele Dolfi <[email protected]> * fix LDFLAG Signed-off-by: Michele Dolfi <[email protected]> * detect lib vs lib64 Signed-off-by: Michele Dolfi <[email protected]> * set libdir Signed-off-by: Michele Dolfi <[email protected]> * enable PIC Signed-off-by: Michele Dolfi <[email protected]> * propagate target arch Signed-off-by: Michele Dolfi <[email protected]> * fPIC for jpeg Signed-off-by: Michele Dolfi <[email protected]> * force usage of /lib Signed-off-by: Michele Dolfi <[email protected]> * abs libdir Signed-off-by: Michele Dolfi <[email protected]> * use qpdf v11 with cmake build Signed-off-by: Michele Dolfi <[email protected]> * fix mac cross compilation Signed-off-by: Michele Dolfi <[email protected]> * force PIC by enabling shared lib Signed-off-by: Michele Dolfi <[email protected]> * print build and configure Signed-off-by: Michele Dolfi <[email protected]> * force -fPIC Signed-off-by: Michele Dolfi <[email protected]> * more hints Signed-off-by: Michele Dolfi <[email protected]> * add -fPIC to C targets Signed-off-by: Michele Dolfi <[email protected]> * cleanup Signed-off-by: Michele Dolfi <[email protected]> * cleanup Signed-off-by: Michele Dolfi <[email protected]> --------- Signed-off-by: Michele Dolfi <[email protected]> Signed-off-by: Peter Staar <[email protected]> Co-authored-by: Peter W. J. Staar <[email protected]>
1 parent fa7bef7 commit 13d3e6b

21 files changed

+1711
-99
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: 'Set up dependencies'
2+
description: 'Set up the dependencies'
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- name: Install dependencies
7+
run: sudo apt-get install libldap-common
8+
shell: bash
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Set up Poetry and install'
2+
description: 'Set up a specific version of Poetry and install dependencies using caching.'
3+
inputs:
4+
python-version:
5+
description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax."
6+
default: '3.11'
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- name: Install poetry
11+
run: pipx install poetry==1.8.3
12+
shell: bash
13+
- uses: actions/setup-python@v4
14+
with:
15+
python-version: ${{ inputs.python-version }}
16+
cache: 'poetry'
17+
- name: Install dependencies
18+
run: poetry install --all-extras
19+
shell: bash

.github/scripts/release.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
set -e # trigger failure on error - do not remove!
4+
set -x # display command on output
5+
6+
if [ -z "${TARGET_VERSION}" ]; then
7+
>&2 echo "No TARGET_VERSION specified"
8+
exit 1
9+
fi
10+
CHGLOG_FILE="${CHGLOG_FILE:-CHANGELOG.md}"
11+
12+
# update package version
13+
poetry version "${TARGET_VERSION}"
14+
15+
# collect release notes
16+
REL_NOTES=$(mktemp)
17+
poetry run semantic-release changelog --unreleased >> "${REL_NOTES}"
18+
19+
# update changelog
20+
TMP_CHGLOG=$(mktemp)
21+
TARGET_TAG_NAME="v${TARGET_VERSION}"
22+
RELEASE_URL="$(gh repo view --json url -q ".url")/releases/tag/${TARGET_TAG_NAME}"
23+
printf "## [${TARGET_TAG_NAME}](${RELEASE_URL}) - $(date -Idate)\n\n" >> "${TMP_CHGLOG}"
24+
cat "${REL_NOTES}" >> "${TMP_CHGLOG}"
25+
if [ -f "${CHGLOG_FILE}" ]; then
26+
printf "\n" | cat - "${CHGLOG_FILE}" >> "${TMP_CHGLOG}"
27+
fi
28+
mv "${TMP_CHGLOG}" "${CHGLOG_FILE}"
29+
30+
# push changes
31+
git config --global user.name 'github-actions[bot]'
32+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
33+
git add pyproject.toml "${CHGLOG_FILE}"
34+
COMMIT_MSG="chore: bump version to ${TARGET_VERSION} [skip ci]"
35+
git commit -m "${COMMIT_MSG}"
36+
git push origin main
37+
38+
# create GitHub release (incl. Git tag)
39+
gh release create "${TARGET_TAG_NAME}" -F "${REL_NOTES}"

.github/workflows/cd.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "Run CD"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
# disable keyring (https://github.com/actions/runner-images/issues/6185):
10+
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
11+
12+
jobs:
13+
code-checks:
14+
uses: ./.github/workflows/checks.yml
15+
pre-release-check:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
TARGET_TAG_V: ${{ steps.version_check.outputs.TRGT_VERSION }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0 # for fetching tags, required for semantic-release
23+
- uses: ./.github/actions/setup-poetry
24+
- name: Check version of potential release
25+
id: version_check
26+
run: |
27+
TRGT_VERSION=$(poetry run semantic-release print-version)
28+
echo "TRGT_VERSION=${TRGT_VERSION}" >> $GITHUB_OUTPUT
29+
echo "${TRGT_VERSION}"
30+
- name: Check notes of potential release
31+
run: poetry run semantic-release changelog --unreleased
32+
release:
33+
needs: [code-checks, pre-release-check]
34+
if: needs.pre-release-check.outputs.TARGET_TAG_V != ''
35+
environment: auto-release
36+
runs-on: ubuntu-latest
37+
concurrency: release
38+
steps:
39+
- uses: actions/checkout@v4
40+
with:
41+
token: ${{ secrets.GH_PAT }}
42+
fetch-depth: 0 # for fetching tags, required for semantic-release
43+
- uses: ./.github/actions/setup-poetry
44+
- name: Run release script
45+
env:
46+
GH_TOKEN: ${{ secrets.GH_PAT }}
47+
TARGET_VERSION: ${{ needs.pre-release-check.outputs.TARGET_TAG_V }}
48+
CHGLOG_FILE: CHANGELOG.md
49+
run: ./.github/scripts/release.sh
50+
shell: bash

.github/workflows/checks.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
run-checks:
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
python-version: ['3.9', '3.10', '3.11', '3.12']
10+
steps:
11+
- uses: actions/checkout@v4
12+
# - name: Install dependencies [linux]
13+
# run: sudo apt-get install -y libldap-common
14+
# shell: bash
15+
- uses: ./.github/actions/setup-poetry
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
- name: Run styling check
19+
run: poetry run pre-commit run --all-files
20+
- name: Install with poetry
21+
run: poetry install
22+
- name: Testing
23+
run: |
24+
poetry run pytest -v tests
25+
- name: Build with poetry
26+
run: poetry build
27+

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Run CI"
2+
3+
on:
4+
schedule: # will run only on the default branch (main)
5+
# Nightly build at 3:42 A.M.
6+
- cron: "42 3 */1 * *"
7+
pull_request:
8+
types: [opened, reopened]
9+
push:
10+
branches:
11+
- "**"
12+
- "!main"
13+
- "!gh-pages"
14+
15+
env:
16+
# disable keyring (https://github.com/actions/runner-images/issues/6185):
17+
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
18+
BUILD_TYPE: Release
19+
20+
jobs:
21+
code-checks:
22+
uses: ./.github/workflows/checks.yml
23+
build-wheels:
24+
uses: ./.github/workflows/wheels.yml
25+

.github/workflows/release.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "Build and publish package"
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
# disable keyring (https://github.com/actions/runner-images/issues/6185):
12+
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
13+
14+
jobs:
15+
build-and-publish:
16+
uses: ./.github/workflows/wheels.yml

.github/workflows/wheels.yml

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
build_wheels:
6+
name: Build wheel for py${{ matrix.python-version }} ${{ matrix.os.platform_id }} ${{ matrix.os.macos_version }}
7+
runs-on: ${{ matrix.os.name }}
8+
9+
strategy:
10+
# Ensure that a wheel builder finishes even if another fails
11+
# list of github vm: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
12+
fail-fast: false
13+
matrix:
14+
python-version: ["3.9", "3.10", "3.11", "3.12"]
15+
16+
os:
17+
- name: "ubuntu-latest"
18+
platform: "linux"
19+
platform_id: "manylinux_x86_64"
20+
21+
- name: "macos-13"
22+
platform: "macos"
23+
macos_version: "13"
24+
platform_id: "macosx_x86_64"
25+
26+
- name: "macos-13"
27+
platform: "macos"
28+
macos_version: "13"
29+
platform_id: "macosx_arm64"
30+
31+
- name: "macos-14"
32+
platform: "macos"
33+
macos_version: "14"
34+
platform_id: "macosx_x86_64"
35+
36+
- name: "macos-14"
37+
platform: "macos"
38+
macos_version: "14"
39+
platform_id: "macosx_arm64"
40+
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
45+
- name: Setup Python
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: ${{ matrix.python-version }}
49+
50+
# - name: Install dependencies [linux]
51+
# if: matrix.os.platform == 'linux'
52+
# run: sudo apt-get install -y libldap-common
53+
# shell: bash
54+
55+
- name: Install poetry
56+
run: pipx install poetry==1.8.3 --python $(which python3)
57+
shell: bash
58+
59+
- name: Test poetry
60+
run: |
61+
poetry run python --version
62+
63+
- name: Convert python version to cpXYZ
64+
run: |
65+
version=${{ matrix.python-version }}
66+
cp_version="cp${version//.}"
67+
echo "python_cp_version=$cp_version" >> $GITHUB_ENV
68+
69+
- name: Build wheels [macos-x86_64]
70+
if: ${{matrix.os.platform_id == 'macosx_x86_64'}}
71+
env:
72+
CIBW_BUILD: ${{ env.python_cp_version }}-${{ matrix.os.platform_id }}
73+
CIBW_ARCHS: x86_64
74+
CIBW_ARCHS_MACOS: x86_64
75+
CIBW_PLATFORM: macos
76+
CIBW_SKIP: "pp* *-musllinux_* *_i686* *_s390* *arm64*"
77+
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
78+
CIBW_BUILD_VERBOSITY: 3
79+
CMAKE_OSX_ARCHITECTURES: x86_64
80+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # do not run delocate-wheel before the re-tag
81+
CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.macos_version }}.0"
82+
ARCHFLAGS: -arch x86_64
83+
run: |
84+
echo "Building wheel ${CIBW_BUILD}"
85+
poetry run python --version
86+
poetry install
87+
cat ./pyproject.toml
88+
poetry run python -m cibuildwheel --output-dir wheelhouse
89+
echo "step 1"
90+
ls -l wheelhouse
91+
poetry run wheel tags --platform-tag macosx_${{ matrix.os.macos_version }}_0_x86_64 ./wheelhouse/*.whl
92+
rm -f ./wheelhouse/*arm64.whl
93+
echo "step 2"
94+
ls -l wheelhouse
95+
poetry run delocate-wheel --require-archs x86_64 -v ./wheelhouse/*.whl
96+
echo "step 3"
97+
ls -l wheelhouse
98+
poetry run python -m zipfile --list wheelhouse/*.whl
99+
mkdir ./dist
100+
cp wheelhouse/*.whl ./dist/
101+
102+
# there is an error with the tagging of wheels for macosx-arm64
103+
# see note: https://cibuildwheel.readthedocs.io/en/stable/faq/
104+
# see here: https://gist.github.com/anderssonjohan/49f07e33fc5cb2420515a8ac76dc0c95#file-build-pendulum-wheels-yml-L39-L53
105+
- name: Build wheels [macos-arm64]
106+
if: ${{matrix.os.platform_id == 'macosx_arm64'}}
107+
env:
108+
CIBW_BUILD: ${{ env.python_cp_version }}-${{ matrix.os.platform_id }}
109+
CIBW_ARCHS: arm64
110+
CIBW_ARCHS_MACOS: arm64
111+
CIBW_PLATFORM: macos
112+
CIBW_SKIP: "pp* *-musllinux_* *_i686* *x86_64* *_s390*"
113+
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
114+
CIBW_BUILD_VERBOSITY: 3
115+
CMAKE_OSX_ARCHITECTURES: arm64
116+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # do not run delocate-wheel before the re-tag
117+
CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.macos_version }}.0"
118+
ARCHFLAGS: -arch arm64
119+
run: |
120+
echo "Building wheel ${CIBW_BUILD}"
121+
poetry run python --version
122+
poetry install
123+
cat ./pyproject.toml
124+
poetry run python -m cibuildwheel --output-dir wheelhouse
125+
echo "step 1"
126+
ls -l wheelhouse
127+
poetry run wheel tags --platform-tag macosx_${{ matrix.os.macos_version }}_0_arm64 ./wheelhouse/*.whl
128+
rm -f ./wheelhouse/*x86_64.whl
129+
echo "step 2"
130+
ls -l wheelhouse
131+
poetry run delocate-wheel --require-archs arm64 -v ./wheelhouse/*.whl
132+
echo "step 3"
133+
ls -l wheelhouse
134+
poetry run python -m zipfile --list wheelhouse/*.whl
135+
mkdir ./dist
136+
cp wheelhouse/*.whl ./dist/
137+
138+
- name: publish wheels (dry run) [macos]
139+
if: matrix.os.platform == 'macos'
140+
run: |
141+
ls -l ./
142+
ls -l ./dist
143+
poetry publish --dry-run --no-interaction -vvv --username=__token__ --password=${{ secrets.PYPI_TOKEN }}
144+
145+
- name: publish wheels (on publishing) [macos]
146+
if: ${{ matrix.os.platform == 'macos' && startsWith(github.ref, 'refs/tags/') }}
147+
run: |
148+
ls -l ./
149+
ls -l ./dist
150+
poetry publish --no-interaction -vvv --username=__token__ --password=${{ secrets.PYPI_TOKEN }}
151+
152+
- name: Build wheels [linux]
153+
if: matrix.os.name == 'ubuntu-latest'
154+
env:
155+
CIBW_BUILD: ${{ env.python_cp_version }}-${{ matrix.os.platform_id }}
156+
CIBW_ARCHS: x86_64
157+
CIBW_PLATFORM: linux
158+
CIBW_SKIP: "pp* *musllinux_* *_i686* *_s390*"
159+
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
160+
CIBW_BUILD_VERBOSITY: 3
161+
run: |
162+
echo "Building wheel ${CIBW_BUILD}"
163+
poetry run python --version
164+
poetry add cibuildwheel
165+
# poetry install
166+
cat ./pyproject.toml
167+
poetry run python -m cibuildwheel --output-dir ./wheelhouse
168+
ls -l ./wheelhouse
169+
poetry run python -m zipfile --list ./wheelhouse/*.whl
170+
mkdir ./dist
171+
cp wheelhouse/*.whl ./dist/
172+
173+
- name: publish wheels (dry run) [linux]
174+
if: matrix.os.platform == 'linux'
175+
run: |
176+
ls -l ./
177+
ls -l ./dist
178+
poetry publish --dry-run --no-interaction -vvv --username=__token__ --password=${{ secrets.PYPI_TOKEN }}
179+
180+
- name: publish wheels (on publishing) [linux]
181+
if: ${{ matrix.os.platform == 'linux' && startsWith(github.ref, 'refs/tags/') }}
182+
run: |
183+
ls -l ./
184+
ls -l ./dist
185+
poetry publish --no-interaction -vvv --username=__token__ --password=${{ secrets.PYPI_TOKEN }}
186+

0 commit comments

Comments
 (0)