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
88 changes: 82 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ concurrency:
group: ${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true

permissions: {}

jobs:
typing:
name: Run type checking
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false

- name: Install uv
uses: astral-sh/[email protected]
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0

- name: Install deps
run: uv sync --all-groups
Expand All @@ -34,10 +38,12 @@ jobs:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false

- name: Install uv
uses: astral-sh/[email protected]
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0

- name: Install deps
run: uv sync --all-groups
Expand All @@ -54,14 +60,84 @@ jobs:

- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@main
uses: py-cov-action/python-coverage-comment-action@main # zizmor: ignore[unpinned-uses] Dogfooding
with:
GITHUB_TOKEN: ${{ github.token }}
ANNOTATE_MISSING_LINES: true

- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
name: python-coverage-comment-action
path: python-coverage-comment-action.txt

push-to-registry:
name: Push Docker image to Docker Hub
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
concurrency:
group: release
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0

- name: Log in to Docker Hub
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
username: ewjoachim
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up QEMU
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0

- name: Login to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- id: docker_meta
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
with:
images: ghcr.io/${{ github.repository }}
tags: type=sha,format=long

- name: Build and push Docker image
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: .
file: Dockerfile.build
platforms: linux/amd64,linux/arm64
labels: |
project='python-coverage-comment-action-base'
org='py-cov-action'
commit-sha='${{ github.sha }}'
org.opencontainers.image.source='https://github.com/${{ github.repository }}'
org.opencontainers.image.description='Publish coverage report as PR comment, and create a coverage badge & dashboard to display on the Readme for Python projects, all inside GitHub without third party servers'
org.opencontainers.image.licenses='MIT'
tags: |
ewjoachim/python-coverage-comment-action-base:v7
ghcr.io/py-cov-action/python-coverage-comment-action-base:v7
${{ steps.docker_meta.outputs.tags }}
ghcr.io/${{ github.repository }}:${{ github.sha }}
ghcr.io/${{ github.repository }}:latest
cache-from: |
ghcr.io/${{ github.repository }}:${{ github.sha }}
ghcr.io/${{ github.repository }}:latest
cache-to: type=inline
push: true
6 changes: 4 additions & 2 deletions .github/workflows/coverage-comment.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: Post coverage comment

on:
on: # zizmor: ignore[dangerous-triggers] We're using workflow_run to post a coverage comment on external PRs. This is safe because we don't checkout the external code. The only attack vector here would be via the coverage comment.
workflow_run:
workflows: ["CI"]
types:
- completed

permissions: {}

jobs:
test:
name: Publish coverage comment
Expand All @@ -17,7 +19,7 @@ jobs:
contents: write
steps:
- name: Post comment
uses: py-cov-action/python-coverage-comment-action@main
uses: py-cov-action/python-coverage-comment-action@main # zizmor: ignore[unpinned-uses] Dogfooding
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }}
4 changes: 3 additions & 1 deletion .github/workflows/e2e-delete-repo.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Delete end-to-end test repos on PR close

on:
on: # zizmor: ignore[dangerous-triggers] We're using pull_request_target to cleanup repos. We're not checking out code from the PR, and the only input we use is guaranteed to be a number.
pull_request_target:
types:
- closed

permissions: {}

jobs:
test:
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/e2e-external-phase-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
pull_request_review:
types: [submitted]

permissions: {}

jobs:
test:
name: Trigger end-to-end tests
Expand All @@ -20,7 +22,7 @@ jobs:
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
- name: Save artifact
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pr_number
path: pr_number.txt
11 changes: 7 additions & 4 deletions .github/workflows/e2e-external-phase-2.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Run end-to-end tests on external PR approval

on:
on: # zizmor: ignore[dangerous-triggers] We're using workflow_run to run end to end tests on external PRs, upon apporoval. It's true that it's a risk, that why we only do it when we a maintainer has approved the PR.
workflow_run:
workflows: ["Trigger end-to-end tests on external PR approval"]
types:
Expand All @@ -9,6 +9,8 @@ on:
concurrency:
group: ${{ github.event_name }}-${{ github.ref }}

permissions: {}

jobs:
e2e:
name: End-to-end tests
Expand Down Expand Up @@ -82,17 +84,18 @@ jobs:
JOB_ID: ${{ steps.extract_job_id.outputs.JOB_ID }}

- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
# Important: use the commit that was reviewed. GitHub is making sure
# that this is race-condition-proof
ref: ${{ steps.extract_commit.outputs.COMMIT_ID }}
persist-credentials: false

- name: Install uv
uses: astral-sh/[email protected]
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0

- name: Poetry caches
uses: actions/cache@v5
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.cache/
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/e2e-private-link-in-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
issue_comment:
types: [created]

permissions: {}

jobs:
invite:
name: Invite everyone to the e2e private repo
Expand All @@ -27,7 +29,6 @@ jobs:
ENABLED: ${{ !contains(fromJson('["kieferro", "ewjoachim"]'), github.event.issue.user.login) }}

steps:

- name: Invite @${{ matrix.collaborator.LOGIN }} to the e2e private repo
run: gh api --method PUT /repos/mihcaojwe/python-coverage-comment-action-end-to-end-${NUMBER}-private/collaborators/${LOGIN} -f permission=${PERMISSION}
if: ${{ matrix.collaborator.ENABLED == true }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/e2e-public-link-in-pr.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Post link to public end-to-end test repository

on:
on: # zizmor: ignore[dangerous-triggers] We're using pull_request_target to post a static comment on PRs. We're not checking out anything. We don't interact with anything from the PR except html_url (provided by github) and pull_request.number (an integer). This is safe.
pull_request_target:
types:
- opened

permissions: {}

jobs:
test:
runs-on: ubuntu-latest
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/manual-release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Release Action (manual)
name: Release Action

on: workflow_dispatch

concurrency:
group: release

permissions: {}

jobs:
release:
name: Create new release
Expand All @@ -14,10 +16,11 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
fetch-tags: true
persist-credentials: false

- env:
GH_TOKEN: ${{ github.token }}
Expand Down
105 changes: 0 additions & 105 deletions .github/workflows/release.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,11 @@ repos:
rev: 1.1.0
hooks:
- id: sync

- repo: https://github.com/zizmorcore/zizmor-pre-commit
# Zizmor version.
rev: v1.25.2
hooks:
# Run the linter.
- id: zizmor
args: ["--fix=all"]
Loading
Loading