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

DM-45243: Migrate to Pydantic v2 and adopt ruff for linting and formatting #52

Merged
merged 12 commits into from
Jul 17, 2024
Merged
7 changes: 0 additions & 7 deletions .flake8

This file was deleted.

11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
121 changes: 86 additions & 35 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
name: CI

"on": [push, pull_request]
env:
# Default Python version used for all jobs other than test, which uses a
# matrix of supported versions. Quote the version to avoid interpretation as
# a floating point number.
PYTHON_VERSION: "3.12"

"on":
merge_group: {}
pull_request: {}
push:
branches-ignore:
# These should always correspond to pull requests, so ignore them for
# the push trigger and let them be triggered by the pull_request
# trigger, avoiding running the workflow twice. This is a minor
# optimization so there's no need to ensure this is comprehensive.
- "dependabot/**"
- "gh-readonly-queue/**"
- "renovate/**"
- "tickets/**"
- "u/**"
tags:
- "*"

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history for setuptools_scm

Expand All @@ -37,23 +58,21 @@ jobs:
npm install -g gulp-cli
npm install

- name: Python install
run: |
python -m pip install --upgrade pip
pip install .[dev]
pip install tox

- name: Build assets
run: gulp assets

- name: Run tests
run: tox run -e py,lint,typing
- name: Run tox
uses: lsst-sqre/run-tox@v1
with:
python-version: ${{ matrix.python }}
tox-envs: "lint,py,typing"
tox-plugins: tox-uv

demo:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history for setuptools_scm

Expand All @@ -65,12 +84,12 @@ jobs:
pandoc --version

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: ${{ env.PYTHON_VERSION }}

- name: Set up node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

Expand All @@ -79,44 +98,77 @@ jobs:
npm install -g gulp-cli
npm install

- name: Python install
run: |
python -m pip install --upgrade pip
pip install .[dev]
pip install tox

- name: Build assets
run: gulp assets

- name: Build demo pages
run: tox run -e demo
uses: lsst-sqre/run-tox@v1
with:
python-version: ${{ env.PYTHON_VERSION }}
tox-envs: "demo"
tox-plugins: tox-uv

- name: Upload demo artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: article-demo
path: _build/article-demo

pypi:
test-packaging:

name: Test packaging
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [test]
if: startsWith(github.ref, 'refs/tags/')

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history for setuptools_scm

- name: Install Pandoc
- name: Set up node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: NPM install
run: |
downloadUrl="https://github.com/jgm/pandoc/releases/download/2.19.2/pandoc-2.19.2-1-amd64.deb"
wget --no-verbose "$downloadUrl"
sudo dpkg -i "${downloadUrl##*/}"
pandoc --version
npm install -g gulp-cli
npm install

- name: Build assets
run: gulp assets

- name: Build and publish
uses: lsst-sqre/build-and-publish-to-pypi@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
upload: false

pypi:

# This job requires set up:
# 1. Set up a trusted publisher for PyPI
# 2. Set up a "pypi" environment in the repository
# See https://github.com/lsst-sqre/build-and-publish-to-pypi
name: Upload release to PyPI
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [test-packaging]
environment:
name: pypi
url: https://pypi.org/p/example
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history for setuptools_scm

- name: Set up node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

Expand All @@ -129,7 +181,6 @@ jobs:
run: gulp assets

- name: Build and publish
uses: lsst-sqre/build-and-publish-to-pypi@v1
uses: lsst-sqre/build-and-publish-to-pypi@v2
with:
pypi-token: ${{ secrets.PYPI_SQRE_ADMIN }}
python-version: "3.11"
python-version: ${{ env.PYTHON_VERSION }}
100 changes: 100 additions & 0 deletions .github/workflows/periodic-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# This is a separate run of the Python test suite that doesn't cache the tox
# environment and runs from a schedule. The purpose is to test compatibility
# with the latest versions of dependencies.

name: Periodic CI

env:
# Default Python version used for all jobs other than test, which uses a
# matrix of supported versions. Quote the version to avoid interpretation as
# a floating point number.
PYTHON_VERSION: "3.12"

"on":
schedule:
- cron: "0 12 * * 1"
workflow_dispatch: {}

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
python:
- "3.11"
- "3.12"

steps:
- uses: actions/checkout@v4

- name: Set up node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: NPM install
run: |
npm install -g gulp-cli
npm install

- name: Build assets
run: gulp assets

- name: Run tests in tox
uses: lsst-sqre/run-tox@v1
with:
python-version: ${{ matrix.python }}
tox-envs: "lint,typing,py"
tox-plugins: tox-uv
use-cache: false

- name: Report status
if: failure()
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
notify_when: "failure"
notification_title: "Periodic test for {repo} failed"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK }}

test-packaging:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [test]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history for setuptools_scm

- name: Set up node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: NPM install
run: |
npm install -g gulp-cli
npm install

- name: Build assets
run: gulp assets

- name: Build and publish
uses: lsst-sqre/build-and-publish-to-pypi@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
upload: false

- name: Report status
if: failure()
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
notify_when: "failure"
notification_title: "Periodic packaging test for {repo} failed"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK }}
30 changes: 10 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,16 @@ repos:
- id: rst-linter
files: (README\.rst)|(CHANGELOG\.rst)

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
hooks:
- id: isort
additional_dependencies:
- toml
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
- id: black

- repo: https://github.com/asottile/blacken-docs
rev: 1.14.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.3.0]
args: [-l, "79", -t, py37]

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
- id: blacken-docs
additional_dependencies: [black==24.3.0]
args: [-l, '79', -t, py312]
Loading
Loading