Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: v0.7.0-43-g7bef3d8
_commit: v0.7.0-84-g3d4712c
_src_path: https://github.com/usnistgov/cookiecutter-nist-python.git
command_line_interface: none
conda_channel: conda-forge
Expand Down
44 changes: 44 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
documentation:
- changed-files:
- any-glob-to-any-file:
- "docs/**/*"
- "examples/**/*"
- "README.md"

dependencies:
- changed-files:
- any-glob-to-any-file:
- ".pre-commit-config.yml"
- "requirements/**/*"
- "uv.lock"

github_actions:
- changed-files:
- any-glob-to-any-file:
- ".github/**/*"

template_update:
- changed-files:
- any-glob-to-any-file:
- ".cruft.json"
- ".copier-answers.y*ml"

testing:
- changed-files:
- any-glob-to-any-file:
- "tests/**/*"
- "noxfile.py"

internal:
- changed-files:
- any-glob-to-any-file:
- ".editorconfig"
- ".git*"
- ".markdown*"
- ".prettier*"
- ".pylint*"
- ".taplo*"
- "justfile"
- "*ruff.toml"
- "scripts/**/*"
- "tools/**/*"
22 changes: 22 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,25 @@ changelog:
authors:
- dependabot[bot]
- pre-commit-ci[bot]
labels:
- internal

categories:
- title: Bug fixes
labels:
- bug
- title: Breaking changes
labels:
- breaking
- title: Enhancements
labels:
- enhancement
- title: Documentation
labels:
- documentation
- title: Testing
labels:
- testing
- title: Other changes
labels:
- "*"
56 changes: 56 additions & 0 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "PR checks"

on: # zizmor: ignore[dangerous-triggers]
pull_request_target:
types:
- opened
- synchronize
- reopened
- edited

permissions: {}

jobs:
validate-title:
runs-on: ubuntu-slim
permissions:
pull-requests: read
steps:
- name: Validate PR title
uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

label-from-title:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-slim
steps:
- uses: bcoe/conventional-release-labels@886f696738527c7be444262c327c89436dfb95a8 # v1.3.1
with:
type_labels:
'{"feat": "enhancement", "fix": "bug", "docs": "documentation",
"breaking": "breaking", "test": "testing"}'
ignored_types: '["build", "chore", "ci", "perf", "refactor", "style"]'
ignore_label: internal

label-from-files:
needs: label-from-title
permissions:
contents: read
pull-requests: write
issues: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.1
id: label-pr

- name: Labeler info
env:
ALL_LABELS: ${{ steps.label-pr.outputs.all-labels }}
NEW_LABELS: ${{ steps.label-pr.outputs.new-labels }}
shell: bash
run: |
echo "new labels: $NEW_LABELS"
echo "all labels: $ALL_LABELS"
16 changes: 9 additions & 7 deletions .github/workflows/copier-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
branch: copier/update
commit-message: "chore(template): accept new copier update"
title: "chore(template): accept new copier update"
- add-paths: .copier-answers.yml
body: Use this to reject the changes in this repository.
branch: copier/reject
commit-message: "chore(template): reject new copier update"
title: "chore(template): reject new copier update"
# - add-paths: .copier-answers.yml
# body: Use this to reject the changes to this repository.
# branch: copier/reject
# commit-message: "chore(template): reject new copier update"
# title: "chore(template): reject new copier update"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
Expand Down Expand Up @@ -69,11 +69,13 @@ jobs:
id: cpr
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
# token: ${{ secrets.PAT }} # use when have permissions
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.PAT }}
add-paths: ${{ matrix.add-paths }}
commit-message: ${{ matrix.commit-message }}
title: ${{ matrix.title }}
labels: |
internal
template_update
branch: ${{ matrix.branch }}
delete-branch: true
# branch-suffix: timestamp # If want commit per run (instead of per workflow)
Expand Down
14 changes: 12 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ list-dist:
unzip -vl dist/*.whl
du -skhc dist/*

# * GitHub cli -----------------------------------------------------------------

# sync labels with template
[group("tools")]
gh-label-sync:
gh label clone usnistgov/cookiecutter-nist-python

# * Other tools ----------------------------------------------------------------

# Run ipython with ephemeral current environment
Expand All @@ -304,8 +311,11 @@ ipython *options:

# update templates
[group("tools")]
copier-update *options="-r main --trust -A":
{{ UVX_WITH_OPTS }} --with copier-template-extensions copier update {{ options }}
copier-update *options="":
{{ UVX_WITH_OPTS }} --with copier-template-extensions \
copier update --trust -A \
-r main \
{{ options }}

# create changelog snippet with scriv
[group("tools")]
Expand Down
26 changes: 24 additions & 2 deletions tools/requirements_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ def _get_default_version() -> str:
return Path(".python-version").read_text(encoding="utf-8").strip()


def _get_exclude_newer_option(cooldown_days: int) -> str:
import datetime

date = datetime.datetime.now(tz=datetime.UTC).date() - datetime.timedelta(
days=cooldown_days
)

return f"--exclude-newer={date}"


def _lock_files(
paths: Iterable[Path],
min_python_version: str,
Expand Down Expand Up @@ -160,6 +170,14 @@ def main(args: Sequence[str] | None = None) -> int:
Overridden by ``--sync``.
""",
)
_ = parser.add_argument(
"--cooldown-days",
type=int,
default=None,
help="""
Calculate ``--exclude-newer`` options from ``today`` less ``cooldown_days``.
""",
)
_ = parser.add_argument(
"--uv-options",
default="",
Expand All @@ -176,12 +194,16 @@ def main(args: Sequence[str] | None = None) -> int:

opts = parser.parse_args(args)

uv_options: list[str] = opts.uv_options
if opts.cooldown_days is not None:
uv_options.append(_get_exclude_newer_option(opts.cooldown_days))

_maybe_lock_or_sync(
lock=opts.lock,
sync=opts.sync,
sync_or_lock=opts.sync_or_lock,
upgrade=opts.upgrade,
uv_options=opts.uv_options,
uv_options=uv_options,
)

_lock_files(
Expand All @@ -190,7 +212,7 @@ def main(args: Sequence[str] | None = None) -> int:
default_python_version=_get_default_version(),
upgrade=opts.upgrade,
pip_compile_config_file=opts.pip_compile_config_file,
uv_options=opts.uv_options,
uv_options=uv_options,
)

return 0
Expand Down
Loading