Main #2383
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: Main | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
schedule: | |
- cron: "0 0 * * *" # daily | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
cancel-in-progress: true | |
env: | |
FORCE_COLOR: "1" | |
TOX_TESTENV_PASSENV: "FORCE_COLOR" | |
MIN_PYTHON_VERSION: "3.8" | |
DEFAULT_PYTHON_VERSION: "3.10" | |
permissions: | |
contents: read | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/[email protected] | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON_VERSION }} | |
- name: Install dependencies | |
run: python -m pip install tox | |
- name: Run linting | |
run: python -m tox -e lint | |
test: | |
strategy: | |
matrix: | |
python-version: | |
- "3.8" | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
platform: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/[email protected] | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: python -m pip install tox | |
- name: Run type-checking | |
run: python -m tox -e types | |
- name: Run tests | |
run: python -m tox -e py | |
# Because the tests can be flaky, they shouldn't be required for merge, but | |
# it's still helpful to run them on PRs. See: | |
# https://github.com/pypa/twine/issues/684#issuecomment-703150619 | |
integration: | |
# Only run on Ubuntu because most of the tests are skipped on Windows | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/[email protected] | |
with: | |
python-version: ${{ env.MIN_PYTHON_VERSION }} | |
- name: Install dependencies | |
run: python -m pip install tox | |
- name: Run tests | |
run: python -m tox -e integration | |
docs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/[email protected] | |
with: | |
python-version: ${{ env.MIN_PYTHON_VERSION }} | |
- name: Install dependencies | |
run: python -m pip install tox | |
- name: Build docs | |
run: python -m tox -e docs | |
# https://github.com/marketplace/actions/alls-green#why | |
check: # This job does nothing and is only used for the branch protection | |
if: always() | |
needs: | |
- lint | |
- test | |
- integration | |
- docs | |
runs-on: ubuntu-latest | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@release/v1 | |
with: | |
allowed-failures: integration # can be flaky | |
jobs: ${{ toJSON(needs) }} | |
release: | |
needs: | |
- check | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/[email protected] | |
with: | |
python-version: ${{ env.MIN_PYTHON_VERSION }} | |
- name: Install dependencies | |
run: python -m pip install tox | |
- name: Release | |
run: tox -e release | |
env: | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |