Skip to content

Commit 39893a8

Browse files
wpk-nist-govgithub-actions[bot]
authored andcommitted
chore(template): accept new copier update
1 parent 6e650a4 commit 39893a8

12 files changed

Lines changed: 563 additions & 36 deletions

File tree

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2-
_commit: v0.7.0-130-gde18aa4
2+
_commit: v0.7.5
33
_src_path: https://github.com/usnistgov/cookiecutter-nist-python.git
44
command_line_interface: typer
55
conda_channel: conda-forge

.github/actions/setup-cached-uv-and-python/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ description:
33
Composite action to do 'actions/setup-python' and 'hynek/setup-cached-uv'
44
inputs:
55
# actions/setup-python
6-
76
python-version:
87
description: "Version to pass to actions/setup-python"
98
python-version-file:
@@ -25,7 +24,7 @@ outputs:
2524
value: ${{ steps.setup-python.outputs.cache-hit }}
2625
python-path:
2726
description: "The absolute path to the Python or PyPy executable."
28-
value: ${{ steps.setup-python.outputs.pytyhon-path }}
27+
value: ${{ steps.setup-python.outputs.python-path }}
2928

3029
runs:
3130
using: composite

.github/workflows/ci.yml

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ on:
33
push:
44
branches: [main]
55
pull_request:
6+
types:
7+
- opened
8+
- synchronize
9+
- reopened
10+
- ready_for_review
611
workflow_dispatch:
712

813
concurrency:
@@ -13,7 +18,12 @@ env:
1318
FORCE_COLOR: "3"
1419
UVX_CONSTRAINT: requirements/lock/uvx-tools.txt
1520
UVX_COMMAND: uvx -crequirements/lock/uvx-tools.txt
21+
<<<<<<< before updating
1622
EXTRA_PYTHON_VERSIONS: "pypy-3.11"
23+
=======
24+
NOX_COMMAND: uvx -crequirements/lock/uvx-tools.txt nox
25+
# EXTRA_PYTHON_VERSIONS: "pypy-3.11"
26+
>>>>>>> after updating
1727

1828
permissions: {}
1929

@@ -24,6 +34,12 @@ jobs:
2434
outputs:
2535
should_skip: ${{ steps.skip_check.outputs.should_skip }}
2636
steps:
37+
- name: Don't run CI on draft PR
38+
if:
39+
github.event_name == 'pull_request' && github.event.pull_request.draft
40+
== true
41+
run: exit 1
42+
2743
- id: skip_check
2844
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1
2945
with:
@@ -69,7 +85,6 @@ jobs:
6985
print("{minmax_default_python_versions=}")
7086
print("{all_python_version=}")
7187
72-
7388
with open(os.getenv("GITHUB_OUTPUT"), "a") as f:
7489
f.write(f"{default_python_version=:s}\n")
7590
f.write(f"{min_python_version=:s}\n")
@@ -153,6 +168,12 @@ jobs:
153168
matrix:
154169
os:
155170
- ubuntu-latest
171+
<<<<<<< before updating
172+
=======
173+
# - windows-latest
174+
session:
175+
- typecheck
176+
>>>>>>> after updating
156177
steps:
157178
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
158179
with:
@@ -162,14 +183,16 @@ jobs:
162183
python-version-file: ".python-version"
163184
cache-dependency-path: uv.lock
164185
- name: Get python version
186+
id: python_version
165187
run: |
166188
python_version=$(cat .python-version)
167-
echo "python_version=${python_version}" >> "$GITHUB_ENV"
189+
echo "python_version=${python_version}" >> "$GITHUB_OUTPUT"
168190
shell: bash
169191
- name: typecheck
170192
env:
171-
python_version: ${{ env.python_version }}
172-
run: $UVX_COMMAND nox -s typecheck-"$python_version"
193+
python_version: ${{ steps.python_version.outputs.python_version }}
194+
session: ${{ matrix.session }}
195+
run: $NOX_COMMAND -s "${session}-${python_version}"
173196
shell: bash
174197

175198
test:
@@ -188,10 +211,13 @@ jobs:
188211
${{
189212
fromJson(needs.build-package.outputs.minmax-default-python-versions)
190213
}}
214+
session:
215+
- test
191216
include:
192217
- os: windows-latest
193218
python-version:
194219
${{ needs.build-package.outputs.default-python-version }}
220+
session: test
195221
steps:
196222
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
197223
with:
@@ -208,14 +234,19 @@ jobs:
208234
- name: Test with nox
209235
env:
210236
python_version: ${{ matrix.python-version }}
211-
run: >-
212-
$UVX_COMMAND nox -s test-"$python_version" -- ++installpkg dist/*.whl
213-
shell: bash
237+
options: "++installpkg dist/*.whl"
238+
session: ${{ matrix.session }}
239+
run: |
240+
# shellcheck disable=SC2086
241+
$NOX_COMMAND -s "${session}-${python_version}" -- $options
242+
shell: bash -euxo pipefail {0}
214243

215244
- name: Upload coverage data
216245
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
217246
with:
218-
name: coverage-data-${{ matrix.os }}-${{ matrix.python-version }}
247+
name:
248+
coverage-data-${{ matrix.os }}-${{ matrix.python-version }}-${{
249+
matrix.session }}
219250
path: .nox/test-*/tmp/.coverage*
220251
include-hidden-files: true
221252
if-no-files-found: ignore
@@ -247,12 +278,12 @@ jobs:
247278
cache-dependency-path: requirements/lock/uvx-tools.txt
248279
- name: Run coverage
249280
run: |
250-
$UVX_COMMAND nox -s coverage -- ++coverage combine html markdown
281+
$NOX_COMMAND -s coverage -- ++coverage combine html markdown
251282
cat coverage.md
252283
cat coverage.md >> "$GITHUB_STEP_SUMMARY"
253284
254285
# fail if under 100%
255-
$UVX_COMMAND nox -s coverage -- ++coverage report ++coverage-options --fail-under=100
286+
$NOX_COMMAND -s coverage -- ++coverage report ++coverage-options --fail-under=100
256287
shell: bash
257288
- name: Upload HTML report if check failed.
258289
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0

.github/workflows/release-auto.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Create github release
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
# for debugging
13+
# info:
14+
# if: github.event.pull_request.merged == true
15+
# runs-on: ubuntu-latest
16+
# permissions: {}
17+
# steps:
18+
# - name: PR info
19+
# env:
20+
# RELEASE_COMMIT: ${{ github.event.pull_request.merge_commit_sha }}
21+
# RELEASE_BRANCH: ${{ github.head_ref }}
22+
# OWNER: ${{ github.repository_owner }}
23+
# RELEASE: ${{ format('{0}', startsWith(github.head_ref, 'release/')) }}
24+
# run: |
25+
# echo "RELEASE_COMMIT - $RELEASE_COMMIT"
26+
# echo "RELEASE_BRANCH - $RELEASE_BRANCH"
27+
# echo "OWNER - $OWNER"
28+
# echo "RELEASE - $RELEASE"
29+
30+
create-release:
31+
name: Create release
32+
if:
33+
# prettier-ignore
34+
github.event.pull_request.merged == true && github.repository_owner == 'usnistgov' && startsWith(github.head_ref, 'release/')
35+
runs-on: ubuntu-latest
36+
environment:
37+
name: pull-request
38+
permissions:
39+
contents: write
40+
steps:
41+
- name: PR info
42+
env:
43+
RELEASE_COMMIT: ${{ github.event.pull_request.merge_commit_sha }}
44+
RELEASE_BRANCH: ${{ github.head_ref }}
45+
OWNER: ${{ github.repository_owner }}
46+
RELEASE: ${{ format('{0}', startsWith(github.head_ref, 'release/')) }}
47+
run: |
48+
echo "RELEASE_COMMIT - $RELEASE_COMMIT"
49+
echo "RELEASE_BRANCH - $RELEASE_BRANCH"
50+
echo "OWNER - $OWNER"
51+
echo "RELEASE - $RELEASE"
52+
53+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
54+
with:
55+
persist-credentials: false
56+
sparse-checkout: |
57+
pyproject.toml
58+
sparse-checkout-cone-mode: false
59+
60+
- name: Setup python
61+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
62+
with:
63+
python-version: ">=3.11"
64+
65+
- name: Get version
66+
id: version
67+
shell: python
68+
run: |
69+
import os
70+
import tomllib
71+
from pathlib import Path
72+
73+
version = tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"]
74+
tag = f"v{version}"
75+
76+
print("{tag=:s}")
77+
78+
with open(os.getenv("GITHUB_OUTPUT"), "a") as f:
79+
f.write(f"{tag=:s}\n")
80+
81+
- name: Create pull request
82+
env:
83+
GH_TOKEN: ${{ secrets.PAT }}
84+
RELEASE_COMMIT: ${{ github.event.pull_request.merge_commit_sha }}
85+
TAG: ${{ steps.version.outputs.tag }}
86+
run: |
87+
gh release create "$TAG" --generate-notes --target "$RELEASE_COMMIT"
Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
name: Copier update repository
1+
name: Update repo with copier
22
on:
33
schedule:
44
- cron: "0 2 * * 1" # Every Monday at 2am
55
workflow_dispatch:
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
711
permissions:
812
contents: write
913
pull-requests: write
@@ -47,33 +51,50 @@ jobs:
4751
- name: Copier update
4852
continue-on-error: false
4953
id: check
54+
env:
55+
commit_message_in: ${{ matrix.commit-message }}
5056
run: |
51-
CHANGES=0
57+
changed='false'
58+
conflict_message=''
59+
commit_message="$commit_message_in"
60+
5261
if [ -f .copier-answers.yml ]; then
5362
copier update ${{ env.COPIER_OPTIONS }}
5463
if ! git diff --quiet -- .copier-answers.yml; then
55-
CHANGES=1
64+
changed='true'
5665
fi
5766
else
5867
echo "No .copier-answers.yml file"
68+
exit 1
5969
fi
60-
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
6170
62-
- name: Git config
63-
if: steps.check.outputs.has_changes == '1'
64-
run: |
65-
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
66-
git config --global user.name "github-actions[bot]"
67-
git restore --staged .
71+
# determine if have any merge conflicts
72+
if [ "$changed" = "true" ] && ! git merge --no-commit --no-ff; then
73+
conflict_message="\n\nFiles with conflicts:\n\n$(git diff --name-only --diff-filter=U)"
74+
commit_message="$commit_message [skip ci]"
75+
fi
76+
77+
echo "changed=$changed" >> "$GITHUB_OUTPUT"
78+
echo "commit_message=$commit_message" >> "$GITHUB_OUTPUT"
79+
echo "conflict_message=$conflict_message" >> "$GITHUB_OUTPUT"
80+
echo "files_changed=$(git status --short)" >> "$GITHUB_OUTPUT"
81+
82+
# git config
83+
if [ "$changed" = "true" ]; then
84+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
85+
git config --global user.name "github-actions[bot]"
86+
git restore --staged .
87+
fi
88+
shell: bash -euxo pipefail {0}
6889

6990
- name: Create pull request
70-
if: steps.check.outputs.has_changes == '1'
91+
if: steps.check.outputs.changed == 'true'
7192
id: cpr
7293
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
7394
with:
7495
token: ${{ secrets.PAT }}
7596
add-paths: ${{ matrix.add-paths }}
76-
commit-message: ${{ matrix.commit-message }}
97+
commit-message: ${{ steps.check.outputs.commit_message }}
7798
title: ${{ matrix.title }}
7899
labels: |
79100
internal
@@ -82,7 +103,11 @@ jobs:
82103
delete-branch: true
83104
# branch-suffix: timestamp # If want commit per run (instead of per workflow)
84105
body: |
85-
This is an autogenerated PR. ${{ matrix.body }}
106+
This is an autogenerated PR. ${{ matrix.body }} ${{ steps.check.outputs.conflict_message }}
107+
108+
`git status --short`:
109+
110+
${{ steps.check.outputs.files_changed }}
86111
87112
[copier](https://github.com/copier-org/copier) has detected updates from the Cookiecutter repository.
88113

0 commit comments

Comments
 (0)