Skip to content

Commit

Permalink
Manage project with cruft (#334)
Browse files Browse the repository at this point in the history
* Manage project with cruft

* Unify mypy configuration

* Remove duplicate dependencies

* Remove duplicate definitions

* Update

* Update benchmark

* Exclude tests from mypy.
  • Loading branch information
allenporter authored May 13, 2024
1 parent 156fb28 commit b47477c
Show file tree
Hide file tree
Showing 18 changed files with 396 additions and 218 deletions.
17 changes: 17 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"template": "http://github.com/allenporter/cookiecutter-python",
"commit": "09fcc9a7574cc92301d2b72ea2535fed208a2e39",
"checkout": null,
"context": {
"cookiecutter": {
"full_name": "Allen Porter",
"email": "allen.porter@gmail.com",
"github_username": "allenporter",
"project_name": "ical",
"description": "Python iCalendar implementation (rfc 2445)",
"version": "8.0.1",
"_template": "http://github.com/allenporter/cookiecutter-python"
}
},
"directory": null
}
7 changes: 4 additions & 3 deletions renovate.json5 → .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"matchUpdateTypes": ["minor", "patch"]
}
],
"pre-commit": {
"enabled": true
}
"pip_requirements": {
"fileMatch": ["requirements_dev.txt"]
},
"pre-commit": {"enabled": true}
}
34 changes: 34 additions & 0 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Python benchmarks

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "**/requirements_dev.txt"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
- name: Run benchmarks with pytest
run: |
pytest --benchmark-only
79 changes: 79 additions & 0 deletions .github/workflows/cruft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
name: Update repository with Cruft
permissions:
contents: write
pull-requests: write
on:
schedule:
- cron: "0 0 * * *"

env:
PYTHON_VERSION: 3.12

jobs:
update:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- add-paths: .
body: Use this to merge the changes to this repository.
branch: cruft/update
commit-message: "chore: accept new Cruft update"
title: New updates detected with Cruft
- add-paths: .cruft.json
body: Use this to reject the changes in this repository.
branch: cruft/reject
commit-message: "chore: reject new Cruft update"
title: Reject new updates detected with Cruft
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Cruft
run: pip3 install cruft

- name: Check if update is available
continue-on-error: false
id: check
run: |
CHANGES=0
if [ -f .cruft.json ]; then
if ! cruft check; then
CHANGES=1
fi
else
echo "No .cruft.json file"
fi
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
- name: Run update if available
if: steps.check.outputs.has_changes == '1'
run: |
git config --global user.email "allen.porter@gmail.com"
git config --global user.name "Allen Porter"
cruft update --skip-apply-ask --refresh-private-variables
git restore --staged .
- name: Create pull request
if: steps.check.outputs.has_changes == '1'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: ${{ matrix.add-paths }}
commit-message: ${{ matrix.commit-message }}
branch: ${{ matrix.branch }}
delete-branch: true
branch-suffix: timestamp
title: ${{ matrix.title }}
body: |
This is an autogenerated PR. ${{ matrix.body }}
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Cookiecutter repository.
48 changes: 31 additions & 17 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Lint

on:
Expand All @@ -8,27 +9,40 @@ on:
branches:
- main

env:
PYTHON_VERSION: 3.12

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1.0.0
- uses: codespell-project/actions-codespell@v2.0
with:
check_hidden: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
- name: Static typing with mypy
run: |
mypy --install-types --non-interactive --no-warn-unused-ignores .
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1.0.0
- uses: codespell-project/actions-codespell@v2.0
with:
check_hidden: false
- name: Run yamllint
uses: ibiqlik/action-yamllint@v3
with:
file_or_dir: "./"
config_file: "./.yaml-lint.yaml"
strict: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
cache-dependency-path: "**/requirements_dev.txt"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
- name: Static typing with mypy
run: |
mypy --install-types --non-interactive --no-warn-unused-ignores .
23 changes: 11 additions & 12 deletions .github/workflows/pages.yml → .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
# Simple workflow for deploying static content to GitHub Pages
---
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches:
- main

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
actions: read
contents: read
pages: write
id-token: write
actions: read

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

env:
PYTHON_VERSION: 3.12

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
cache-dependency-path: "**/requirements_dev.txt"
- name: Install dependencies
run: |
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
python -m pip install --upgrade pip
pip install -r requirements_dev.txt
- run: pdoc ./ical -o docs/
- name: Setup Pages
uses: actions/configure-pages@v5
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: Upload Python Package

on:
release:
types: [created]

env:
PYTHON_VERSION: 3.12

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build --user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/ical
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
32 changes: 0 additions & 32 deletions .github/workflows/python-benchmark.yaml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/python-package.yaml

This file was deleted.

Loading

0 comments on commit b47477c

Please sign in to comment.