Skip to content

Commit 97f8510

Browse files
authored
Copier update (pre-commit workflow) (#42)
Pull in upstream changes
1 parent 277f4c4 commit 97f8510

File tree

6 files changed

+143
-74
lines changed

6 files changed

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

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ updates:
1212
- dependency-name: "boto3" # boto3 gets patch updates way too frequently and they're usually not important
1313
update-types:
1414
- "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"
1519

1620
groups:
1721
prod-dependencies:

.github/workflows/ci.yaml

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,9 @@ jobs:
2121

2222
pre-commit:
2323
needs: [ get-values ]
24-
strategy:
25-
fail-fast: false
26-
matrix:
27-
os:
28-
- "ubuntu-24.04"
29-
python-version:
30-
- 3.12.7
31-
name: Pre-commit for Py${{ matrix.python-version }} on ${{ matrix.os }}
32-
runs-on: ${{ matrix.os }}
33-
steps:
34-
- name: Checkout code
35-
uses: actions/checkout@v4.2.2
36-
with:
37-
ref: ${{ github.ref_name }} # explicitly get the head of
38-
39-
40-
41-
- name: Install latest versions of python packages
42-
uses: ./.github/actions/install_deps_uv
43-
with:
44-
python-version: ${{ matrix.python-version }}
45-
46-
- 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
47-
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
48-
uses: ben-z/gh-action-mutex@1ebad517141198e08d47cf72f3c0975316620a65 # v1.0.0-alpha.10
49-
with:
50-
branch: mutex-venv-${{ matrix.os }}-${{ matrix.python-version }}
51-
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
52-
53-
- name: Cache Pre-commit hooks
54-
uses: actions/cache@v4.2.2
55-
env:
56-
cache-name: cache-pre-commit-hooks
57-
with:
58-
path: ${{ env.PRE_COMMIT_HOME }}
59-
key: ${{ matrix.os }}-${{ matrix.python-version }}-build-${{ env.cache-name }}-${{ hashFiles('.pre-commit-config.yaml') }}
60-
restore-keys: |
61-
${{ matrix.os }}-${{ matrix.python-version }}-build-${{ env.cache-name }}-
62-
63-
- name: Run pre-commit
64-
run: pre-commit run -a
24+
uses: ./.github/workflows/pre-commit.yaml
25+
with:
26+
python-version: 3.12.7
6527

6628
lint-matrix:
6729
needs: [ pre-commit ]

.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/checkout@v4.2.2
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/setup-node@v4.3.0
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/cache@v4.2.2
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

template/.github/workflows/ci.yaml.jinja

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,9 @@ jobs:
2222
lint:
2323
needs: [ get-values ]
2424
name: Pre-commit
25-
runs-on: {% endraw %}{{ gha_linux_runner }}{% raw %}
26-
steps:
27-
- name: Checkout code
28-
uses: actions/checkout@{% endraw %}{{ gha_checkout }}{% raw %}
29-
30-
- name: Install latest versions of python packages
31-
uses: ./.github/actions/install_deps_uv
32-
with:
33-
python-version: {% endraw %}{{ python_version }}{% raw %}{% endraw %}{% if python_package_registry == "AWS CodeArtifact" %}{% raw %}
34-
code-artifact-auth-role-name: CoreInfraBaseAccess
35-
code-artifact-auth-role-account-id: {% endraw %}{{ aws_central_infrastructure_account_id }}{% raw %}
36-
code-artifact-auth-region: {% endraw %}{{ aws_org_home_region }}{% endif %}{% raw %}
37-
38-
- 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
39-
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
40-
uses: ben-z/gh-action-mutex@{% endraw %}{{ gha_mutex }}{% raw %}
41-
with:
42-
branch: mutex-venv-{% endraw %}{{ gha_linux_runner }}{% raw %}-py{% endraw %}{{ python_version }}{% raw %}
43-
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
44-
45-
- name: Cache Pre-commit hooks
46-
uses: actions/cache@{% endraw %}{{ gha_cache }}{% raw %}
47-
env:
48-
cache-name: cache-pre-commit-hooks
49-
with:
50-
path: ${{ env.PRE_COMMIT_HOME }}
51-
key: {% endraw %}{{ gha_linux_runner }}{% raw %}-py{% endraw %}{{ python_version }}{% raw %}-build-${{ env.cache-name }}-${{ hashFiles('.pre-commit-config.yaml') }}
52-
restore-keys: |
53-
{% endraw %}{{ gha_linux_runner }}{% raw %}-py{% endraw %}{{ python_version }}{% raw %}-build-${{ env.cache-name }}-
54-
55-
- name: Run pre-commit
56-
run: pre-commit run -a
25+
uses: ./.github/workflows/pre-commit.yaml
26+
with:
27+
python-version: {% endraw %}{{ python_version }}{% raw %}
5728

5829
test:
5930
needs: [ lint ]
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/checkout@v4.2.2
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/setup-node@v4.3.0
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/cache@v4.2.2
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

0 commit comments

Comments
 (0)