Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV - Refactor CI and environment setup #1759

Merged
merged 81 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
c1cfeaa
Add python default doc
trallard Mar 28, 2024
1edcade
Add tox configuration
trallard Mar 28, 2024
d71c46a
Add tox based workflow
trallard Mar 28, 2024
03c8531
Rename workflow
trallard Mar 28, 2024
a992b12
Add debugging branch
trallard Mar 28, 2024
72bec4b
Remove extra .
trallard Mar 28, 2024
a1baedc
Update tox commands
trallard Mar 28, 2024
027c2bb
Add sphinx versions test
trallard Mar 28, 2024
5a282da
Update workflow syntax
trallard Mar 28, 2024
d285c4d
Fix typo
trallard Mar 28, 2024
c90409b
Add build docs
trallard Mar 28, 2024
5da3482
Add pandoc
trallard Apr 2, 2024
3280ac0
Exclude non-supported version
trallard Apr 2, 2024
cf30a7f
Remove if check
trallard Apr 2, 2024
d9c18fb
Fix sphinx version expression
trallard Apr 2, 2024
47fc967
Use composite action
trallard Apr 2, 2024
cfbfe60
Fix inputs in composite
trallard Apr 2, 2024
84c554c
Install Sphinx dev deps
trallard Apr 2, 2024
4272ccc
Always use bash
trallard Apr 2, 2024
3f3b203
Add lighthouse audits
trallard Apr 2, 2024
0c36b2e
Allow for build docs params
trallard Apr 2, 2024
b3ce8b3
Fix deps - docs
trallard Apr 2, 2024
da0b90d
Fix if syntax
trallard Apr 2, 2024
fc588c5
Clean nox
trallard Apr 2, 2024
7cdff01
Fix base python
trallard Apr 2, 2024
92b1b53
Add coverage
trallard Apr 2, 2024
29b756d
Ensure docs are built for a11y tests
trallard Apr 2, 2024
0085c77
Update tox commands and envs
trallard Apr 3, 2024
ec5c1e0
Make compile explicit
trallard Apr 3, 2024
256d574
Skip installs in lint
trallard Apr 4, 2024
2b5b862
Add coverage upload
trallard Apr 4, 2024
8f6c9cb
Fix Python version
trallard Apr 4, 2024
37ea780
Update pre-release workflow
trallard Apr 4, 2024
d77fddb
Update tox.ini
trallard Apr 4, 2024
1bcfa64
Small formatting and style fixes to actions
trallard Apr 4, 2024
574e294
Add profiling to CI
trallard Apr 5, 2024
9f84c92
Remove default version
trallard Apr 5, 2024
dfbca62
Remove trallard debug in ci
trallard Apr 5, 2024
46eb200
Apply suggestions from code review
trallard Apr 8, 2024
dc202fa
Add inline comments
trallard Apr 8, 2024
a59a4fb
Merge branch 'trallard/update-ci' of https://github.com/trallard/pyda…
trallard Apr 8, 2024
185efc6
Add Python 3.13 so we can start testing against it
trallard Apr 8, 2024
4d35885
:pencil2: Fix typo - profile
trallard Apr 8, 2024
7491341
Merge remote-tracking branch 'upstream/main' into trallard/update-ci
trallard Apr 8, 2024
dc3bc4f
Add Python 3.13 so we can start testing against it
trallard Apr 8, 2024
90b2739
Ensure we can run profiling in CI
trallard Apr 9, 2024
5887ea2
Remove 13 for now
trallard Apr 9, 2024
5f435b1
Add script for now - install gh
trallard Apr 10, 2024
876cc43
Use relative path for executable
trallard Apr 16, 2024
0b74130
make install scritp executable
Carreau Apr 16, 2024
19b8572
Merge remote-tracking branch 'origin/main' into trallard/update-ci
Carreau Apr 25, 2024
039c530
try to fix sphinx test
Carreau Apr 25, 2024
904ffeb
Fix Python version for profiling
trallard May 8, 2024
963b51a
Merge remote-tracking branch 'upstream/main' into trallard/update-ci
trallard May 8, 2024
491c59a
Update release workflow
trallard May 8, 2024
7a6d85c
:memo: Update dev setup docs
trallard May 9, 2024
f44df2a
:heavy_plus_sign: Add pandoc to prerelease workflow
trallard May 9, 2024
6b2dcca
Update manual dev instructions
trallard May 9, 2024
0532405
Add notes about codespaces
trallard May 9, 2024
800b89c
Add live-docs to tox
trallard May 9, 2024
7ebd352
Remove obsolete nox refs
trallard May 9, 2024
11343ec
Rename workflow to best reflect its purpose
trallard May 9, 2024
85650ff
Ensure we do not build pkg before compiling
trallard May 10, 2024
a609f3a
Update a11y-pygments test
trallard May 10, 2024
4123025
Merge branch 'main' into trallard/update-ci
trallard May 13, 2024
9a51128
Update contrbution docs
trallard May 13, 2024
36ec81f
Ensure we always use 80 as coverage treshold
trallard May 19, 2024
c3d8455
Fix profile step
trallard May 19, 2024
996bfda
Merge remote-tracking branch 'origin/main' into trallard/update-ci
Carreau May 23, 2024
4a59ab5
Fix CI - ensure consistency
trallard May 23, 2024
2f77ce1
Merge branch 'trallard/update-ci' of https://github.com/trallard/pyda…
trallard May 23, 2024
c242b93
Apply suggestions from code review
trallard May 23, 2024
cb294ca
Add nox to devcontainer for now
trallard May 23, 2024
652fea2
Merge branch 'trallard/update-ci' of https://github.com/trallard/pyda…
trallard May 23, 2024
48c5cdd
Update .github/workflows/CI.yml
Carreau May 24, 2024
e74f1e2
Update .github/workflows/CI.yml
Carreau May 24, 2024
c237a81
Apply suggestions from code review
Carreau May 24, 2024
325c29d
Apply suggestions from code review
Carreau May 24, 2024
607f940
Remove coverage from docs
trallard May 24, 2024
f5b0507
Add newer Python and ubuntu versions
trallard May 24, 2024
1043373
Exclude non-supported version
trallard May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"name": "Python 3",
"image": "mcr.microsoft.com/devcontainers/python:1-3.10-bullseye",
"features": {
"ghcr.io/devcontainers-contrib/features/tox:2": {},
"ghcr.io/devcontainers-contrib/features/nox:2": {},
"ghcr.io/devcontainers-contrib/features/pre-commit:2": {},
"ghcr.io/rocker-org/devcontainer-features/pandoc:1": {},
Expand Down
32 changes: 32 additions & 0 deletions .github/actions/set-dev-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Setup PST CI environment
description: Create a PST dev environment

inputs:
python-version:
description: Default Python version to use if none is specified
required: false
default: "3.12"
pandoc:
description: Whether this should install pandoc or not
required: false
default: "False"

runs:
using: composite
steps:
- name: "Setup Python 🐍"
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: "pip"
cache-dependency-path: "pyproject.toml"
allow-prereleases: true

- run: python -Im pip install tox-uv
shell: bash

# waiting for https://github.com/nikeee/setup-pandoc/pull/8
# using 12rambau fork until then
- name: "Install pandoc 📝"
uses: 12rambau/setup-pandoc@test
if: ${{ inputs.pandoc }} == true
3 changes: 2 additions & 1 deletion .github/prerelease-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ assignees: choldgraf
labels: bug, enhancement
---

A prerelease of one of our dependencies failed. See the
A prerelease of one of our dependencies failed.
See the
[action log](https://github.com/{{ env.GITHUB_ACTION_REPOSITORY }}/actions/runs/{{ env.GITHUB_RUN_ID }})
for more details.
234 changes: 234 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
name: continuous-integration-tox

# Concurrency group that uses the workflow name and PR number if available
# or commit SHA as a fallback. If a new build is triggered under that
# concurrency group while a previous build is running it will be canceled.
# Repeated pushes to a PR will cancel all previous builds, while multiple
# merges to main will not cancel.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

env:
FORCE_COLOR: "1" # Make tools pretty
DEFAULT_PYTHON_VERSION: "3.12" # keep in sync with tox.ini
PIP_DISABLE_PIP_VERSION_CHECK: "1" # Don't check for pip updates

permissions: {}

on:
push:
branches:
- main
pull_request:
workflow_call:
# allow manual triggering of the workflow, while debugging
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: "Checkout repository 🛎"
uses: actions/checkout@v4
- name: "Setup CI environment 🛠"
uses: ./.github/actions/set-dev-env
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
- name: "Run lint checks 🧹"
run: python -Im tox run -e lint

# Run our test suite on various combinations of OS & Python versions
run-pytest:
needs: lint
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest", "macos-latest", "macos-14", "windows-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
sphinx-version: [""]
include:
# oldest Python version with the oldest Sphinx version
- os: ubuntu-latest
python-version: "3.9"
sphinx-version: "6.1"
# newest Python version with the newest Sphinx version
- os: ubuntu-latest
python-version: "3.12"
# Sphinx HEAD
sphinx-version: "dev"
exclude:
# Python 3.9 is not supported on macOS 14 - https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
- os: macos-14
python-version: "3.9"
runs-on: ${{ matrix.os }}
steps:
- name: "Checkout repository 🛎"
uses: actions/checkout@v4
- name: "Setup CI environment 🛠"
uses: ./.github/actions/set-dev-env
with:
python-version: ${{ matrix.python-version }}
pandoc: true
- name: "Run tests ✅"
shell: bash
run: |
# this will compile the assets then run the tests
# check if there is a specific Sphinx version to test with
# example substitution: tox run -e compile,py39-sphinx61-tests
if [ -n "${{matrix.sphinx-version}}" ]; then
python -Im tox run -e compile,py$(echo ${{ matrix.python-version }} | tr -d .)-sphinx(echo ${{ matrix.sphinx-version }} | tr -d .)-tests
Carreau marked this conversation as resolved.
Show resolved Hide resolved
# if not we use the default version
# example substitution: tox run -e compile,py39-tests
else
python -Im tox run -e compile,py$(echo ${{ matrix.python-version }} | tr -d .)-tests
fi
- name: "Upload coverage data to GH artifacts 📤"
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' && matrix.sphinx-version == 'dev'
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ matrix.python-version }}
path: .coverage
if-no-files-found: ignore
trallard marked this conversation as resolved.
Show resolved Hide resolved

# Only run accessibility tests on the latest Python version (3.12) and Ubuntu
a11y-tests:
name: "a11y-tests (ubuntu-latest, 3.12)"
needs: lint
runs-on: ubuntu-latest
steps:
- name: "Checkout repository 🛎"
uses: actions/checkout@v4
- name: "Setup CI environment 🛠"
uses: ./.github/actions/set-dev-env
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
- name: "Run accessibility tests with playwright 🎭"
# build PST, build docs, then run a11y-tests
run: python -Im tox run -e py312-docs,a11y-tests
continue-on-error: true

# Build our docs (PST) on major OSes and check for warnings
build-site:
name: "build PST docs"
needs: lint
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.12"]
include:
# oldest Python version with the oldest Sphinx version
- os: ubuntu-latest
python-version: "3.9"
sphinx-version: "6.1"
runs-on: ${{ matrix.os }}
steps:
- name: "Checkout repository 🛎"
uses: actions/checkout@v4
- name: "Setup CI environment 🛠"
uses: ./.github/actions/set-dev-env
with:
python-version: ${{ matrix.python-version }}
pandoc: true
- name: "Build docs and check for warnings 📖"
shell: bash
run: |
# check if there is a specific Sphinx version to build with
# example substitution: tox run -e docs-py39-sphinx61-docs
if [ -n "${{matrix.sphinx-version}}" ]; then
python -Im tox run -e py$(echo ${{ matrix.python-version }} | tr -d .)-sphinx(echo ${{ matrix.sphinx-version }} | tr -d .)-docs
Carreau marked this conversation as resolved.
Show resolved Hide resolved
# build with the default Sphinx version
# example substitution: tox run -e docs-py312-docs
else
python -Im tox run -e py$(echo ${{ matrix.python-version }} | tr -d .)-docs
fi

# Run Lighthouse audits on the built site (kitchen-sink only)
lighthouse-audit:
needs: build-site
runs-on: ubuntu-latest
env:
DOCS_DIR: "audit"
steps:
- name: "Checkout repository 🛎"
uses: actions/checkout@v4
- name: "Setup CI environment 🛠"
uses: ./.github/actions/set-dev-env
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
- name: "Copy kitchen sink to a tiny site"
run: |
mkdir -p ${{ env.DOCS_DIR }}/site
cp -r docs/examples/kitchen-sink ${{ env.DOCS_DIR }}/site/kitchen-sink
printf "Test\n====\n\n.. toctree::\n\n kitchen-sink/index\n" > ${{ env.DOCS_DIR }}/site/index.rst
echo 'html_theme = "pydata_sphinx_theme"' > ${{ env.DOCS_DIR }}/site/conf.py
echo '.. toctree::\n :glob:\n\n *' >> ${{ env.DOCS_DIR }}/site/index.rst

# build docs without checking for warnings
python -Im tox run -e docs-no-checks

- name: "Audit with Lighthouse 🔦"
uses: treosh/lighthouse-ci-action@v11
with:
configPath: ".github/workflows/lighthouserc.json"
temporaryPublicStorage: true
uploadArtifacts: true
runs: 3 # Multiple runs to reduce variance

coverage:
name: "check coverage"
needs: run-pytest
runs-on: ubuntu-latest
steps:
- name: "Checkout repository 🛎"
uses: actions/checkout@v4
- name: "Setup CI environment 🛠"
uses: ./.github/actions/set-dev-env
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
- run: python -Im pip install --upgrade coverage[toml]
- name: "Download coverage data 📥"
uses: actions/download-artifact@v4
with:
pattern: coverage-data-*
merge-multiple: true
- name: "Get coverage data & fail if it's <80%"
run: |
# if we decide to check cov across versions and combine
# python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty

# report and write to summary.
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY

# report again and fail if under 80%.
python -Im coverage report --fail-under=80
- name: "Upload HTML report if check failed 📤"
uses: actions/upload-artifact@v4
with:
name: html-report
path: htmlcov
if: ${{ failure() }}

profiling:
needs: [build-site, run-pytest]
runs-on: ubuntu-latest
steps:
- name: "Checkout repository 🛎"
uses: actions/checkout@v4
- name: "Setup CI environment 🛠"
uses: ./.github/actions/set-dev-env
with:
# 3.12 is not supported by py-spy yet
python-version: "3.11"
- name: "Run profiling with py-spy 🕵️‍♂️"
# profiling needs to be run as sudo
run: python -m tox run -e py311-profile-docs -- -o docbuild_profile.svg
continue-on-error: true
- name: "Upload profiling data to GH artifacts 📤"
uses: actions/upload-artifact@v4
with:
name: profile-results
path: docbuild_profile.svg
if-no-files-found: ignore
39 changes: 18 additions & 21 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
- cron: "0 5 * * 1,4"
workflow_dispatch:

env:
FORCE_COLOR: "1" # Make tools pretty
PIP_DISABLE_PIP_VERSION_CHECK: "1" # Don't check for pip updates

jobs:
prerelease:
runs-on: ubuntu-latest
Expand All @@ -16,35 +20,28 @@ jobs:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: "Checkout repository 🛎"
uses: actions/checkout@v4
- name: "Setup CI environment 🛠"
uses: ./.github/actions/set-dev-env
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "pyproject.toml"

- name: Install (prerelease) dependencies
pandoc: "True"
- name: "Install (prerelease) dependencies 📦"
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install --upgrade --pre -e .[doc,test]
- name: Build docs to store
python -Im pip install --upgrade pip wheel setuptools
- name: "Build PST docs and check for warnings 📖"
run: |
sphinx-build -b html docs/ docs/_build/html --keep-going -w warnings.txt
- name: Check that there are no unexpected Sphinx warnings
if: matrix.python-version == '3.10'
run: python tests/utils/check_warnings.py

- name: Run the tests
# example substitution: tox run -e docs-py312-docs
python -Im tox run -e docs-py$(echo ${{ matrix.python-version }} | tr -d .)-docs -- --keep-going
- name: "Run tests ✅ (no coverage)"
run: |
pytest --color=yes
# this will compile the assets then run the tests
python -Im tox run -e compile,py$(echo ${{ matrix.python-version }} | tr -d .)-tests-no-cov
echo "PYTEST_ERRORS=$?" >> $GITHUB_ENV
# If either the docs build or the tests resulted in an error, create an issue to note it
- name: Create an issue if failure
- name: "Create an issue if failure"
uses: JasonEtco/create-an-issue@v2
if: ${{ env.SPHINX_BUILD_UNEXPECTED_WARNINGS || !env.PYTEST_ERRORS }}
env:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ permissions:
jobs:
# calls our tests workflow
tests:
uses: ./.github/workflows/tests.yml
uses: ./.github/workflows/CI.yml

build-package:
name: "Build & verify PST package"
Expand All @@ -27,10 +27,11 @@ jobs:
- name: "Checkout repository 🛎"
uses: actions/checkout@v4

- name: "Set up Python 3.9"
uses: actions/setup-python@v5
- name: "Setup CI environment 🛠"
uses: ./.github/actions/set-dev-env
with:
python-version: "3.9"
pandoc: "False"

- name: "Install gettext for translations 🌐"
run: |
Expand Down
Loading
Loading