Skip to content

Derived property clean #9002

Derived property clean

Derived property clean #9002

Workflow file for this run

name: tests
on:
push:
branches:
- main
- 8.x
tags:
- v*
pull_request:
schedule:
- cron: '14 7 * * 0' # run once a week on Sunday
workflow_dispatch:
pull_request_review:
types: [submitted]
jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
# See https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/passing-information-between-jobs#example-defining-outputs-for-a-job
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Set matrix
id: set-matrix
env:
EVENT_NAME: ${{ github.event_name }}
GIT_REF: ${{ github.ref }}
REVIEW_STATE: ${{ github.event.review.state }}
run: |
matrix_json="$(python .github/workflows/generate_matrix.py "$GIT_REF" "$REVIEW_STATE" "$EVENT_NAME")"
echo "include=$(echo "$matrix_json" | python -c 'import json,sys; print(json.dumps(json.load(sys.stdin)["include"]))')" >> $GITHUB_OUTPUT
run-tests:
needs: generate-matrix
strategy:
matrix:
include: ${{ fromJSON(needs.generate-matrix.outputs.include) }}
runs-on: ubuntu-latest
name: ${{ matrix.test_name }}
steps:
- name: Skip notice
if: ${{ matrix.skip }}
run: echo "Skipped ${{ matrix.test_name }} (not required for this trigger)"
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
if: ${{ !matrix.skip }}
with:
fetch-tags: true
- name: Install uv and Python ${{ matrix.python_version }}
if: ${{ !matrix.skip }}
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
# zizmor: ignore[cache-poisoning] - run-tests does not produce release artifacts
enable-cache: true
# UV_VERSION can be set in the repository settings:
# Settings -> Secrets and variables -> Actions or click here:
# https://github.com/PyCalendar/icalendar/settings/variables/actions
# -> Variables -> UV_VERSION
version: "${{ vars.UV_VERSION }}"
python-version: ${{ matrix.python_version }}
- name: Install dependencies
if: ${{ !matrix.skip }}
run: |
make dev PYTHONVERSION=${{ matrix.python_version }}
uv tree
- name: Test
if: ${{ !matrix.skip }}
run: ${{ matrix.test_command }}
- name: Coveralls Parallel
if: ${{ !matrix.skip }}
uses: coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2
with:
flag-name: run-${{ matrix.test_name }}
parallel: true
file: coverage.xml
allow-empty: true
fail-on-error: false
coverage:
# parallel test coverage upload
# see https://coveralls-python.readthedocs.io/en/latest/usage/configuration.html#github-actions-support
name: Submit test coverage
needs: run-tests
# always finalize coverage aftest tests ran
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-not-requiring-successful-dependent-jobs
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2
with:
parallel-finished: true
format: cobertura
fail-on-error: false
test-distribution:
name: Check built packages
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Install uv and Python
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
enable-cache: false
version: "0.11.6"
- name: Check the release files
run: make test-dist
- name: Upload built packages
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: built-packages
path: dist/*
test-source-distribution:
name: Test source distribution
needs: test-distribution
permissions: {}
runs-on: ubuntu-latest
steps:
- name: Download built packages
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: built-packages
path: dist
- name: Install uv and Python 3.14
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
enable-cache: false
# UV_VERSION can be set in the repository settings:
# Settings -> Secrets and variables -> Actions or click here:
# https://github.com/PyCalendar/icalendar/settings/variables/actions
# -> Variables -> UV_VERSION
version: "${{ vars.UV_VERSION }}"
python-version: "3.14"
- name: Unpack source distribution
run: |
mkdir source-distribution
tar --extract --gzip --file dist/*.tar.gz --directory source-distribution --strip-components=1
- name: Test source distribution
working-directory: source-distribution
run: uv run --group test pytest
deploy-tag-to-pypi:
# only deploy on tags, see https://stackoverflow.com/a/58478262/1320237
if: startsWith(github.ref, 'refs/tags/v')
needs:
- run-tests
- test-distribution
- test-source-distribution
runs-on: ubuntu-latest
# Publishes with PyPI Trusted Publishing, configured for this workflow and environment.
# See https://docs.pypi.org/trusted-publishers/
environment:
name: PyPI
url: https://pypi.org/project/icalendar/
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.14"
- name: Update pip
run: scripts/update-pip.sh
- name: Install dependencies
run: pip install build twine
- name: remove old files
run: rm -rf dist/*
- name: build distribution files
run: python -m build # same as in test-distribution
- name: check distribution files
run: twine check dist/*
- name: deploy to pypi
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
deploy-github-release:
# only deploy on tags, see https://stackoverflow.com/a/58478262/1320237
if: startsWith(github.ref, 'refs/tags/v')
needs:
- run-tests
- test-distribution
- test-source-distribution
runs-on: ubuntu-latest
environment:
name: github-release
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Create GitHub release from tag
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1
with:
allowUpdates: true
body: "To view the changes, please see the [Changelog](https://icalendar.readthedocs.io/en/latest/reference/changelog.html). This release can be installed from [PyPI](https://pypi.org/project/icalendar/#history)."
generateReleaseNotes: false