Skip to content

Commit 331309f

Browse files
authored
Copier update (dependabot) (#31)
Pull in upstream changes
1 parent f8f1b34 commit 331309f

File tree

21 files changed

+474
-95
lines changed

21 files changed

+474
-95
lines changed

.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
2-
_commit: v0.0.34
2+
_commit: v0.0.44
33
_src_path: gh:LabAutomationAndScreening/copier-base-template.git
44
description: A web app that is hosted within a local intranet. Nuxt frontend, python
55
backend, docker-compose

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@
5959
"initializeCommand": "sh .devcontainer/initialize-command.sh",
6060
"onCreateCommand": "sh .devcontainer/on-create-command.sh",
6161
"postStartCommand": "sh .devcontainer/post-start-command.sh"
62-
// Devcontainer context hash (do not manually edit this, it's managed by a pre-commit hook): 04266789 # spellchecker:disable-line
62+
// Devcontainer context hash (do not manually edit this, it's managed by a pre-commit hook): c3deafe5 # spellchecker:disable-line
6363
}

.devcontainer/install-ci-tooling.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ npm -v
99
npm install -g [email protected]
1010
pnpm -v
1111

12-
curl -LsSf https://astral.sh/uv/0.6.17/install.sh | sh
12+
curl -LsSf https://astral.sh/uv/0.7.3/install.sh | sh
1313
uv --version
1414
# TODO: add uv autocompletion to the shell https://docs.astral.sh/uv/getting-started/installation/#shell-autocompletion
1515

.github/actions/install_deps_uv/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ runs:
4040
shell: bash
4141

4242
- name: Setup python
43-
uses: actions/setup-python@v5.5.0
43+
uses: actions/setup-python@v5.6.0
4444
with:
4545
python-version: ${{ env.PYTHON_VERSION }}
4646

.github/actions/install_deps_uv/install-ci-tooling.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Set-StrictMode -Version Latest
44
$ErrorActionPreference = "Stop"
55

6-
irm https://astral.sh/uv/0.6.17/install.ps1 | iex
6+
irm https://astral.sh/uv/0.7.3/install.ps1 | iex
77

88
# Add uv to path (in github runner)
99
$env:Path = "C:\Users\runneradmin\.local\bin;$env:Path"
@@ -21,7 +21,7 @@ if ($args.Count -eq 0) {
2121
}
2222

2323

24-
$env:UV_PYTHON = "$input"
24+
$env:UV_PYTHON = "$input_arg"
2525
$env:UV_PYTHON_PREFERENCE="only-system"
2626

2727
& uv tool install 'copier==9.6.0' --with 'copier-templates-extensions==0.3.0'
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Update Devcontainer Hash
2+
3+
inputs:
4+
branch:
5+
description: 'Branch to checkout and update'
6+
required: true
7+
8+
permissions:
9+
contents: write
10+
11+
outputs:
12+
new-sha:
13+
description: 'The SHA of the branch tip after update'
14+
value: ${{ steps.commit-and-push.outputs.new-sha }}
15+
commit-created:
16+
description: 'Whether a new commit was created and pushed'
17+
value: ${{ steps.commit-and-push.outputs.commit-created }}
18+
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Verify Dependabot actor
23+
if: ${{ github.actor != 'dependabot[bot]' }}
24+
run: |
25+
echo "Action can only be run by dependabot[bot], but was invoked by ${GITHUB_ACTOR}." >&2
26+
exit 1
27+
shell: bash
28+
29+
- name: Checkout code
30+
uses: actions/[email protected]
31+
with:
32+
persist-credentials: true
33+
fetch-depth: 1
34+
ref: ${{ inputs.branch }}
35+
36+
- name: Configure Git author
37+
run: |
38+
git config user.name "github-actions[bot]"
39+
git config user.email "github-actions[bot]@users.noreply.github.com"
40+
shell: bash
41+
42+
- name: Update devcontainer hash
43+
run: |
44+
python3 .github/workflows/hash_git_files.py . --for-devcontainer-config-update --exit-zero
45+
shell: bash
46+
47+
- name: Commit & push changes
48+
id: commit-and-push
49+
run: |
50+
if ! git diff --quiet; then
51+
git add .
52+
git commit -m "chore: update devcontainer hash [dependabot skip]"
53+
git push origin HEAD:${{ inputs.branch }}
54+
echo "commit-created=true" >> $GITHUB_OUTPUT
55+
echo "new-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
56+
else
57+
echo "No changes to commit"
58+
echo "commit-created=false" >> $GITHUB_OUTPUT
59+
fi
60+
shell: bash

.github/dependabot.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "uv"
4+
directories:
5+
- "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "sunday"
9+
time: "16:00"
10+
open-pull-requests-limit: 5
11+
ignore:
12+
- dependency-name: "boto3" # boto3 gets patch updates way too frequently and they're usually not important
13+
update-types:
14+
- "version-update:semver-patch"
15+
- dependency-name: "sphinx*" # read-the-docs uses specific versions of sphinx, so we generally want to stay tightly pinned unless there's a major version change
16+
update-types:
17+
- "version-update:semver-minor"
18+
- "version-update:semver-patch"
19+
20+
groups:
21+
prod-dependencies:
22+
dependency-type: "production"
23+
update-types:
24+
- "minor"
25+
- "patch"
26+
dev-dependencies:
27+
dependency-type: "development"
28+
update-types:
29+
- "minor"
30+
- "patch"

.github/workflows/ci.yaml

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,18 @@ env:
1212

1313
permissions:
1414
id-token: write
15-
contents: write # needed for mutex
15+
contents: write # needed for mutex, and updating dependabot branches
16+
statuses: write # needed for updating status on Dependabot PRs
1617

1718
jobs:
18-
pre-commit:
19-
strategy:
20-
fail-fast: false
21-
matrix:
22-
os:
23-
- "ubuntu-24.04"
24-
python-version:
25-
- 3.12.7
26-
node-version:
27-
- 22.14.0
28-
name: Pre-commit for Py${{ matrix.python-version }} on ${{ matrix.os }}
29-
runs-on: ${{ matrix.os }}
30-
steps:
31-
- name: Checkout code
32-
uses: actions/[email protected]
19+
get-values:
20+
uses: ./.github/workflows/get-values.yaml
3321

34-
- name: Setup node
35-
uses: actions/[email protected]
36-
with:
37-
node-version: ${{ matrix.node-version }}
38-
39-
- name: Install latest versions of python packages
40-
uses: ./.github/actions/install_deps_uv
41-
with:
42-
python-version: ${{ matrix.python-version }}
43-
44-
- name: Set up mutex # Github concurrency management is horrible, things get arbitrarily cancelled if queued up. So using mutex until github fixes itself. When multiple jobs are modifying cache at once, weird things can happen. possible issue is https://github.com/actions/toolkit/issues/658
45-
if: ${{ runner.os != 'Windows' }} # we're just gonna have to YOLO on Windows, because this action doesn't support it yet https://github.com/ben-z/gh-action-mutex/issues/14
46-
uses: ben-z/gh-action-mutex@1ebad517141198e08d47cf72f3c0975316620a65 # v1.0.0-alpha.10
47-
with:
48-
branch: mutex-venv-${{ matrix.os }}-${{ matrix.python-version }}
49-
timeout-minutes: 30 # this is the amount of time this action will wait to attempt to acquire the mutex lock before failing, e.g. if other jobs are queued up in front of it
50-
51-
- name: Cache Pre-commit hooks
52-
uses: actions/[email protected]
53-
env:
54-
cache-name: cache-pre-commit-hooks
55-
with:
56-
path: ${{ env.PRE_COMMIT_HOME }}
57-
key: ${{ matrix.os }}-${{ matrix.python-version }}-build-${{ env.cache-name }}-${{ hashFiles('.pre-commit-config.yaml') }}
58-
restore-keys: |
59-
${{ matrix.os }}-${{ matrix.python-version }}-build-${{ env.cache-name }}-
60-
61-
- name: Run pre-commit
62-
run: pre-commit run -a
22+
pre-commit:
23+
needs: [ get-values ]
24+
uses: ./.github/workflows/pre-commit.yaml
25+
with:
26+
python-version: 3.12.7
6327

6428
lint-matrix:
6529
needs: [ pre-commit ]
@@ -160,10 +124,20 @@ jobs:
160124

161125
required-check:
162126
runs-on: ubuntu-24.04
163-
needs: [ lint-matrix ]
127+
needs: [ lint-matrix, get-values ]
164128
if: always()
165129
steps:
166130
- name: fail if prior job failure
167131
if: needs.lint-matrix.result != 'success'
168132
run: |
169133
exit 1
134+
- name: Mark updated dependabot hash commit as succeeded
135+
if: needs.get-values.outputs.dependabot-commit-created == 'true'
136+
env:
137+
GH_TOKEN: ${{ github.token }}
138+
run: |
139+
gh api \
140+
-X POST -H "Accept: application/vnd.github.v3+json" \
141+
"/repos/${{ github.repository }}/statuses/${{ needs.get-values.outputs.new-dependabot-sha }}" \
142+
-f state=success -f context="required-check" -f description="Initial CI run passed" \
143+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

.github/workflows/get-values.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Get Values
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
new-dependabot-sha:
7+
description: BUILD_HASH
8+
value: ${{ jobs.get-values.outputs.new-dependabot-sha }}
9+
dependabot-commit-created:
10+
description: whether or not a commit was created on a dependabot branch
11+
value: ${{ jobs.get-values.outputs.dependabot-commit-created }}
12+
13+
env:
14+
PYTHONUNBUFFERED: True
15+
16+
permissions:
17+
contents: write # needed to push commit of new devcontainer hash for dependabot PRs
18+
19+
jobs:
20+
get-values:
21+
runs-on: ubuntu-24.04
22+
outputs:
23+
new-dependabot-sha: ${{ steps.update-hash.outputs.new-sha }}
24+
dependabot-commit-created: ${{ steps.update-hash.outputs.commit-created }}
25+
steps:
26+
- name: Checkout code
27+
uses: actions/[email protected]
28+
29+
- name: Update Devcontainer Hash
30+
if: ${{ github.actor == 'dependabot[bot]' }}
31+
id: update-hash
32+
uses: ./.github/actions/update-devcontainer-hash
33+
with:
34+
branch: ${{ github.ref_name }}

.github/workflows/hash_git_files.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def main():
138138
action="store_true",
139139
help="Update the hash in the devcontainer.json file based on all files relevant to devcontainer context",
140140
)
141+
_ = parser.add_argument("--exit-zero", action="store_true", help="Exit with code 0 even if the hash changes")
141142
args = parser.parse_args()
142143

143144
repo_path = args.folder
@@ -170,7 +171,11 @@ def main():
170171
print( # noqa: T201
171172
f"Updated {devcontainer_json_file} with the new hash: {overall_checksum_str}"
172173
)
173-
sys.exit(1) # Exit with non-zero code to indicate changes were made
174+
if args.exit_zero:
175+
sys.exit(0)
176+
else:
177+
sys.exit(1)
178+
174179
else:
175180
print(overall_checksum_str) # noqa: T201 # print this so that the value can be picked up via STDOUT when calling this in a CI pipeline or as a subprocess
176181

.github/workflows/pre-commit.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Pre-commit
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-version:
7+
description: 'What version of python'
8+
type: string
9+
required: true
10+
setup-node:
11+
description: 'Whether to set up Node'
12+
type: boolean
13+
default: false
14+
node-version:
15+
description: 'What version of node'
16+
type: string
17+
required: false
18+
default: 'notUsing'
19+
20+
env:
21+
PYTHONUNBUFFERED: True
22+
PRE_COMMIT_HOME: ${{ github.workspace }}/.precommit_cache
23+
24+
permissions:
25+
contents: write # needed for mutex
26+
27+
jobs:
28+
pre-commit:
29+
runs-on: ubuntu-24.04
30+
name: Pre-commit
31+
steps:
32+
- name: Checkout code
33+
uses: actions/[email protected]
34+
with:
35+
ref: ${{ github.ref_name }} # explicitly get the head of the branch, which will include any new commits pushed if this is a dependabot branch
36+
37+
- name: Setup node
38+
uses: actions/[email protected]
39+
if: ${{ inputs.setup-node }}
40+
with:
41+
node-version: ${{ inputs.node-version }}
42+
43+
- name: Install latest versions of python packages
44+
uses: ./.github/actions/install_deps_uv
45+
with:
46+
python-version: ${{ inputs.python-version }}
47+
48+
- name: Set up mutex # Github concurrency management is horrible, things get arbitrarily cancelled if queued up. So using mutex until github fixes itself. When multiple jobs are modifying cache at once, weird things can happen. possible issue is https://github.com/actions/toolkit/issues/658
49+
if: ${{ runner.os != 'Windows' }} # we're just gonna have to YOLO on Windows, because this action doesn't support it yet https://github.com/ben-z/gh-action-mutex/issues/14
50+
uses: ben-z/gh-action-mutex@1ebad517141198e08d47cf72f3c0975316620a65 # v1.0.0-alpha.10
51+
with:
52+
branch: mutex-venv-ubuntu-24.04-py${{ inputs.python-version }}-nodejs-${{ inputs.node-version }}
53+
timeout-minutes: 30 # this is the amount of time this action will wait to attempt to acquire the mutex lock before failing, e.g. if other jobs are queued up in front of it
54+
55+
- name: Cache Pre-commit hooks
56+
uses: actions/[email protected]
57+
env:
58+
cache-name: cache-pre-commit-hooks
59+
with:
60+
path: ${{ env.PRE_COMMIT_HOME }}
61+
key: ubuntu-24.04-py${{ inputs.python-version }}-node-${{ inputs.node-version}}-${{ env.cache-name }}-${{ hashFiles('.pre-commit-config.yaml') }}
62+
restore-keys: |
63+
ubuntu-24.04-py${{ inputs.python-version }}-node-${{ inputs.node-version}}-${{ env.cache-name }}-
64+
65+
- name: Run pre-commit
66+
run: pre-commit run -a

extensions/context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ContextUpdater(ContextHook):
1010

1111
@override
1212
def hook(self, context: dict[Any, Any]) -> dict[Any, Any]:
13-
context["uv_version"] = "0.6.17"
13+
context["uv_version"] = "0.7.3"
1414
context["pnpm_version"] = "10.10.0"
1515
context["pre_commit_version"] = "4.2.0"
1616
context["pyright_version"] = "1.1.400"
@@ -45,10 +45,11 @@ def hook(self, context: dict[Any, Any]) -> dict[Any, Any]:
4545
context["graphql_codegen_typescript_version"] = "^4.1.6"
4646

4747
context["gha_checkout"] = "v4.2.2"
48-
context["gha_setup_python"] = "v5.5.0"
48+
context["gha_setup_python"] = "v5.6.0"
4949
context["gha_cache"] = "v4.2.2"
5050
context["gha_upload_artifact"] = "v4.6.2"
5151
context["gha_download_artifact"] = "v4.2.1"
52+
context["gha_github_script"] = "v7.0.1"
5253
context["gha_setup_buildx"] = "v3.10.0"
5354
context["buildx_version"] = "v0.22.0"
5455
context["gha_docker_build_push"] = "v6.15.0"

template/.github/actions/install_deps_uv/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ runs:
4040
shell: bash
4141

4242
- name: Setup python
43-
uses: actions/setup-python@v5.5.0
43+
uses: actions/setup-python@v5.6.0
4444
with:
4545
python-version: ${{ env.PYTHON_VERSION }}
4646

template/.github/actions/install_deps_uv/install-ci-tooling.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Set-StrictMode -Version Latest
44
$ErrorActionPreference = "Stop"
55

6-
irm https://astral.sh/uv/0.6.17/install.ps1 | iex
6+
irm https://astral.sh/uv/0.7.3/install.ps1 | iex
77

88
# Add uv to path (in github runner)
99
$env:Path = "C:\Users\runneradmin\.local\bin;$env:Path"
@@ -21,7 +21,7 @@ if ($args.Count -eq 0) {
2121
}
2222

2323

24-
$env:UV_PYTHON = "$input"
24+
$env:UV_PYTHON = "$input_arg"
2525
$env:UV_PYTHON_PREFERENCE="only-system"
2626

2727
& uv tool install 'copier==9.6.0' --with 'copier-templates-extensions==0.3.0'

0 commit comments

Comments
 (0)