Skip to content

Commit 6c0e161

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

11 files changed

Lines changed: 357 additions & 29 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.0-131-g6201c7f
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
Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Copier update repository
1+
name: Update repo with copier
22
on:
33
schedule:
44
- cron: "0 2 * * 1" # Every Monday at 2am
@@ -48,26 +48,41 @@ jobs:
4848
continue-on-error: false
4949
id: check
5050
run: |
51-
CHANGES=0
51+
changed='false'
52+
conflict_message=''
53+
draft='false'
54+
5255
if [ -f .copier-answers.yml ]; then
5356
copier update ${{ env.COPIER_OPTIONS }}
5457
if ! git diff --quiet -- .copier-answers.yml; then
55-
CHANGES=1
58+
changed='true'
5659
fi
5760
else
5861
echo "No .copier-answers.yml file"
62+
exit 1
5963
fi
60-
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
6164
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 .
65+
# determine if have any merge conflicts
66+
if [ "$changed" = "true" ] && ! git merge --no-commit --no-ff; then
67+
draft='true'
68+
conflict_message="\n\nFiles with conflicts:\n\n$(git diff --name-only --diff-filter=U)"
69+
fi
70+
71+
echo "changed=$changed" >> "$GITHUB_OUTPUT"
72+
echo "draft=$draft" >> "$GITHUB_OUTPUT"
73+
echo "conflict_message=$conflict_message" >> "$GITHUB_OUTPUT"
74+
echo "files_changed=$(git status --short)" >> "$GITHUB_OUTPUT"
75+
76+
# git config
77+
if [ "$changed" = "true" ]; then
78+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
79+
git config --global user.name "github-actions[bot]"
80+
git restore --staged .
81+
fi
82+
shell: bash -euxo pipefail {0}
6883

6984
- name: Create pull request
70-
if: steps.check.outputs.has_changes == '1'
85+
if: steps.check.outputs.changed == 'true'
7186
id: cpr
7287
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
7388
with:
@@ -80,9 +95,14 @@ jobs:
8095
template_update
8196
branch: ${{ matrix.branch }}
8297
delete-branch: true
98+
draft: ${{ steps.check.outputs.draft }}
8399
# branch-suffix: timestamp # If want commit per run (instead of per workflow)
84100
body: |
85-
This is an autogenerated PR. ${{ matrix.body }}
101+
This is an autogenerated PR. ${{ matrix.body }} ${{ steps.check.outputs.conflict_message }}
102+
103+
`git status --short`:
104+
105+
${{ steps.check.outputs.files_changed }}
86106
87107
[copier](https://github.com/copier-org/copier) has detected updates from the Cookiecutter repository.
88108

.github/workflows/update-cruft.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Update repo with cruft
2+
on:
3+
# schedule:
4+
# - cron: "0 2 * * 1" # Every Monday at 2am
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
update:
13+
name: Update template
14+
runs-on: ubuntu-latest
15+
environment:
16+
name: pull-request
17+
strategy:
18+
fail-fast: true
19+
matrix:
20+
include:
21+
- add-paths: .
22+
body: Use this to merge the changes to this repository.
23+
branch: cruft/update
24+
commit-message: "chore(template): accept new cruft update"
25+
title: "chore(template): accept new cruft update"
26+
# - add-paths: .cruft.json
27+
# body: Use this to reject the changes to this repository.
28+
# branch: cruft/reject
29+
# commit-message: "chore(template): reject new cruft update"
30+
# title: "chore(template): reject new cruft update"
31+
steps:
32+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
with:
34+
persist-credentials: false
35+
- uses: ./.github/actions/setup-cached-uv-and-python
36+
with:
37+
python-version-file: ".python-version"
38+
cache-dependency-path: requirements/lock/uvx-tools.txt
39+
- name: Install cruft
40+
run: uv tool install -crequirements/lock/uvx-tools.txt cruft
41+
- name: Cruft update
42+
continue-on-error: false
43+
id: check
44+
run: |
45+
changed='false'
46+
conflict_message=''
47+
draft='false'
48+
49+
if [ -f .cruft.json ]; then
50+
cruft update --skip-apply-ask --refresh-private-variables
51+
if ! git diff --quiet -- .cruft.json; then
52+
changed='true'
53+
fi
54+
else
55+
echo "No .cruft.json file"
56+
exit 1
57+
fi
58+
59+
# determine if have any merge conflicts
60+
if [ "$changed" = "true" ] && ! git merge --no-commit --no-ff; then
61+
draft='true'
62+
conflict_message="\n\nFound conflicts. Fix below files before merge:\n\n$(git diff --name-only --diff-filter=U)"
63+
fi
64+
65+
echo "changed=$changed" >> "$GITHUB_OUTPUT"
66+
echo "draft=$draft" >> "$GITHUB_OUTPUT"
67+
echo "conflict_message=$conflict_message" >> "$GITHUB_OUTPUT"
68+
echo "files_changed=$(git status --short)" >> "$GITHUB_OUTPUT"
69+
70+
# git config
71+
if [ "$changed" = "true" ]; then
72+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
73+
git config --global user.name "github-actions[bot]"
74+
git restore --staged .
75+
fi
76+
shell: bash -euxo pipefail {0}
77+
78+
- name: Create pull request
79+
if: steps.check.outputs.changed == 'true'
80+
id: cpr
81+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
82+
with:
83+
token: ${{ secrets.PAT }}
84+
add-paths: ${{ matrix.add-paths }}
85+
commit-message: ${{ matrix.commit-message }}
86+
title: ${{ matrix.title }}
87+
labels: |
88+
internal
89+
template_update
90+
branch: ${{ matrix.branch }}
91+
delete-branch: true
92+
draft: ${{ steps.check.outputs.draft }}
93+
# branch-suffix: timestamp # If want commit per run (instead of per workflow)
94+
body: |
95+
This is an autogenerated PR. ${{ matrix.body }} ${{ steps.check.outputs.conflict_message }}
96+
97+
`git status --short`:
98+
99+
${{ steps.check.outputs.files_changed }}
100+
101+
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Cookiecutter repository.
102+
103+
- name: Pull request info
104+
if: ${{ steps.cpr.outputs.pull-request-number }}
105+
env:
106+
NUMBER: ${{ steps.cpr.outputs.pull-request-number }}
107+
URL: ${{ steps.cpr.outputs.pull-request-url }}
108+
OPERATION: ${{ steps.cpr.outputs.pull-request-operation }}
109+
SHA: ${{ steps.cpr.outputs.pull-request-sha }}
110+
BRANCH: ${{ steps.cpr.outputs.pull-request-branch }}
111+
VERIFIED: $steps.cpr.outputs.pull-request-commits-verified
112+
run: |
113+
echo "Pull Request Number - $NUMBER"
114+
echo "Pull Request URL - $URL"
115+
echo "Pull Request Operation - $OPERATION"
116+
echo "Pull Request SHA - $SHA"
117+
echo "Pull Request BRANCH - $BRANCH"
118+
echo "Pull Request VERIFIED - $VERIFIED"

0 commit comments

Comments
 (0)