Refactor all metadata into pyproject.toml #358
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --------------------------- | |
# | |
# Prepare distributions of this project | |
# for various platforms | |
# | |
# --------------------------- | |
name: Packaging | |
on: | |
push: | |
branches: | |
- main | |
- release/** | |
pull_request: | |
branches: | |
- main | |
- release/** | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
dist: | |
name: Build distributions | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get source code | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install build requirements | |
run: python -m pip install build | |
- name: Create distributions | |
run: python -m build . --sdist --wheel --outdir . | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: tarball | |
path: ciecplib-*.tar.* | |
if-no-files-found: error | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: wheel | |
path: ciecplib*.whl | |
if-no-files-found: error | |
# -- Pip ------------------ | |
pip-install: | |
name: Pip install from wheel (Python ${{ matrix.python-version }}, ${{ matrix.os }}) | |
needs: | |
- dist | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- macOS | |
- Ubuntu | |
- Windows | |
python-version: | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
runs-on: ${{ matrix.os }}-latest | |
steps: | |
- name: Download tarball | |
uses: actions/download-artifact@v3 | |
with: | |
name: wheel | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install system requirements (Linux) | |
if: matrix.os == 'Ubuntu' | |
run: | | |
sudo apt-get install -y -q -q \ | |
libkrb5-dev \ | |
; | |
- name: List installed packages | |
run: python -m pip list installed | |
- name: Install from wheel | |
shell: bash -e {0} | |
run: python -m pip install ciecplib*.whl | |
- name: Sanity check entry points | |
run: | | |
ecp-cert-info --help | |
ecp-curl --help | |
ecp-get-cert --help | |
ecp-get-cookie --help | |
# -- Conda ---------------- | |
conda-install: | |
name: Conda build | |
needs: | |
- dist | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -el {0} | |
steps: | |
- name: Download tarball | |
uses: actions/download-artifact@v3 | |
with: | |
name: tarball | |
- name: Cache conda packages | |
uses: actions/cache@v3 | |
env: | |
# increment to reset cache | |
CACHE_NUMBER: 0 | |
with: | |
path: ~/conda_pkgs_dir | |
key: conda-build-${{ env.CACHE_NUMBER }} | |
restore-keys: conda-build- | |
- name: Configure conda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
activate-environment: build | |
miniforge-variant: Miniforge3 | |
python-version: "3.12" | |
- name: Conda info | |
run: conda info --all | |
- name: Install conda build tooling | |
run: | | |
conda install --name base \ | |
boa \ | |
conda-build \ | |
conda-forge-pinning \ | |
conda-verify \ | |
; | |
- name: Install grayskull | |
run: | | |
conda install --name build \ | |
grayskull \ | |
packaging \ | |
; | |
- name: Generate conda recipe | |
run: | | |
grayskull pypi ciecplib-*.tar.* \ | |
--extras-require-test tests \ | |
--maintainers ${{ github.actor }} \ | |
; | |
- name: Display conda recipe | |
run: | | |
echo "-----------------" | |
cat ciecplib/meta.yaml | |
echo "-----------------" | |
- name: Build the recipe | |
run: conda mambabuild ciecplib/ -m $(conda info --base)/conda_build_config.yaml | |
- name: Install the conda package | |
run: conda install --name build --use-local ciecplib | |
- name: Sanity check entry points | |
run: | | |
ecp-cert-info --help | |
ecp-curl --help | |
ecp-get-cert --help | |
ecp-get-cookie --help | |
# -- Debian --------------- | |
debian-source: | |
name: Debian source package | |
needs: | |
- dist | |
runs-on: ubuntu-latest | |
container: debian:bookworm | |
env: | |
TARBALL: "ciecplib-*.tar.*" | |
steps: | |
- name: Download tarball | |
uses: actions/download-artifact@v3 | |
with: | |
name: tarball | |
- name: Configure apt | |
run: | | |
apt-get autoclean | |
apt-get -y -q -q update | |
apt-get -y -q -q install \ | |
dpkg-dev \ | |
; | |
- name: Create source package | |
run: | | |
mkdir src | |
tar -xf ${TARBALL} -C src --strip-components=1 | |
# rename tarball for debian orig | |
_orig=$(basename ${TARBALL} | sed 's|\(.*\)-\(.*\).\(tar\..*\)|\1_\2.orig.tar.gz|') | |
mv -v ${TARBALL} "${_orig}" | |
# create debian source package files | |
dpkg-source --build src | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: debian-source | |
path: | | |
*.orig.tar.* | |
*.debian.tar.* | |
*.dsc | |
if-no-files-found: error | |
debian-binary: | |
name: Debian ${{ matrix.debian }} binary package | |
needs: | |
- debian-source | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- debian: Bullseye | |
container: igwn/builder:bullseye-backports | |
- debian: Bookworm | |
container: igwn/builder:bookworm | |
runs-on: ubuntu-latest | |
container: ${{ matrix.container }} | |
env: | |
DSC: "ciecplib_*.dsc" | |
steps: | |
- name: Download source package | |
uses: actions/download-artifact@v3 | |
with: | |
name: debian-source | |
- name: Configure apt | |
run: | | |
apt-get -y -q -q update | |
apt-get -y -q -q install \ | |
devscripts \ | |
dpkg-dev \ | |
; | |
- name: Unpack DSC | |
run: | | |
dpkg-source --extract ${DSC} src | |
- name: Install build dependencies | |
env: | |
DOCKER_CONTAINER: ${{ matrix.container }} | |
shell: bash -ex {0} | |
run: | | |
cd src | |
if [[ "${{ matrix.container }}" == *backports ]]; then | |
. /etc/os-release | |
BACKPORTS="-t ${VERSION_CODENAME}-backports"; | |
fi | |
mk-build-deps \ | |
--tool "apt-get -y -q ${BACKPORTS:-} -o Debug::pkgProblemResolver=yes --no-install-recommends" \ | |
--install \ | |
--remove \ | |
; | |
# also install pytest-cov | |
apt-get -y -q -q install python3-pytest-cov | |
- name: Get Python version (for codecov flags) | |
run: | | |
echo PYTHON_VERSION=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") >> "$GITHUB_ENV" | |
- name: Build binary packages | |
run: | | |
# set pytest environment | |
export COVERAGE_FILE="$(pwd)/.coverage" | |
export PYBUILD_TEST_ARGS="-ra --verbose --cov ciecplib --pyargs ciecplib --junitxml='$(pwd)/pytest.xml'" | |
# build debian packages | |
cd src | |
dpkg-buildpackage -us -uc -b | |
- name: Print package info | |
run: | | |
# print contents of packages | |
for debf in *.deb; do | |
echo "===== ${debf}" | |
dpkg --info "${debf}" | |
dpkg --contents "${debf}" | |
done | |
- name: Install new packages | |
run: | | |
dpkg --install *.deb || { \ | |
apt-get -y -f install; | |
dpkg --install *.deb; | |
} | |
- name: Get source code to assist codecov | |
uses: actions/checkout@v4 | |
with: | |
path: src | |
- name: Coverage report | |
run: | | |
cd src | |
# use 'combine' to implement sources map | |
python3 -m coverage combine ../.coverage | |
# print report | |
python3 -m coverage report --show-missing | |
# convert to xml for codecov | |
python3 -m coverage xml | |
- name: Publish coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
files: coverage.xml | |
root_dir: src | |
flags: Linux,Debian,${{ matrix.debian }},python${{ env.PYTHON_VERSION }} | |
- name: Upload test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pytest-${{ matrix.debian }} | |
path: pytest.xml | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: deb-${{ matrix.debian }} | |
path: | | |
*.buildinfo | |
*.changes | |
*.deb | |
if-no-files-found: error | |
debian-install: | |
name: Debian ${{ matrix.debian }} install test | |
needs: | |
- debian-binary | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- debian: Bullseye | |
container: igwn/base:bullseye | |
- debian: Bookworm | |
container: igwn/base:bookworm | |
runs-on: ubuntu-latest | |
container: ${{ matrix.container }} | |
steps: | |
- name: Download binary packages | |
uses: actions/download-artifact@v3 | |
with: | |
name: deb-${{ matrix.debian }} | |
- name: Configure apt | |
run: apt-get -y -q -q update | |
- name: Install packages | |
shell: bash -ex {0} | |
run: | | |
dpkg --install *.deb || { \ | |
apt-get -y -f install; | |
dpkg --install *.deb; | |
} | |
- name: Sanity check entry points | |
run: | | |
ecp-cert-info --help | |
ecp-curl --help | |
ecp-get-cert --help | |
ecp-get-cookie --help | |
lint-debian: | |
name: Lint Debian packages | |
runs-on: ubuntu-latest | |
container: debian | |
needs: | |
- debian-binary | |
steps: | |
- name: Download debian package | |
uses: actions/download-artifact@v3 | |
with: | |
name: deb-Bookworm | |
- name: Install lintian | |
run: | | |
apt-get -y -q -q update | |
apt-get -y -q -q install \ | |
lintian \ | |
; | |
- name: Lintian | |
run: lintian --color=auto --allow-root --pedantic --fail-on error,warning *.changes | |
# -- RHEL ----------------- | |
rhel-source: | |
name: LSCSoft (${{ matrix.dist }}) ${{ matrix.version }} source package | |
needs: | |
- dist | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- dist: Rocky Linux | |
version: 8 | |
- dist: Rocky Linux | |
version: 9 | |
image: igwn/base | |
runs-on: ubuntu-latest | |
container: ${{ matrix.image || 'igwn/builder' }}:el${{ matrix.version }}-testing | |
env: | |
TARBALL: "ciecplib-*.tar.*" | |
steps: | |
- name: Download tarball | |
uses: actions/download-artifact@v3 | |
with: | |
name: tarball | |
- name: Configure rpmbuild | |
run: | | |
dnf -y install \ | |
python-srpm-macros \ | |
rpm-build \ | |
; | |
- name: Configure EPEL | |
run: | | |
dnf -y install epel-release | |
dnf -y install epel-rpm-macros | |
- name: Create source package | |
run: rpmbuild -ts --define "_srcrpmdir $(pwd)" ${TARBALL} | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: srpm-${{ matrix.version }} | |
path: "*.src.rpm" | |
if-no-files-found: error | |
rhel-binary: | |
name: LSCSoft (${{ matrix.dist }}) ${{ matrix.version }} binary package | |
needs: | |
- rhel-source | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- dist: Rocky Linux | |
version: 8 | |
- dist: Rocky Linux | |
version: 9 | |
image: igwn/base | |
runs-on: ubuntu-latest | |
container: ${{ matrix.image || 'igwn/builder' }}:el${{ matrix.version }}-testing | |
env: | |
SRPM: "ciecplib-*.src.rpm" | |
steps: | |
- name: Download SRPM | |
uses: actions/download-artifact@v3 | |
with: | |
name: srpm-${{ matrix.version }} | |
- name: Configure EPEL | |
run: | | |
dnf -y install epel-release | |
dnf -y install epel-rpm-macros | |
- name: Install build tools | |
run: | | |
dnf -y install \ | |
rpm-build \ | |
"dnf-command(builddep)" \ | |
; | |
- name: Install build dependencies | |
run: dnf builddep -y ${SRPM} | |
- name: Configure test coverage (el9+) | |
if: matrix.version >= 9 | |
run: | | |
# install pytest-cov | |
dnf -y install \ | |
python3-pytest-cov \ | |
; | |
- name: Get Python version (for codecov flags) | |
run: | | |
echo PYTHON_VERSION=$(/usr/bin/python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") >> "$GITHUB_ENV" | |
- name: Build binary packages | |
run: | | |
# configure coverage reporting during rpmbuild | |
export COVERAGE_FILE="$(pwd)/.coverage" | |
export PYTEST_ADDOPTS="--cov ciecplib --junitxml='$(pwd)/pytest.xml'" | |
# build RPMs | |
rpmbuild --rebuild --define "_rpmdir $(pwd)" ${SRPM} | |
rm -f ${SRPM} | |
mv */*.rpm . | |
- name: Print package info | |
run: | | |
# print contents of packages | |
for rpmf in *.rpm; do | |
echo "===== ${rpmf}" | |
rpm -qp --info "${rpmf}" | |
echo "-- Files:" | |
rpm -qp --list "${rpmf}" | |
echo "-- Provides:" | |
rpm -qp --provides "${rpmf}" | |
echo "-- Requires:" | |
rpm -qp --requires "${rpmf}" | |
done | |
- name: Install new packages | |
run: dnf -y install *.rpm | |
- name: Get source code to assist codecov | |
if: matrix.version >= 9 | |
uses: actions/checkout@v4 | |
with: | |
path: src | |
- name: Coverage report | |
if: matrix.version >= 9 | |
run: | | |
cd src | |
# use 'combine' to implement sources map | |
python3 -m coverage combine \ | |
--debug=config \ | |
--rcfile=pyproject.toml \ | |
../.coverage | |
# print report | |
python3 -m coverage report --show-missing | |
# convert to xml for codecov | |
python3 -m coverage xml | |
- name: Publish coverage to Codecov | |
if: matrix.version >= 9 | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./coverage.xml | |
root_dir: src | |
flags: Linux,EL,EL${{ matrix.version }},python${{ env.PYTHON_VERSION }} | |
- name: Upload test results | |
if: matrix.version >= 9 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pytest-el${{ matrix.version }} | |
path: pytest.xml | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: rpm-${{ matrix.version }} | |
path: "*.rpm" | |
if-no-files-found: error | |
rhel-install: | |
name: LSCSoft (${{ matrix.dist }}) ${{ matrix.version }} install test | |
needs: | |
- rhel-binary | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- dist: Rocky Linux | |
version: 8 | |
- dist: Rocky Linux | |
version: 9 | |
image: igwn/base | |
runs-on: ubuntu-latest | |
container: ${{ matrix.image || 'igwn/base' }}:el${{ matrix.version }}-testing | |
steps: | |
- name: Download RPMs | |
uses: actions/download-artifact@v3 | |
with: | |
name: rpm-${{ matrix.version }} | |
- name: Configure EPEL | |
run: dnf -y install epel-release | |
- name: Install RPMs | |
run: dnf -y install *.rpm | |
- name: Sanity check entry points | |
run: | | |
ecp-cert-info --help | |
ecp-curl --help | |
ecp-get-cert --help | |
ecp-get-cookie --help | |
- name: Install test requirements | |
if: matrix.version < 9 | |
run: | | |
dnf -y install python3-pip | |
python3 -m pip install \ | |
pytest \ | |
pytest-cov \ | |
requests-mock \ | |
; | |
- name: Get Python version (for codecov flags) | |
run: | | |
echo PYTHON_VERSION=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") >> "$GITHUB_ENV" | |
- name: Run test suite | |
if: matrix.version < 9 | |
run: | | |
python3 -m pytest -ra --verbose --cov ciecplib --pyargs ciecplib --junitxml=pytest.xml | |
- name: Get source code to assist codecov | |
if: matrix.version < 9 | |
uses: actions/checkout@v4 | |
with: | |
path: src | |
- name: Coverage report | |
if: matrix.version < 9 | |
run: | | |
cd src | |
python3 -m coverage combine ../.coverage | |
python3 -m coverage report --show-missing | |
python3 -m coverage xml | |
- name: Publish coverage to Codecov | |
if: matrix.version < 9 | |
uses: codecov/codecov-action@v3 | |
with: | |
files: coverage.xml | |
root_dir: src | |
flags: Linux,EL,EL${{ matrix.version }},python${{ env.PYTHON_VERSION }} | |
- name: Upload test results | |
if: matrix.version < 9 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pytest-el${{ matrix.version }} | |
path: pytest.xml | |
lint-rhel: | |
name: Lint CentOS packages | |
runs-on: ubuntu-latest | |
container: igwn/base:el9-testing | |
needs: | |
- rhel-binary | |
steps: | |
- name: Download RPM | |
uses: actions/download-artifact@v3 | |
with: | |
name: rpm-9 | |
- name: Configure EPEL | |
run: dnf -y install epel-release | |
- name: Install rpmlint | |
run: | | |
dnf -y install \ | |
rpmlint \ | |
*.rpm \ | |
; | |
- name: Lint | |
run: rpmlint --info "*ciecp*" *.rpm |