ci(actions): fix pdm environ vars #838
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
name: CI | |
on: | |
push: | |
branches: [master] | |
tags: ["v*.*.*"] | |
pull_request: | |
branches: [master] | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
id: setup-python | |
with: | |
python-version: ">=3.9" | |
- name: Setup PDM | |
uses: "pdm-project/setup-pdm@v4.1" | |
id: setup-pdm | |
with: | |
cache: true | |
- name: Install dependencies | |
run: pdm install | |
- name: Cache Pre-Commit Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: Lint with Mypy and Flake8 | |
run: | | |
pdm run pre-commit run --all | |
build: | |
needs: [lint] | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: [3.9, "3.10", "3.11", "3.12"] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Setup PDM | |
uses: "pdm-project/setup-pdm@v4.1" | |
id: setup-pdm | |
with: | |
cache: true | |
- name: Install Dependencies | |
run: pdm install | |
# TODO: add testing steps | |
- name: Test with Pytest | |
run: pdm run pytest -n auto --dist=worksteal --cov=src/ --cov-report=lcov --cov-branch | |
- name: Upload Coverage Report | |
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 # v2.2.3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
file: "./coverage.lcov" | |
parallel: true | |
flag-name: run-${{ matrix.os }}-python-${{ matrix.python-version }} | |
publish: | |
needs: [build] | |
runs-on: ubuntu-latest | |
if: ${{ github.ref_type == 'tag' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install commitizen | |
run: pipx install commitizen | |
- name: Get 2nd-last commit tag | |
id: second-last | |
run: | | |
tags="$(git tag --sort=creatordate)" | |
output='' | |
# length > 1 means we have multiple tags and we need 2nd last one | |
if [[ "$(echo "$tags" | grep -c ^)" != "1" ]]; then | |
output="$(echo "$tags" | tail -2 | head -1)" | |
fi | |
echo "tag=$output" >> $GITHUB_OUTPUT | |
- name: Generate Changelog | |
run: | | |
# from 2nd-last revision upto this current tag. | |
cz ch --start-rev '${{ steps.second-last.outputs.tag }}' \ | |
--unreleased-version '${{ github.ref_name }}' \ | |
--file-name body.md | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
body_path: body.md | |
tag_name: ${{ github.ref_name }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ">=3.9" | |
- name: Setup PDM | |
uses: "pdm-project/setup-pdm@v4.1" | |
id: setup-pdm | |
with: | |
cache: true | |
- name: Publish Package | |
run: pdm publish | |
env: | |
PDM_PUBLISH_USERNAME: __token__ | |
PDM_PUBLISH_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
finish: | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Finish Coverage Report | |
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 # v2.2.3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
parallel-finished: true |