Skip to content

Commit

Permalink
Merge branch 'main' into missing-exception
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek authored Jul 22, 2023
2 parents 6ca2aa7 + 549c414 commit 502090b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 55 deletions.
84 changes: 32 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,26 @@ env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"

# For re-actors/checkout-python-sdist
SETUPTOOLS_SCM_PRETEND_VERSION: "1.0" # hard-code version for predictable sdist names
sdist-artifact: python-package-distributions
sdist-name: structlog-1.0.tar.gz

# N.B. default Python version for setup-python comes from the .python-version
# file at the root of the project.

permissions: {}

jobs:
build-sdist:
name: 📦 Build the source distribution
build-package:
name: Build & verify package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
cache: pip
- run: python -Im pip install build
fetch-depth: 0

- run: python -Im build --sdist

- uses: actions/upload-artifact@v3
with:
name: ${{ env.sdist-artifact }}
# NOTE: Exact expected file names are specified here
# NOTE: as a safety measure — if anything weird ends
# NOTE: up being in this dir or not all dists will be
# NOTE: produced, this will fail the workflow.
path: dist/${{ env.sdist-name }}
retention-days: 15
- uses: hynek/build-and-inspect-python-package@v1

tests:
name: Tests & API Mypy on ${{ matrix.python-version }}
needs: build-sdist
needs: build-package
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -62,11 +45,12 @@ jobs:
- "3.12"

steps:
- name: Get source code from pre-built sdist
uses: re-actors/checkout-python-sdist@release/v1
- name: Download pre-built packages
uses: actions/download-artifact@v3
with:
source-tarball-name: ${{ env.sdist-name }}
workflow-artifact-name: ${{ env.sdist-artifact }}
name: Packages
path: dist
- run: tar xf dist/*.tar.gz --strip-components=1 # needed for config files

- uses: actions/setup-python@v4
with:
Expand All @@ -75,8 +59,8 @@ jobs:
cache: pip

- run: python -Im pip install tox
- run: python -Im tox run -f py$(echo ${{ matrix.python-version }} | tr -d .)
- run: python -Im tox run -e mypy-api
- run: python -Im tox run --installpkg dist/*.whl -f py$(echo ${{ matrix.python-version }} | tr -d .)
- run: python -Im tox run --installpkg dist/*.whl -e mypy-api

- name: Upload coverage data
uses: actions/upload-artifact@v3
Expand All @@ -91,12 +75,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Get source code from pre-built sdist
uses: re-actors/checkout-python-sdist@release/v1
with:
source-tarball-name: ${{ env.sdist-name }}
workflow-artifact-name: ${{ env.sdist-artifact }}

- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
cache: pip
Expand Down Expand Up @@ -125,17 +104,19 @@ jobs:
path: htmlcov
if: ${{ failure() }}

mypy:
mypy-pkg:
name: Type-check package
needs: build-sdist
needs: build-package
runs-on: ubuntu-latest

steps:
- name: Get source code from pre-built sdist
uses: re-actors/checkout-python-sdist@release/v1
- name: Download pre-built packages
uses: actions/download-artifact@v3
with:
source-tarball-name: ${{ env.sdist-name }}
workflow-artifact-name: ${{ env.sdist-artifact }}
name: Packages
path: dist
- run: tar xf dist/*.tar.gz --strip-components=1 # needed for config files

- uses: actions/setup-python@v4
with:
allow-prereleases: true
Expand All @@ -144,18 +125,20 @@ jobs:
- name: Prepare & run tox
run: |
python -Im pip install tox
python -Im tox run -e mypy-pkg
python -Im tox run --installpkg dist/*.whl -e mypy-pkg
docs:
name: Build docs & run doctests
needs: build-sdist
needs: build-package
runs-on: ubuntu-latest
steps:
- name: Get source code from pre-built sdist
uses: re-actors/checkout-python-sdist@release/v1
- name: Download pre-built packages
uses: actions/download-artifact@v3
with:
source-tarball-name: ${{ env.sdist-name }}
workflow-artifact-name: ${{ env.sdist-artifact }}
name: Packages
path: dist
- run: tar xf dist/*.tar.gz --strip-components=1 # needed for config files

- uses: actions/setup-python@v4
with:
# Keep in sync with tox.ini/docs & .readthedocs.yaml
Expand Down Expand Up @@ -189,6 +172,7 @@ jobs:
- coverage
- docs
- install-dev
- mypy-pkg

runs-on: ubuntu-latest

Expand All @@ -201,15 +185,11 @@ jobs:

colors:
name: Visual check for color settings using env variables
needs: build-sdist
needs: build-package
runs-on: ubuntu-latest

steps:
- name: Get source code from pre-built sdist
uses: re-actors/checkout-python-sdist@release/v1
with:
source-tarball-name: ${{ env.sdist-name }}
workflow-artifact-name: ${{ env.sdist-artifact }}
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
cache: pip
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/pypi-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
push:
branches: [main]
tags: ["*"]
pull_request:
branches: [main]
release:
types:
- published
Expand All @@ -17,7 +15,6 @@ permissions:
id-token: write

jobs:
# Always build & lint package.
build-package:
name: Build & verify package
runs-on: ubuntu-latest
Expand Down

0 comments on commit 502090b

Please sign in to comment.