Skip to content

Commit

Permalink
Manage pyrainbird in cruft (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
allenporter committed May 12, 2024
1 parent 52dca04 commit 9b97a53
Show file tree
Hide file tree
Showing 15 changed files with 280 additions and 125 deletions.
17 changes: 17 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"template": "https://github.com/allenporter/cookiecutter-python",
"commit": "fa32728e64c6946fba7ea2477e77def141582b3b",
"checkout": null,
"context": {
"cookiecutter": {
"full_name": "Allen Porter",
"email": "allen.porter@gmail.com",
"github_username": "allenporter",
"project_name": "pyrainbird",
"description": "Rain Bird Controller",
"version": "6.0.1",
"_template": "https://github.com/allenporter/cookiecutter-python"
}
},
"directory": null
}
File renamed without changes.
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.
44 changes: 32 additions & 12 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,45 @@ name: Lint
on:
push:
branches:
- main
- main
pull_request:
branches:
- main
- main

env:
PYTHON_VERSION: 3.12

jobs:
build:

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

steps:
- uses: actions/checkout@v4
- uses: codespell-project/actions-codespell@master
- name: Run yamllint
uses: ibiqlik/action-yamllint@v3
with:
file_or_dir: "./"
config_file: "./.yaml-lint.yaml"
strict: true
- uses: chartboost/ruff-action@v1.0.0
- 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 .
21 changes: 10 additions & 11 deletions .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:
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 ./pyrainbird -o docs/
- name: Setup Pages
uses: actions/configure-pages@v5
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@v1.8.14
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
34 changes: 0 additions & 34 deletions .github/workflows/python-app.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/python-publish.yaml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Test

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: Test with pytest
run: |
pytest --cov=pyrainbird --cov-report=term-missing
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS,PYTHON
fail_ci_if_error: true
verbose: true
Loading

0 comments on commit 9b97a53

Please sign in to comment.