Skip to content

Commit

Permalink
build: update pyproject.toml, ruff, tox, actions, trusted publish
Browse files Browse the repository at this point in the history
  • Loading branch information
martibosch committed Mar 28, 2024
1 parent 7d9c247 commit c6e3d98
Show file tree
Hide file tree
Showing 33 changed files with 434 additions and 415 deletions.
10 changes: 0 additions & 10 deletions .bumpversion.cfg

This file was deleted.

6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATES/bug.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
* detectree version:
* Python version:
* Operating system:
- detectree version:
- Python version:
- Operating system:

### Description

Expand Down
11 changes: 11 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Config for Dependabot updates. See Documentation here:
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
# Update GitHub actions in workflows
- package-ecosystem: "github-actions"
directory: "/"
# Check for updates to GitHub Actions every weekday
schedule:
interval: "daily"
6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Before you proceed, review the contributing guidelines in the "Pull request guid

In this pull request, please include:

* a reference to related issue(s)
* a description of the changes proposed in the pull request
* an example code snippet illustrating usage of the new functionality
- a reference to related issue(s)
- a description of the changes proposed in the pull request
- an example code snippet illustrating usage of the new functionality
69 changes: 0 additions & 69 deletions .github/workflows/dev.yml

This file was deleted.

96 changes: 96 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: release

on:
push:
tags:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: build sdist and wheel
run: pipx run build

- uses: actions/upload-artifact@v4
with:
path: dist/*

- name: check metadata
run: pipx run twine check dist/*

publish_dev_build:
needs: [build]
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://pypi.org/p/detectree
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: artifact
path: dist

- name: publish to test pypi
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true

release:
needs: [publish_dev_build]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/detectree
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
# see https://github.com/softprops/action-gh-release/issues/236
contents: write

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

- name: update changelog
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
tag: ${{ github.ref_name }}

- name: create Release
uses: ncipollo/release-action@v1.12.0
with:
allowUpdates: true
draft: false
makeLatest: true
name: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ github.token }}

- uses: actions/download-artifact@v4
with:
name: artifact
path: dist

- name: publish to pypi
uses: pypa/gh-action-pypi-publish@release/v1

- name: commit changelog
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]'
file_pattern: CHANGELOG.md
58 changes: 0 additions & 58 deletions .github/workflows/release_to_pypi.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: tests

on:
push:
branches: [main]
pull_request:
branches:
- "*"

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- os: macos-latest
python-version: "3.12"
- os: windows-latest
python-version: "3.12"

runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4

- uses: mamba-org/setup-micromamba@v1
with:
environment-name: test-env
create-args: >-
python=${{ matrix.python-version }}
pip
- name: install dependencies
run: pip install tox tox-gh-actions

- name: test with tox
run: tox
env:
CONDA_EXE: mamba

- name: upload coverage reports to Codecov
uses: codecov/codecov-action@v3

- name: list files
run: ls -l .
59 changes: 38 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,55 @@
exclude: 'docs|node_modules|migrations|.tox'
default_stages: [commit]
fail_fast: true
ci:
autofix_commit_msg: "style(pre-commit.ci): auto fixes from pre-commit hooks"
autoupdate_commit_msg: "style(pre-commit.ci): pre-commit autoupdate"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.18.2
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.15.0
hooks:
- id: check-github-workflows
- id: commitizen

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
additional_dependencies: [prettier, prettier-plugin-toml, prettier-plugin-ini]
types: ["ini", "toml", "yaml"]

- repo: https://github.com/psf/black
rev: 22.10.0
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17 # Use the ref you want to point at
hooks:
- id: black
- id: mdformat
# Optionally add plugins
additional_dependencies:
- mdformat-gfm
- mdformat-black

- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: isort
- id: yamllint
args: ["-d relaxed"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.0
hooks:
- id: check-github-workflows

- repo: https://gitlab.com/pycqa/flake8
rev: 5.0.4
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: flake8
additional_dependencies: [flake8-isort]
- id: pyupgrade

- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: pydocstyle
files: ^detectree
- id: ruff
args: [ --fix ]
- id: ruff-format
Loading

0 comments on commit c6e3d98

Please sign in to comment.