103 lines
3.9 KiB
YAML
103 lines
3.9 KiB
YAML
# see https://github.com/karlicoss/pymplate for up-to-date reference
|
|
|
|
name: CI
|
|
on:
|
|
push:
|
|
branches: '*'
|
|
tags: 'v[0-9]+.*' # only trigger on 'release' tags for PyPi
|
|
# Ideally I would put this in the pypi job... but github syntax doesn't allow for regexes there :shrug:
|
|
pull_request: # needed to trigger on others' PRs
|
|
# Note that people who fork it need to go to "Actions" tab on their fork and click "I understand my workflows, go ahead and enable them".
|
|
workflow_dispatch: # needed to trigger workflows manually
|
|
# todo cron?
|
|
inputs:
|
|
debug_enabled:
|
|
type: boolean
|
|
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
|
required: false
|
|
default: false
|
|
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
matrix:
|
|
platform: [ubuntu-latest, macos-latest, windows-latest]
|
|
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
|
|
exclude: [
|
|
# windows runners are pretty scarce, so let's only run lowest and highest python version
|
|
{platform: windows-latest, python-version: '3.9' },
|
|
{platform: windows-latest, python-version: '3.10'},
|
|
{platform: windows-latest, python-version: '3.11'},
|
|
|
|
# same, macos is a bit too slow and ubuntu covers python quirks well
|
|
{platform: macos-latest , python-version: '3.9' },
|
|
{platform: macos-latest , python-version: '3.10' },
|
|
{platform: macos-latest , python-version: '3.11' },
|
|
]
|
|
|
|
runs-on: ${{ matrix.platform }}
|
|
|
|
# useful for 'optional' pipelines
|
|
# continue-on-error: ${{ matrix.platform == 'windows-latest' }}
|
|
|
|
steps:
|
|
# ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation
|
|
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
fetch-depth: 0 # nicer to have all git history when debugging/for tests
|
|
|
|
- uses: mxschmitt/action-tmate@v3
|
|
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
|
|
|
|
# explicit bash command is necessary for Windows CI runner, otherwise it thinks it's cmd...
|
|
- run: bash .ci/run
|
|
|
|
- if: matrix.platform == 'ubuntu-latest' # no need to compute coverage for other platforms
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: .coverage.mypy-misc_${{ matrix.platform }}_${{ matrix.python-version }}
|
|
path: .coverage.mypy-misc/
|
|
- if: matrix.platform == 'ubuntu-latest' # no need to compute coverage for other platforms
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: .coverage.mypy-core_${{ matrix.platform }}_${{ matrix.python-version }}
|
|
path: .coverage.mypy-core/
|
|
|
|
pypi:
|
|
runs-on: ubuntu-latest
|
|
needs: [build] # add all other jobs here
|
|
|
|
steps:
|
|
# ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation
|
|
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
|
|
- uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.8'
|
|
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: 'release to test pypi'
|
|
# always deploy merged master to test pypi
|
|
if: github.event_name != 'pull_request' && github.event.ref == 'refs/heads/master'
|
|
env:
|
|
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD_TEST }}
|
|
run: pip3 install --user --upgrade build twine && .ci/release --test
|
|
|
|
- name: 'release to pypi'
|
|
# always deploy tags to release pypi
|
|
# NOTE: release tags are guarded by on: push: tags on the top
|
|
if: github.event_name != 'pull_request' && startsWith(github.event.ref, 'refs/tags')
|
|
env:
|
|
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
|
|
run: pip3 install --user --upgrade build twine && .ci/release --test
|