Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ updates:
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7

- package-ecosystem: uv
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7

- package-ecosystem: pre-commit
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7
46 changes: 46 additions & 0 deletions .github/workflows/actions.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This file is machine-generated by `gh actions-lock`.
# Do not edit by hand; run `gh actions-lock` to update.
# Docs: https://gh.io/actions-lockfile
version: 'v0.0.3'
workflows:
'.github/workflows/ci.yml':
- 'actions/checkout@v7.0.1'
- 'astral-sh/setup-uv@v7.6.0'
'.github/workflows/release.yml':
- 'actions/attest@v4.2.2'
- 'actions/download-artifact@v8.0.2'
'.github/workflows/sbom.yml':
- 'actions/checkout@v7.0.1'
- 'actions/upload-artifact@v7.0.2'
- 'anchore/sbom-action@v0.24.3'
dependencies:
'actions/attest@v4.2.2':
ref: 'v4.2.2'
commit: 'sha1-1e69f48acb82d1966a394da916b4c1698aa569d6'
owner_id: 44036562
repo_id: 760701061
'actions/checkout@v7.0.1':
ref: 'v7.0.1'
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
owner_id: 44036562
repo_id: 197814629
'actions/download-artifact@v8.0.2':
ref: 'v8.0.2'
commit: 'sha1-9000827ccba6bdab643e8b6fd33ac0654aef8333'
owner_id: 44036562
repo_id: 192626254
'actions/upload-artifact@v7.0.2':
ref: 'v7.0.2'
commit: 'sha1-cf430e030ddbb5b0abf93d22962f4752f3646cd9'
owner_id: 44036562
repo_id: 192625955
'anchore/sbom-action@v0.24.3':
ref: 'v0.24.3'
commit: 'sha1-66cbf4bc1f1c0d2edc94016e65bc221b6bb0ad6c'
owner_id: 16208487
repo_id: 399925381
'astral-sh/setup-uv@v7.6.0':
ref: 'v7.6.0'
commit: 'sha1-37802adc94f370d6bfd71619e3f0bf239e1f3b78'
owner_id: 115962839
repo_id: 846733598
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false

- uses: astral-sh/setup-uv@v7
- uses: astral-sh/setup-uv@v7.6.0
with:
enable-cache: true

Expand All @@ -41,9 +43,11 @@ jobs:
runner: ubuntu-24.04-arm

steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false

- uses: astral-sh/setup-uv@v7
- uses: astral-sh/setup-uv@v7.6.0
with:
enable-cache: true

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ permissions:

jobs:
build:
uses: ./.github/workflows/ci.yml
uses: $/.github/workflows/ci.yml

sbom:
uses: ./.github/workflows/sbom.yml
uses: $/.github/workflows/sbom.yml

release:
needs: [build, sbom]
Expand All @@ -25,13 +25,13 @@ jobs:
id-token: write

steps:
- uses: actions/download-artifact@v8
- uses: actions/download-artifact@v8.0.2
with:
path: dist
merge-multiple: true

- name: Attest build provenance
uses: actions/attest@v4
uses: actions/attest@v4.2.2
with:
subject-path: dist/*

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/sbom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false

- name: Install syft
uses: anchore/sbom-action/download-syft@v0.24.3
Expand All @@ -27,7 +29,7 @@ jobs:
--source-name="${NAME}"

- name: Upload SBOM
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v7.0.2
with:
name: sbom
path: dist/*.json
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,19 @@ repos:
entry: uv run --frozen shfmt -w
language: system
types: [shell]

# actionlint does not accept the $/ syntax yet (pywright/template#38).
- id: actionlint
name: actionlint
entry: >-
uv run --frozen actionlint -ignore
'reusable workflow call "\$/.+" at "uses" is not following the format'
language: system
files: ^\.github/workflows/.*\.ya?ml$

- id: zizmor
name: zizmor
entry: uv run --frozen zizmor .github/
language: system
files: ^\.github/
pass_filenames: false
12 changes: 12 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ build`, the command CI runs.
external tool missing locally). CI must run every case with no skips.
- **Docker is required**: the `debian` cases fail without it, they do not skip.

## Workflows

After adding or removing an action in a workflow, update the lockfile next to
it:

- **Root**: run `gh actions-lock`.
- **Template**: generate a project for each packaging, run `gh actions-lock`
there and copy the result to
`{{cookiecutter.artifact}}/.github/workflows/actions.lock`, keeping the Jinja
blocks for actions used by one packaging only.
`tests/files/test_actions_lock.py` checks the result.

## Out of scope

- Hooks and extensions: tested separately, not through the
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Issues = "https://github.com/pywright/template/issues"

[dependency-groups]
dev = [
"actionlint-py>=1.7.12.25",
"docker>=7.2.0",
"mbake>=1.5.0",
"pre-commit>=4.7.0",
Expand All @@ -47,6 +48,7 @@ dev = [
"shellcheck-py>=0.11.0.1",
"shfmt-py>=4.2.0",
"types-docker>=7.2.0.20261102",
"zizmor>=1.32.0",
]

[tool.ruff]
Expand Down
49 changes: 49 additions & 0 deletions tests/files/test_actions_lock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import re
from pathlib import Path

import pytest

from tests.helpers import Generate

# `owner/repo[/path]@ref` in a workflow; the lockfile records `owner/repo@ref`.
USES = re.compile(r"uses: ([\w-]+/[\w.-]+)(?:/\S+)?(@\S+)$", re.MULTILINE)
PINNED = re.compile(r"^ '(.+@.+)':$", re.MULTILINE)
SETUP_UV = "astral-sh/setup-uv@"


def read_lockfile(project: Path) -> str:
return (project / ".github" / "workflows" / "actions.lock").read_text()


@pytest.mark.parametrize("packaging", ["python", "debian-jammy-arm64"])
def test_whenPackagingIsSet_expectEveryActionLockedOnce(
generate: Generate, packaging: str
) -> None:
project = generate(packaging=packaging)
lockfile = read_lockfile(project)

used = {
path.name: sorted({repo + ref for repo, ref in USES.findall(path.read_text())})
for path in sorted((project / ".github" / "workflows").glob("*.yml"))
}
workflows = "".join(
f" '.github/workflows/{name}':\n"
+ "".join(f" - '{action}'\n" for action in actions)
for name, actions in used.items()
)

assert f"\nworkflows:\n{workflows}dependencies:\n" in lockfile
assert PINNED.findall(lockfile) == sorted(set().union(*used.values()))


def test_whenPackagingIsPython_expectSetupUvLocked(generate: Generate) -> None:
lockfile = read_lockfile(generate(packaging="python"))

assert f" - '{SETUP_UV}" in lockfile
assert f"\n '{SETUP_UV}" in lockfile


def test_whenPackagingIsDebian_expectSetupUvNotLocked(generate: Generate) -> None:
lockfile = read_lockfile(generate(packaging="debian-jammy-arm64"))

assert SETUP_UV not in lockfile
1 change: 1 addition & 0 deletions tests/files/test_rendered.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
".editorconfig",
"AGENTS.md",
".github/dependabot.yml",
".github/workflows/actions.lock",
".github/workflows/ci.yml",
".github/workflows/release.yml",
".github/workflows/sbom.yml",
Expand Down
29 changes: 29 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions {{cookiecutter.artifact}}/.github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,28 @@ updates:
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7

- package-ecosystem: uv
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7

- package-ecosystem: pre-commit
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7
{%- if cookiecutter.__packaging == 'debian' %}

- package-ecosystem: docker
directory: /packaging
schedule:
interval: weekly
cooldown:
default-days: 7
{%- endif %}
Loading
Loading