Skip to content

Commit 74c46c2

Browse files
authored
Copier Update (biome) (#18)
Pull in upstream changes
1 parent 5eebd3a commit 74c46c2

25 files changed

+611
-86
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.19
2+
_commit: v0.0.31
33
_src_path: gh:LabAutomationAndScreening/copier-base-template.git
44
description: Copier template for creating Python libraries and executables
55
python_ci_versions:

.devcontainer/devcontainer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,17 @@
2222
"eamodio.gitlens@15.5.1",
2323
"ms-vscode.live-server@0.5.2024091601",
2424
"MS-vsliveshare.vsliveshare@1.0.5905",
25-
"github.copilot@1.234.0",
26-
"github.copilot-chat@0.20.2",
25+
"github.copilot@1.304.1523",
26+
"github.copilot-chat@0.27.2025042301",
2727

2828
// Python
2929
"ms-python.python@2024.14.1",
3030
"ms-python.vscode-pylance@2024.9.2",
3131
"ms-vscode-remote.remote-containers@0.383.0",
3232
"charliermarsh.ruff@2024.54.0",
3333

34-
35-
3634
// Misc file formats
37-
"bierner.markdown-mermaid@1.25.0",
35+
"bierner.markdown-mermaid@1.28.0",
3836
"samuelcolvin.jinjahtml@0.20.0",
3937
"tamasfe.even-better-toml@0.19.2",
4038
"emilast.LogFileHighlighter@3.3.3",
@@ -61,4 +59,5 @@
6159
"initializeCommand": "sh .devcontainer/initialize-command.sh",
6260
"onCreateCommand": "sh .devcontainer/on-create-command.sh",
6361
"postStartCommand": "sh .devcontainer/post-start-command.sh"
62+
// Devcontainer context hash (do not manually edit this, it's managed by a pre-commit hook): bbebc7c9
6463
}

.devcontainer/install-ci-tooling.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -ex
66

77

88

9-
curl -LsSf https://astral.sh/uv/0.6.6/install.sh | sh
9+
curl -LsSf https://astral.sh/uv/0.6.17/install.sh | sh
1010
uv --version
1111
# TODO: add uv autocompletion to the shell https://docs.astral.sh/uv/getting-started/installation/#shell-autocompletion
1212

@@ -19,8 +19,8 @@ input="${1:-$default_version}"
1919
export UV_PYTHON="$input"
2020
export UV_PYTHON_PREFERENCE=only-system
2121

22-
uv tool install 'copier==9.5.0' --with 'copier-templates-extensions==0.3.0'
22+
uv tool install 'copier==9.6.0' --with 'copier-templates-extensions==0.3.0'
2323

24-
uv tool install 'pre-commit==4.1.0'
24+
uv tool install 'pre-commit==4.2.0'
2525

2626
uv tool list

.devcontainer/windows-host-helper.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# If you're still having issues, make sure in Windows Developer Settings that you enabled Developer Mode, and also that you set your git config to have `core.autocrlf=false` and `core.symlinks=true` globally
99

10-
set -e # Exit immediately on error
10+
set -euo pipefail # Exit immediately on error
1111

1212
if [ -z "$BASH_VERSION" ]; then
1313
echo "Error: This script must be run with bash (e.g., 'bash windows-host-helper.sh')." >&2
@@ -39,13 +39,26 @@ tmpdir=$(mktemp -d)
3939
# This creates "$tmpdir/$repoName" with the repository's contents.
4040
git clone "$gitUrl" "$tmpdir/$repoName"
4141

42-
# Enable dotglob so that '*' includes hidden files
43-
shopt -s dotglob
4442

45-
# Move all contents (including hidden files) from the cloned repo to the target folder
46-
mv "$tmpdir/$repoName"/* "./$repoName/"
43+
SRC="$(realpath "$tmpdir/$repoName")"
44+
DST="$(realpath "./$repoName")"
4745

48-
# Clean up: remove the temporary directory
46+
# 1) Recreate directory tree under $DST
47+
while IFS= read -r -d '' dir; do
48+
rel="${dir#$SRC/}" # strip leading $SRC/ → e.g. "sub/dir"
49+
mkdir -p "$DST/$rel"
50+
done < <(find "$SRC" -type d -print0)
51+
52+
# 2) Move all files into that mirror
53+
while IFS= read -r -d '' file; do
54+
rel="${file#$SRC/}" # e.g. "sub/dir/file.txt"
55+
# ensure parent exists (though step 1 already did)
56+
mkdir -p "$(dirname "$DST/$rel")"
57+
mv "$file" "$DST/$rel"
58+
done < <(find "$SRC" -type f -print0)
59+
60+
# 3) Clean up now‑empty dirs and the tmp clone
61+
find "$SRC" -depth -type d -empty -delete
4962
rm -rf "$tmpdir"
5063

51-
echo "Repository '$repoName' has been updated."
64+
echo "Repository '$repoName' has been synced into '$DST'."

.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.4.0
43+
uses: actions/setup-python@v5.5.0
4444
with:
4545
python-version: ${{ env.PYTHON_VERSION }}
4646

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

Lines changed: 3 additions & 3 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.6/install.ps1 | iex
6+
irm https://astral.sh/uv/0.6.17/install.ps1 | iex
77

88
# Add uv to path (in github runner)
99
$env:Path = "C:\Users\runneradmin\.local\bin;$env:Path"
@@ -24,8 +24,8 @@ if ($args.Count -eq 0) {
2424
$env:UV_PYTHON = "$input"
2525
$env:UV_PYTHON_PREFERENCE="only-system"
2626

27-
& uv tool install 'copier==9.5.0' --with 'copier-templates-extensions==0.3.0'
27+
& uv tool install 'copier==9.6.0' --with 'copier-templates-extensions==0.3.0'
2828

29-
& uv tool install 'pre-commit==4.1.0'
29+
& uv tool install 'pre-commit==4.2.0'
3030

3131
& uv tool list

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Link to Issue or Slack thread
1+
## Link to Issue or Message thread
22

33

44

.github/reusable_workflows/build-docker-image.yaml

Lines changed: 110 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,144 @@ on:
1111
description: 'Docker image name'
1212
type: string
1313
required: true
14-
tag:
15-
description: 'Docker image tag'
16-
type: string
17-
required: true
14+
tag-for-production:
15+
description: 'Whether or not to add a tag indicating this is being used in production'
16+
type: boolean
17+
required: false
18+
default: false
1819
context:
1920
description: 'Build context path'
2021
type: string
2122
required: false
2223
default: './'
24+
push-role-name:
25+
type: string
26+
description: What's the IAM role name to use for Pushing to the ECR?
27+
required: false
28+
default: no-push
29+
save-as-artifact:
30+
type: boolean
31+
description: 'Should the image be saved as an artifact?'
32+
required: false
33+
default: false
2334

35+
permissions:
36+
id-token: write
37+
contents: write # needed for mutex
2438

2539
jobs:
2640
build-image:
2741
name: Build Docker Image
2842
runs-on: ubuntu-24.04
2943
steps:
44+
- name: Parse ECR URL
45+
if: ${{ inputs.push-role-name != 'no-push' }}
46+
id: parse_ecr_url
47+
run: |
48+
ECR_URL="${{ inputs.repository}}"
49+
50+
# Extract the AWS Account ID, which is the first field
51+
AWS_ACCOUNT_ID=$(echo "$ECR_URL" | cut -d. -f1)
52+
53+
# Extract the AWS Region, which is the fourth field in the URL structure
54+
AWS_REGION=$(echo "$ECR_URL" | cut -d. -f4)
55+
56+
# Set the outputs for use in later steps
57+
echo "aws_account_id=${AWS_ACCOUNT_ID}" >> "$GITHUB_OUTPUT"
58+
echo "aws_region=${AWS_REGION}" >> "$GITHUB_OUTPUT"
59+
shell: bash
60+
3061
- name: Checkout code
3162
uses: actions/checkout@v4.2.2
3263

64+
- name: OIDC Auth for ECR
65+
if: ${{ inputs.push-role-name != 'no-push' }}
66+
uses: aws-actions/configure-aws-credentials@v4.1.0
67+
with:
68+
role-to-assume: arn:aws:iam::${{ steps.parse_ecr_url.outputs.aws_account_id }}:role/${{ inputs.push-role-name }}
69+
aws-region: ${{ steps.parse_ecr_url.outputs.aws_region }}
70+
71+
- name: Calculate hash of files in build context
72+
id: calculate-build-context-hash
73+
run: |
74+
python3 --version
75+
BUILD_HASH=$(python3 .github/workflows/hash_git_files.py ${{ inputs.context }})
76+
echo "build_context_tag=context-${BUILD_HASH}" >> "$GITHUB_OUTPUT"
77+
echo "Calculated build context tag as: ${BUILD_HASH}"
78+
79+
IMAGE_NAME_WITH_NAMESPACE="${{ inputs.image_name }}"
80+
IMAGE_NAME_NO_SLASHES="${IMAGE_NAME_WITH_NAMESPACE//\//-}"
81+
echo "image_name_no_slashes=${IMAGE_NAME_NO_SLASHES}" >> "$GITHUB_OUTPUT"
82+
echo "Image name without slashes: ${IMAGE_NAME_NO_SLASHES}"
83+
84+
- 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
85+
if: ${{ inputs.push-role-name != 'no-push' }}
86+
uses: ben-z/gh-action-mutex@1ebad517141198e08d47cf72f3c0975316620a65 # v1.0.0-alpha.10
87+
with:
88+
branch: mutex-${{ inputs.repository }}-${{ inputs.image_name }}
89+
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
90+
91+
- name: Test if docker image exists
92+
if: ${{ inputs.push-role-name != 'no-push' }}
93+
id: check-if-exists
94+
run: |
95+
BUILD_HASH=${{ steps.calculate-build-context-hash.outputs.build_context_tag }}
96+
echo Checking for : $BUILD_HASH
97+
if aws ecr describe-images --region ${{ steps.parse_ecr_url.outputs.aws_region }} --registry-id=${{ steps.parse_ecr_url.outputs.aws_account_id }} --repository-name=${{ inputs.image_name }} --image-ids=imageTag=$BUILD_HASH; then \
98+
echo "Image was found in ECR"; \
99+
echo "status=found" >> $GITHUB_OUTPUT
100+
else \
101+
echo "Image was not found in ECR"; \
102+
echo "status=notfound" >> $GITHUB_OUTPUT
103+
fi
104+
105+
- name: Login to Amazon ECR
106+
if: ${{ inputs.push-role-name != 'no-push' && (steps.check-if-exists.outputs.status == 'notfound' || inputs.save-as-artifact ) }}
107+
id: login-ecr
108+
uses: aws-actions/amazon-ecr-login@v2.0.1
109+
110+
- name: Pull existing image to package as artifact
111+
if: ${{ inputs.save-as-artifact && steps.check-if-exists.outputs.status == 'found' }}
112+
run: |
113+
docker pull ${{ inputs.repository }}/${{ inputs.image_name }}:${{ steps.calculate-build-context-hash.outputs.build_context_tag }}
114+
33115
- name: Set up Docker Buildx
116+
if: ${{ (inputs.save-as-artifact && inputs.push-role-name == 'no-push') || steps.check-if-exists.outputs.status == 'notfound' }}
34117
uses: docker/setup-buildx-action@v3.10.0
35118
with:
36119
version: v0.22.0
37120

38121
- name: Build Docker Image
122+
if: ${{ (inputs.save-as-artifact && inputs.push-role-name == 'no-push') || steps.check-if-exists.outputs.status == 'notfound' }}
39123
uses: docker/build-push-action@v6.15.0
40124
with:
41125
context: ${{ inputs.context }}
42-
push: false
43-
load: true # make the image available later for the `docker save` step
44-
tags: ${{ inputs.repository }}/${{ inputs.image_name }}:${{ inputs.tag }}
126+
push: ${{ inputs.push-role-name != 'no-push' && steps.check-if-exists.outputs.status == 'notfound' }}
127+
load: ${{ inputs.save-as-artifact }} # make the image available later for the `docker save` step
128+
tags: ${{ inputs.repository }}/${{ inputs.image_name }}:${{ steps.calculate-build-context-hash.outputs.build_context_tag }}
129+
130+
- name: Add git sha tag
131+
if: ${{ inputs.push-role-name != 'no-push' }}
132+
run: |
133+
aws ecr batch-get-image --registry-id=${{ steps.parse_ecr_url.outputs.aws_account_id }} --repository-name=${{ inputs.image_name }} --image-ids imageTag=${{ steps.calculate-build-context-hash.outputs.build_context_tag }} --query 'images[].imageManifest' --output text > manifest.json
134+
aws ecr put-image --registry-id=${{ steps.parse_ecr_url.outputs.aws_account_id }} --repository-name=${{ inputs.image_name }} --image-tag git-sha-${{ github.sha }} --image-manifest file://manifest.json
135+
136+
- name: Add tag for Production
137+
if: ${{ inputs.push-role-name != 'no-push' && inputs.tag-for-production }}
138+
run: |
139+
aws ecr batch-get-image --registry-id=${{ steps.parse_ecr_url.outputs.aws_account_id }} --repository-name=${{ inputs.image_name }} --image-ids imageTag=${{ steps.calculate-build-context-hash.outputs.build_context_tag }} --query 'images[].imageManifest' --output text > manifest.json
140+
# TODO: figure out some better conditional logic about adding a tag for the context in production, so we don't have to `|| true` at the end
141+
aws ecr put-image --registry-id=${{ steps.parse_ecr_url.outputs.aws_account_id }} --repository-name=${{ inputs.image_name }} --image-tag production--${{ steps.calculate-build-context-hash.outputs.build_context_tag }} --image-manifest file://manifest.json || true
142+
aws ecr put-image --registry-id=${{ steps.parse_ecr_url.outputs.aws_account_id }} --repository-name=${{ inputs.image_name }} --image-tag production--git-sha-${{ github.sha }} --image-manifest file://manifest.json
45143
46144
- name: Save Docker Image as tar
47-
run: docker save -o ${{ inputs.image_name }}.tar ${{ inputs.repository }}/${{ inputs.image_name }}:${{ inputs.tag }}
145+
if: ${{ inputs.save-as-artifact }}
146+
run: docker save -o ${{ steps.calculate-build-context-hash.outputs.image_name_no_slashes }}.tar ${{ inputs.repository }}/${{ inputs.image_name }}:${{ steps.calculate-build-context-hash.outputs.build_context_tag }}
48147

49148
- name: Upload Docker Image Artifact
149+
if: ${{ inputs.save-as-artifact }}
50150
uses: actions/upload-artifact@v4.6.2
51151
with:
52-
name: ${{ inputs.image_name }}
53-
path: ${{ inputs.image_name }}.tar
152+
name: ${{ steps.calculate-build-context-hash.outputs.image_name_no_slashes }}
153+
path: ${{ steps.calculate-build-context-hash.outputs.image_name_no_slashes }}.tar
54154
if-no-files-found: error

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ jobs:
143143
144144
- name: Run pre-commit
145145
run: |
146-
# skip pip-compile because the command line args in the header are different
147-
SKIP=git-dirty pre-commit run -a
146+
# skip devcontainer context hash because the template instantiation may make it different every time
147+
SKIP=git-dirty,compute-devcontainer-context-hash pre-commit run -a
148148
149149
- name: Upload pre-commit log if failure
150150
if: ${{ failure() }}

0 commit comments

Comments
 (0)