Skip to content

Commit

Permalink
Update project using latest versions of the templates
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Oct 15, 2024
1 parent f399fc9 commit 30376a2
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 77 deletions.
96 changes: 49 additions & 47 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# ---- Default values to be merged into tasks ----

env:
LC_ALL: C.UTF-8
LANG: C.UTF-8
LC_ALL: C
LC_CTYPE: UTF-8
LANG: C
PIP_CACHE_DIR: ${CIRRUS_WORKING_DIR}/.cache/pip
PRE_COMMIT_HOME: ${CIRRUS_WORKING_DIR}/.cache/pre-commit
CIRRUS_ARTIFACT_URL: https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}
# Coveralls configuration
CI_NAME: cirrus-ci
CI_BRANCH: ${CIRRUS_BRANCH}
Expand Down Expand Up @@ -49,12 +51,16 @@ env:
alias: test
depends_on: [build]
<<: *task-template
dist_cache: {folder: dist, fingerprint_script: echo $CIRRUS_BUILD_ID} # download
download_artifact_script: &download-artifact
- curl -L -O ${CIRRUS_ARTIFACT_URL}/build/upload/dist.tar.gz
- tar xzf dist.tar.gz
- rm dist.tar.gz
test_script:
- tox --installpkg dist/*.whl -- -rfEx --durations 10 --color yes
submit_coverage_script:
- pipx run coverage xml -o coverage.xml
- pipx run coveralls --submit coverage.xml
- pipx run 'coveralls<4' --submit coverage.xml
# ^-- https://github.com/TheKevJames/coveralls-python/issues/434

# Deep clone script for POSIX environments (required for setuptools-scm)
.clone_script: &clone |
Expand All @@ -70,113 +76,108 @@ env:
# ---- CI Pipeline ----

build_task:
name: build (Linux - 3.10)
name: build and check (Linux - 3.11)
alias: build
container: {image: "python:3.10-bullseye"}
container: {image: "python:3.11-bullseye"}
clone_script: *clone
dist_cache: # build once and upload to be used by other tasks
folder: dist
fingerprint_script: echo $CIRRUS_BUILD_ID
reupload_on_changes: true
<<: *task-template
install_script: pip install tox
build_script: tox -e clean,build

check_task:
name: check (Linux - 3.11)
alias: check
depends_on: [build]
container: {image: "python:3.11-bullseye"} # most recent => better types
dist_cache: {folder: dist, fingerprint_script: echo $CIRRUS_BUILD_ID} # download
<<: *task-template
install_script: pip install tox
install_script: pip install tox pre-commit
build_script:
- tox -e clean,build
- tar czf dist.tar.gz dist
check_script: tox --installpkg dist/*.whl -e lint,typecheck
upload_artifacts:
path: dist.tar.gz

linux_task:
matrix:
- name: test (Linux - 3.7)
container: {image: "python:3.7-bullseye"}
- name: test (Linux - 3.8)
container: {image: "python:3.8-bullseye"}
- name: test (Linux - 3.9)
container: {image: "python:3.9-bullseye"}
container: {image: "python:3.8-bookworm"}
- name: test (Linux - 3.10)
container: {image: "python:3.10-bullseye"}
- name: test (Linux - 3.11)
container: {image: "python:3.11-bullseye"}
container: {image: "python:3.10-bookworm"}
skip: $BRANCH !=~ "^(main|master)$"
- name: test (Linux - 3.12)
container: {image: "python:3.12-rc-bullseye"}
allow_failures: true # Experimental
container: {image: "python:3.12-bookworm"}
# - name: test (Linux - 3.13)
# container: {image: "python:3.13-rc-bookworm"}
# allow_failures: true # Experimental
install_script:
- python -m pip install --upgrade pip tox pipx
<<: *test-template
alias: base-test

mamba_task:
name: test (Linux - mambaforge)
container: {image: "condaforge/mambaforge"}
install_script: # Overwrite template
- mamba install -y pip pipx tox
- mamba install -y pip pipx tox curl
<<: *test-template
depends_on: [base-test]

macos_task:
name: test (macOS - brew)
macos_instance:
image: ghcr.io/cirruslabs/macos-monterey-xcode
brew_cache: {folder: "$HOME/Library/Caches/Homebrew"}
install_script: brew install python tox pipx
image: ghcr.io/cirruslabs/macos-runner:sonoma
env:
PATH: "/opt/homebrew/opt/python/libexec/bin:${PATH}"
brew_cache: {folder: "$HOME/Library/Caches/Homebrew"}
install_script: brew install python tox pipx
<<: *test-template
depends_on: [build, base-test]

freebsd_task:
name: test (freebsd - 3.9)
freebsd_instance: {image_family: freebsd-13-1}
name: test (freebsd - 3.11)
freebsd_instance: {image_family: freebsd-14-0}
install_script:
- pkg remove -y python lang/python
- pkg install -y git python39 py39-pip py39-gdbm py39-sqlite3 py39-tox py39-pipx py39-tomli
- ln -s /usr/local/bin/python3.9 /usr/local/bin/python
- pkg install -y git python311 py311-pip py311-gdbm py311-sqlite3 py311-tox py311-tomli py311-pipx
- ln -s /usr/local/bin/python3.11 /usr/local/bin/python
<<: *test-template
depends_on: [build, base-test]

windows_task:
name: test (Windows - 3.9.10)
name: test (Windows - 3.12.5)
windows_container:
image: "cirrusci/windowsservercore:2019"
os_version: 2019
env:
CIRRUS_SHELL: bash
PATH: /c/Python39:/c/Python39/Scripts:/c/tools:${PATH}
PATH: /c/Python312:/c/Python312/Scripts:/c/tools:${PATH}
install_script:
# Activate long file paths to avoid some errors
- ps: New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
- choco install -y --no-progress python3 --version=3.9.10 --params "/NoLockdown"
- choco install -y --no-progress python3 --version=3.12.5 --params "/NoLockdown"
- choco install -y --no-progress curl
- pip install --upgrade certifi
- python -m pip install -U pip tox pipx
<<: *test-template
depends_on: [build, base-test]

finalize_task:
container: {image: "python:3.10-bullseye"}
depends_on: [test]
<<: *task-template
install_script: pip install coveralls
install_script: pip install 'coveralls<4'
# ^-- https://github.com/TheKevJames/coveralls-python/issues/434
finalize_coverage_script: coveralls --finish

linkcheck_task:
name: linkcheck (Linux - 3.10)
only_if: $BRANCH =~ "^(main|master)$"
container: {image: "python:3.10-bullseye"}
depends_on: [finalize]
allow_failures: true
dist_cache: {folder: dist, fingerprint_script: echo $CIRRUS_BUILD_ID} # download
<<: *task-template
install_script: pip install tox
download_artifact_script: *download-artifact
linkcheck_script: tox --installpkg dist/*.whl -e linkcheck -- -q

publish_task:
name: publish (Linux - 3.10)
container: {image: "python:3.10-bullseye"}
depends_on: [check, build, test]
container: {image: "python:3.10-bookworm"}
depends_on: [build, base-test, test]
only_if: $CIRRUS_TAG =~ 'v\d.*' && $CIRRUS_USER_PERMISSION == "admin"
<<: *task-template
dist_cache: {folder: dist, fingerprint_script: echo $CIRRUS_BUILD_ID} # download
env:
TWINE_REPOSITORY: pypi
TWINE_USERNAME: __token__
Expand All @@ -187,6 +188,7 @@ publish_task:
# - https://pypi.org/help/#apitoken
# - https://cirrus-ci.org/guide/writing-tasks/#encrypted-variables
install_script: pip install tox
download_artifact_script: *download-artifact
publish_script:
- ls dist/*
- tox -e publish
34 changes: 19 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ on:
# (useful to check if updates on dependencies break the package)
- cron: '0 0 1,16 * *'

permissions:
contents: read

concurrency:
group: >-
${{ github.workflow }}-${{ github.ref_type }}-
Expand All @@ -29,13 +32,12 @@ jobs:
outputs:
wheel-distribution: ${{ steps.wheel-distribution.outputs.path }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with: {fetch-depth: 0} # deep clone for setuptools-scm
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
id: setup-python
with: {python-version: "3.11"}
with: {python-version: "3.12"}
- name: Run static analysis and format checkers
run: >-
pipx run --python '${{ steps.setup-python.outputs.python-path }}'
tox -e lint,typecheck
- name: Build package distribution files
Expand All @@ -48,7 +50,7 @@ jobs:
- name: Store the distribution files for use in other stages
# `tests` and `publish` will use the same pre-built distributions,
# so we make sure to release the exact same package that was tested
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: python-distribution-files
path: dist/
Expand All @@ -59,21 +61,21 @@ jobs:
strategy:
matrix:
python:
- "3.7" # oldest Python supported by PSF
- "3.11" # newest Python that is stable
- "3.8" # oldest Python supported by PSF
- "3.13" # newest Python that is stable
platform:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ matrix.python }}
- name: Retrieve pre-built distribution files
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with: {name: python-distribution-files, path: dist/}
- name: Run tests
run: >-
Expand All @@ -86,7 +88,7 @@ jobs:
uses: coverallsapp/github-action@master
with:
path-to-lcov: coverage.lcov
github-token: ${{ secrets.github_token }}
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: ${{ matrix.platform }} - py${{ matrix.python }}
parallel: true

Expand All @@ -105,12 +107,14 @@ jobs:
# needs: finalize
# if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
# runs-on: ubuntu-latest
# permissions:
# contents: write
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# with: {python-version: "3.11"}
# - uses: actions/checkout@v4
# - uses: actions/setup-python@v5
# with: {python-version: "3.12"}
# - name: Retrieve pre-built distribution files
# uses: actions/download-artifact@v3
# uses: actions/download-artifact@v4
# with: {name: python-distribution-files, path: dist/}
# - name: Publish Package
# env:
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ __pycache__/*
*/.ipynb_checkpoints/*
.DS_Store

# Automatically generated by setuptools-scm
_version.py

# Project files
.ropeproject
.project
Expand Down
22 changes: 11 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exclude: '^docs/conf.py'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
Expand All @@ -18,13 +18,13 @@ repos:
args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.17.0
hooks:
- id: pyupgrade
args: ['--py37-plus']
args: ['--py38-plus']

- repo: https://github.com/PyCQA/autoflake
rev: v2.0.0
rev: v2.3.1
hooks:
- id: autoflake
args: [
Expand All @@ -34,29 +34,29 @@ repos:
]

- repo: https://github.com/PyCQA/isort
rev: 5.11.4
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 22.12.0
rev: stable
hooks:
- id: black
language_version: python3

- repo: https://github.com/asottile/blacken-docs
rev: 1.13.0
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.19.0
hooks:
- id: blacken-docs
additional_dependencies: [black]
additional_dependencies: [black==23.*]

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.3.0
hooks:
- id: codespell
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exclude =
[pyscaffold]
# PyScaffold's parameters when the project was created.
# This will be used when updating. Do not change!
version = 4.4
version = 4.6
package = texted
extensions =
cirrus
Expand Down

0 comments on commit 30376a2

Please sign in to comment.