Skip to content

Commit

Permalink
Merge branch 'pre_commit_additions' of github.com:CyclingNinja/packag…
Browse files Browse the repository at this point in the history
…e-template into pre_commit_additions
  • Loading branch information
CyclingNinja committed Feb 28, 2024
2 parents aad3e84 + 73ea77e commit d84b458
Show file tree
Hide file tree
Showing 19 changed files with 434 additions and 79 deletions.
9 changes: 6 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def bake_examples(cookies):
"""
Examples on.
"""
result = cookies.bake(extra_context={"include_example_code": "y"})
result = cookies.bake(extra_context={"include_example_code": "y",
"author_name": "test"})
return _handle_cookiecutter_errors(result)


Expand All @@ -74,7 +75,8 @@ def bake_examples_compiled(cookies):
Examples on.
"""
result = cookies.bake(extra_context={"include_example_code": "y",
"use_compiled_extensions": "y"})
"use_compiled_extensions": "y",
"author_name": "test"})
return _handle_cookiecutter_errors(result)


Expand All @@ -85,5 +87,6 @@ def bake_examples_compiled_dev_version(cookies):
"""
result = cookies.bake(extra_context={"include_example_code": "y",
"use_compiled_extensions": "y",
"enable_dynamic_dev_versions": "y"})
"enable_dynamic_dev_versions": "y",
"author_name": "test"})
return _handle_cookiecutter_errors(result)
7 changes: 7 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ envlist =
build-docs

[testenv]
pass_env =
# Custom compiler locations (such as ccache)
CC
# Location of locales (needed by sphinx on some systems)
LOCALE_ARCHIVE
# If the user has set a LC override we should follow it
LC_ALL
description = render the template and run all the rendered tox environments
skip_install = true
deps =
Expand Down
27 changes: 27 additions & 0 deletions {{ cookiecutter.package_name }}/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[flake8]
ignore =
# missing-whitespace-around-operator
E225
# missing-whitespace-around-arithmetic-operator
E226
# line-too-long
E501
# unused-import
F401
# undefined-local-with-import-star
F403
# redefined-while-unused
F811
# Line break occurred before a binary operator
W503,
# Line break occurred after a binary operator
W504
max-line-length = 110
exclude =
.git
__pycache__
docs/conf.py
build
{{ cookiecutter.package_name }}/__init__.py,
rst-directives =
plot
129 changes: 129 additions & 0 deletions {{ cookiecutter.package_name }}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{% set default_python = '3.10' %}
name: CI

on:
push:
branches:
- 'main'
- '*.*'
- '!*backport*'
tags:
- 'v*'
- '!*dev*'
- '!*pre*'
- '!*post*'
pull_request:
# Allow manual runs through the web UI
workflow_dispatch:

concurrency:
group: {{ '${{ github.workflow }}-${{ github.ref }}' }}
cancel-in-progress: true

jobs:
core:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
submodules: false
coverage: codecov
toxdeps: tox-pypi-filter
envs: |
- linux: py312
secrets:
CODECOV_TOKEN: {{ '${{ secrets.CODECOV_TOKEN }}' }}

sdist_verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '{{ default_python }}'
- run: python -m pip install -U --user build
- run: python -m build . --sdist
- run: python -m pip install -U --user twine
- run: python -m twine check dist/*

test:
needs: [core, sdist_verify]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
submodules: false
coverage: codecov
toxdeps: tox-pypi-filter
posargs: -n auto
envs: |
- windows: py311
- macos: py310
- linux: py310-oldestdeps
secrets:
CODECOV_TOKEN: {{ '${{ secrets.CODECOV_TOKEN }}' }}

docs:
needs: [core]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
default_python: '{{ default_python }}'
submodules: false
pytest: false
toxdeps: tox-pypi-filter
envs: |
- linux: build_docs
cron:
if: |
github.event_name == 'workflow_dispatch' || (
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'Run cron CI')
)
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
default_python: '{{ default_python }}'
submodules: false
coverage: codecov
toxdeps: tox-pypi-filter
envs: |
- linux: py311-devdeps
secrets:
CODECOV_TOKEN: {{ '${{ secrets.CODECOV_TOKEN }}' }}

{% if cookiecutter.use_compiled_extensions == 'y' -%}
publish:
# Build wheels when pushing to any branch except main
# publish.yml will only publish if tagged ^v.*
if: |
(
github.event_name != 'pull_request' && (
github.ref_name != 'main' ||
github.event_name == 'workflow_dispatch'
)
) || (
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'Run publish')
)
needs: [test, docs]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish.yml@main
with:
sdist: true
test_extras: 'tests'
test_command: 'pytest -p no:warnings --doctest-rst --pyargs {{ cookiecutter.module_name }}'
submodules: false
targets: |
- cp3{9,10,11,12}-manylinux*_x86_64
- cp3{9,10,11,12}-macosx_x86_64
- cp3{9,10,11,12}-macosx_arm64
- cp3{9,10,11,12}-win_amd64
secrets:
pypi_token: {{ '${{ secrets.pypi_token }}' }}
{%- else -%}
publish_pure:
needs: [test, docs]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@main
with:
python-version: '{{ default_python }}'
test_extras: 'tests'
test_command: 'pytest -p no:warnings --doctest-rst --pyargs {{ cookiecutter.module_name }}'
submodules: false
secrets:
pypi_token: {{ '${{ secrets.pypi_token }}' }}
{%- endif %}
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
"""
This template is taken from the cruft example code, for further information please see:
https://cruft.github.io/cruft/#automating-updates-with-github-actions
"""
# This template is taken from the cruft example code, for further information please see:
# https://cruft.github.io/cruft/#automating-updates-with-github-actions
name: Automatic Update from package template
permissions:
contents: write
pull-requests: write

on:
pull_request:
branches:
main
# Allow manual runs through the web UI
workflow_dispatch:
schedule:
# ┌───────── minute (0 - 59)
# │ ┌───────── hour (0 - 23)
# │ │ ┌───────── day of the month (1 - 31)
# │ │ │ ┌───────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────── day of the week (0 - 6 or SUN-SAT)
- cron: '0 7 * * 1' # Every Monday at 7am UTC

jobs:
update:
runs-on: ubuntu-latest
Expand All @@ -19,25 +24,25 @@ jobs:
matrix:
include:
- add-paths: .
body: Use this to merge the changes to the repo
body: apply the changes to this repo.
branch: cruft/update
commit-message: "Automate package template update"
title: Incoming updates from package template
commit-message: "Automatic package template update"
title: Updates from the package template
- add-paths: .cruft.json
body: Use this to reject changes in the repo
body: reject these changes for this repo.
branch: cruft/reject
commit-message: "Chore: reject this cruft update"
commit-message: "Reject this package template update"
title: Reject new updates from package template

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"

- name: Install Cruft
run: pip3 install cruft
run: python -m pip install cruft

- name: Check if update is available
continue-on-error: false
Expand All @@ -57,15 +62,15 @@ jobs:
- name: Run update if available
if: steps.check.outputs.has_changes == '1'
run: |
git config --global user.email "gromit@cruft.com"
git config --global user.name "Gromit"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
cruft update --skip-apply-ask --refresh-private-variables
git restore --staged
git restore --staged .
- name: Create pull request
if: steps.check.output.has_changes == '1'
uses: peter-evans/create-pull-request@v4
if: steps.check.outputs.has_changes == '1'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: ${{ matrix.add-paths }}
Expand All @@ -75,5 +80,5 @@ jobs:
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 Package Template
This is an autogenerated PR, which will ${{ matrix.body }}.
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template
Loading

0 comments on commit d84b458

Please sign in to comment.