Skip to content

Commit

Permalink
Update dependencies and tooling (#251)
Browse files Browse the repository at this point in the history
- Fixes CI pipelines that were broken due to the [deprecated
`set-output`
command](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/)
- Drops support for Python 3.6-3.8
- Updates dependencies, pre-commit hooks and GitHub Actions
- Adds `mkdocs` as a dev dependency to build documentation locally
- Adds `pytest-xdist` as a dev dependency to run tests in parallel
- Removes `pytest-lazy-fixture` as a dev dependency since it [does not
support `pytest`
8](TvoroG/pytest-lazy-fixture#65)
- Removes `tox` as a dev dependency
- Migrates code formatting and linting to ruff
  • Loading branch information
klane authored Oct 14, 2024
1 parent 6ff5261 commit 9e317e9
Show file tree
Hide file tree
Showing 22 changed files with 1,539 additions and 1,281 deletions.
18 changes: 0 additions & 18 deletions .deepsource.toml

This file was deleted.

11 changes: 3 additions & 8 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
directory: /
schedule:
interval: monthly
time: "00:00"
timezone: America/Los_Angeles
open-pull-requests-limit: 99
assignees:
- klane
labels:
- dependencies
- actions

- package-ecosystem: pip
directory: "/"
directory: /
schedule:
interval: monthly
time: "00:00"
timezone: America/Los_Angeles
open-pull-requests-limit: 99
assignees:
- klane
labels:
Expand Down
62 changes: 7 additions & 55 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Quality

on:
push:
branches: [master]
branches:
- main
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
# every Sunday at midnight
schedule:
- cron: '0 0 * * 0'

Expand All @@ -16,68 +16,20 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v3
with:
languages: python
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v1

linting:
name: Linting
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/[email protected]

- name: Set up Python
uses: actions/[email protected]

- name: Hash Python version
id: hash
run: echo ::set-output name=hash::$(python --version | sha256sum | cut -d' ' -f1)

- name: Restore cache
uses: actions/[email protected]
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ steps.hash.outputs.hash }}|${{ hashFiles('.pre-commit-config.yaml') }}

- name: Run pre-commit
uses: pre-commit/[email protected]

safety:
name: Safety
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/[email protected]

- name: Set up Python
uses: actions/[email protected]

- name: Install Poetry
uses: Gr1N/setup-poetry@v7

- name: Install Safety
run: pip install safety

- name: Check dependencies
run: poetry export --dev --format requirements.txt | safety check --stdin --ignore=39462
uses: github/codeql-action/analyze@v3

slack:
name: Slack
runs-on: ubuntu-latest
needs: [analyze, linting, safety]
needs: analyze

steps:
- name: Send Slack message
Expand Down
92 changes: 71 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,107 @@ name: Release
on:
push:
tags:
- v*
- v*.*.*
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies and build project
run: |
poetry install --without docs,test
poetry build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: poetry-build
path: dist/

github:
name: GitHub
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout
uses: actions/checkout@v2.3.3
uses: actions/checkout@v4

- name: Get tag
id: tag
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: poetry-build
path: dist

- name: Get changes
if: github.event_name == 'push'
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/v}
tag=${GITHUB_REF#refs/tags/v}
pattern="0,/$tag/d;/[0-9]\+\.[0-9]\+\.[0-9]\+/Q"
sed $pattern CHANGELOG.md | head -n -1 | tail -n +2 > RELEASE.md
cat RELEASE.md
- name: Get changes
id: changelog
if: github.event_name == 'workflow_dispatch'
run: |
pattern='0,/${{ steps.tag.outputs.tag }}/d;/[0-9]\+\.[0-9]\+\.[0-9]\+/Q'
pattern='0,/[0-9]\+\.[0-9]\+\.[0-9]\+/d;/[0-9]\+\.[0-9]\+\.[0-9]\+/Q'
sed $pattern CHANGELOG.md | head -n -1 | tail -n +2 > RELEASE.md
cat RELEASE.md
- name: Create release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v2
if: success() && github.event_name == 'push'
with:
body_path: RELEASE.md
prerelease: ${{ contains(github.ref, '-') }}
files: dist/*

pypi:
name: PyPI
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout
uses: actions/checkout@v2.3.3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/[email protected]

- name: Install Poetry
uses: Gr1N/setup-poetry@v7
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: poetry-build
path: dist

- name: Install dependencies
run: poetry install --no-dev
- name: Install poetry
run: pipx install poetry

- name: Build project
run: poetry build
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Publish to PyPI
if: success() && github.event_name == 'push'
run: poetry publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish

- name: Publish to TestPyPI
if: success() && github.event_name == 'workflow_dispatch'
run: poetry publish -r test-pypi
env:
POETRY_REPOSITORIES_TEST_PYPI_URL: https://test.pypi.org/legacy/
POETRY_PYPI_TOKEN_TEST_PYPI: ${{ secrets.TEST_PYPI_TOKEN }}
86 changes: 36 additions & 50 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,70 @@ name: Tests
on:
push:
branches:
- '*'
paths-ignore:
- 'docs/**'
- '**.md'
- main
pull_request:
paths-ignore:
- 'docs/**'
- '**.md'

jobs:
test:
name: '${{ matrix.os_name }}: Python ${{ matrix.python }}'
runs-on: ${{ matrix.os }}
name: ${{ matrix.os.name }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os.image }}
defaults:
run:
shell: bash

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: [3.6, 3.7, 3.8, 3.9]
include:
- os: ubuntu-latest
os_name: Linux
poetry_cache: ~/.cache/pypoetry

- os: macos-latest
os_name: macOS
poetry_cache: ~/Library/Caches/pypoetry

- os: windows-latest
os_name: Windows
poetry_cache: ~\AppData\Local\pypoetry\Cache
os:
- name: Ubuntu
image: ubuntu-latest
- name: macOS aarch64
image: macos-latest
- name: macOS x86_64
image: macos-13
- name: Windows
image: windows-latest
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
fail-fast: false

steps:
- name: Checkout
uses: actions/[email protected]

- name: Set up Python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python }}

- name: Install Poetry
uses: Gr1N/setup-poetry@v7
uses: actions/checkout@v4

- name: Write environment information to a file
run: |
pwd > environment
python --version >> environment
- name: Install poetry
run: pipx install poetry

- name: Restore cache
uses: actions/[email protected]
if: runner.os != 'Windows'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
path: ${{ matrix.poetry_cache }}
key: poetry|${{ hashFiles('environment') }}|${{ hashFiles('poetry.lock') }}
python-version: ${{ matrix.python-version }}
cache: poetry

- name: Install dependencies
run: poetry install
run: |
poetry install
pip install pytest-github-actions-annotate-failures
- name: Run tests
run: poetry run pytest tests/ --cov=jekyllnb

- name: Generate coverage report
run: poetry run coverage xml
run: poetry run pytest --cov-report xml:coverage.xml

- name: Upload coverage report
uses: codecov/codecov-action@v2.1.0
uses: codecov/codecov-action@v4
if: success()
with:
file: coverage.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml

- name: Send Slack message on failure
uses: lazy-actions/[email protected]
if: failure()
with:
type: ${{ job.status }}
job_name: '${{ runner.os }} :snake: ${{ matrix.python }} Tests'
job_name: '${{ runner.os }} :snake: ${{ matrix.python-version }} Tests'
url: ${{ secrets.SLACK_WEBHOOK }}
commit: true
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ dist/

# pyenv version file
.python-version

# docs site
site/
Loading

0 comments on commit 9e317e9

Please sign in to comment.