Skip to content
Merged
8 changes: 4 additions & 4 deletions .github/workflows/actions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ workflows:
'.github/workflows/test.yml':
- 'actions/checkout@v4.4.0'
- 'actions/setup-go@v6.5.0'
- 'docker/login-action@v3.7.0'
- 'docker/login-action@v4.7.0'
'.github/workflows/vuln-remediation.yml': []
dependencies:
'actions/checkout@v4.4.0':
Expand Down Expand Up @@ -68,9 +68,9 @@ dependencies:
commit: 'sha1-7474bc4690e29a8392af63c5b98e7449536d5c3a'
owner_id: 57468012
repo_id: 220391287
'docker/login-action@v3.7.0':
ref: 'v3.7.0'
commit: 'sha1-c94ce9fb468520275223c153574b00df6fe4bcc9'
'docker/login-action@v4.7.0':
ref: 'v4.7.0'
commit: 'sha1-81c6f93d4bc991e510b342a00b419b3bb4efc5c6'
owner_id: 5429470
repo_id: 287743349
'docker/setup-buildx-action@v3.12.0':
Expand Down
30 changes: 10 additions & 20 deletions .github/workflows/test-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,21 @@ jobs:
run: |
set -euo pipefail
gh api "repos/$REPO/pulls/$PR_NUMBER" \
--jq '[.state, .base.ref, .head.repo.full_name, .head.sha] | @tsv' > "$RUNNER_TEMP/pr.tsv"
read -r state base_repo head_repo head_sha < "$RUNNER_TEMP/pr.tsv"
--jq '[.state, .base.ref, .head.repo.full_name, .head.sha, .head.ref] | @tsv' > "$RUNNER_TEMP/pr.tsv"
read -r state base_repo head_repo head_sha head_ref < "$RUNNER_TEMP/pr.tsv"
if [ "$state" != "open" ] || [ "$base_repo" != "main" ] || [ -z "$head_repo" ]; then
echo "::error::only open pull requests targeting main can be tested"
exit 1
fi
if [ "$head_repo" != "$REPO" ]; then
gh api "repos/$REPO/issues/$PR_NUMBER/comments" \
--field body="Full CI runs from branches in this repository only. A maintainer can review the changes and push them to a branch here to run CI."
exit 1
fi
{
echo "head_repo=$head_repo"
echo "head_sha=$head_sha"
echo "head_ref=$head_ref"
} >> "$GITHUB_OUTPUT"

- name: Reject commits pushed after the command
Expand Down Expand Up @@ -93,23 +99,6 @@ jobs:
exit 1
fi

- name: Reject dependency changes
if: steps.command.outputs.run == 'true' && steps.pr.outputs.head_repo != github.repository
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.issue.number }}
run: |
set -euo pipefail
dependency_files="$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/files" \
--jq '.[] | select(.filename == "go.mod" or .filename == "go.sum") | .filename')"
if [ -n "$dependency_files" ]; then
gh api "repos/$REPO/issues/$PR_NUMBER/comments" \
--field body="Tests were not dispatched because public contributions cannot change go.mod or go.sum."
echo "::error::public contribution changes dependency files: $dependency_files"
exit 1
fi

- name: Dispatch tests
if: steps.command.outputs.run == 'true'
env:
Expand All @@ -118,6 +107,7 @@ jobs:
PR_NUMBER: ${{ github.event.issue.number }}
HEAD_REPO: ${{ steps.pr.outputs.head_repo }}
HEAD_SHA: ${{ steps.pr.outputs.head_sha }}
HEAD_REF: ${{ steps.pr.outputs.head_ref }}
run: |
set -euo pipefail
current_head_sha="$(gh api "repos/$REPO/pulls/$PR_NUMBER" --jq '.head.sha')"
Expand All @@ -130,7 +120,7 @@ jobs:

gh workflow run test.yml \
--repo "$REPO" \
--ref main \
--ref "$HEAD_REF" \
--field pr_head_repo="$HEAD_REPO" \
--field pr_head_sha="$HEAD_SHA" \
--field pr_number="$PR_NUMBER"
Expand Down
66 changes: 32 additions & 34 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_dispatch:
inputs:
pr_head_repo:
description: "Fork repository containing the PR commit"
description: "Repository containing the PR branch (must be this repository)"
required: false
type: string
pr_head_sha:
Expand All @@ -28,25 +28,25 @@ concurrency:
group: test-${{ (github.event_name == 'push' && github.ref != 'refs/heads/main') && github.ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' }}

# A slash-command dispatch supplies a fork repository and immutable commit SHA.
# Normal push runs use the upstream repository and pushed ref.
env:
TEST_PR_HEAD_REPO: ${{ inputs.pr_head_repo || github.repository }}
TEST_SOURCE_REPO: ${{ inputs.pr_head_repo || github.repository }}
TEST_SOURCE_REF: ${{ inputs.pr_head_sha || github.ref }}

permissions:
contents: read

env:
DOCKERHUB_OIDC_CONNECTIONID: e87832ce-a4e3-4386-8b17-44a6085109f2
DOCKERHUB_OIDC_EXPIREIN: '3600'

jobs:
test:
# Test the commit selected by GitHub, not a dispatch-supplied checkout.
if: ${{ github.repository == 'kernel/hypeman' && (!inputs.pr_head_repo || inputs.pr_head_repo == github.repository) && (!inputs.pr_head_sha || inputs.pr_head_sha == github.sha) }}
Comment thread
sjmiller609 marked this conversation as resolved.
Resolved
runs-on: [self-hosted, linux, x64, kvm]
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4.4.0
with:
clean: false
repository: ${{ env.TEST_SOURCE_REPO }}
ref: ${{ env.TEST_SOURCE_REF }}
persist-credentials: false

- name: Clean workspace (preserve binary caches)
Expand Down Expand Up @@ -166,13 +166,13 @@ jobs:
done
exit 1

# Slash-command runs are maintainer-approved and need authenticated pulls
# for images that are not covered by the prewarm cache.
- name: Login to Docker Hub
uses: docker/login-action@v3.7.0
- name: Create isolated Docker config
run: echo "DOCKER_CONFIG=$(mktemp -d "$RUNNER_TEMP/docker-config.XXXXXX")" >> "$GITHUB_ENV"

- name: Login to Docker Hub with OIDC
uses: docker/login-action@v4.7.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
username: onkernel

- name: Generate OpenAPI code
run: make oapi-generate
Expand Down Expand Up @@ -220,7 +220,6 @@ jobs:

- name: Prewarm test cache
env:
DOCKER_CONFIG: /home/debianuser/.docker
GITHUB_TOKEN: ${{ github.token }}
HYPEMAN_TEST_REGISTRY: 127.0.0.1:5001
run: |
Expand Down Expand Up @@ -260,13 +259,11 @@ jobs:
env:
GO_TEST_TIMEOUT: 600s
GITHUB_TOKEN: ${{ github.token }}
# Docker auth for tests running as root (sudo)
DOCKER_CONFIG: /home/debianuser/.docker
# TLS/ACME testing (optional - tests will skip if not configured)
ACME_EMAIL: ${{ env.TEST_PR_HEAD_REPO == github.repository && secrets.ACME_EMAIL || '' }}
ACME_EMAIL: ${{ secrets.ACME_EMAIL }}
ACME_DNS_PROVIDER: "cloudflare"
ACME_CA: "https://acme-staging-v02.api.letsencrypt.org/directory"
CLOUDFLARE_API_TOKEN: ${{ env.TEST_PR_HEAD_REPO == github.repository && secrets.CLOUDFLARE_API_TOKEN || '' }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
TLS_TEST_DOMAIN: "test.hypeman-development.com"
TLS_ALLOWED_DOMAINS: '*.hypeman-development.com'
HYPEMAN_TEST_PREWARM_STRICT: "1"
Expand All @@ -283,7 +280,7 @@ jobs:
make test TEST_TIMEOUT=20m

report-pr-test:
if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }}
if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.pr_number != '' && (needs.test.result == 'success' || needs.test.result == 'failure') }}
needs: test
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -323,7 +320,11 @@ jobs:
--field target_url="$GITHUB_SERVER_URL/$REPO/actions/runs/$GITHUB_RUN_ID"

test-darwin:
if: ${{ github.repository == 'kernel/hypeman' && (!inputs.pr_head_repo || inputs.pr_head_repo == github.repository) && (!inputs.pr_head_sha || inputs.pr_head_sha == github.sha) }}
runs-on: [self-hosted, macos, arm64]
permissions:
contents: read
id-token: write
concurrency:
group: macos-ci-test-${{ inputs.pr_head_sha || github.ref }}
cancel-in-progress: true
Expand All @@ -332,8 +333,6 @@ jobs:
steps:
- uses: actions/checkout@v4.4.0
with:
repository: ${{ env.TEST_SOURCE_REPO }}
ref: ${{ env.TEST_SOURCE_REF }}
persist-credentials: false
- uses: actions/setup-go@v6.5.0
with:
Expand Down Expand Up @@ -368,11 +367,10 @@ jobs:
done

docker info
- name: Login to Docker Hub
uses: docker/login-action@v3.7.0
- name: Login to Docker Hub with OIDC
uses: docker/login-action@v4.7.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
username: onkernel
- name: Install dependencies
run: |
brew list e2fsprogs &>/dev/null || brew install e2fsprogs
Expand Down Expand Up @@ -440,14 +438,15 @@ jobs:
e2e-install:
runs-on: [self-hosted, macos, arm64]
needs: test-darwin
permissions:
contents: read
id-token: write
concurrency:
group: macos-ci-e2e-${{ inputs.pr_head_sha || github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4.4.0
with:
repository: ${{ env.TEST_SOURCE_REPO }}
ref: ${{ env.TEST_SOURCE_REF }}
persist-credentials: false
- uses: actions/setup-go@v6.5.0
with:
Expand All @@ -473,11 +472,10 @@ jobs:
# Self-hosted runners retain Docker layers across jobs. Prune only
# what is stale, and fall back to a full prune when host disk is low.
bash scripts/docker-ci-cleanup.sh
- name: Login to Docker Hub
uses: docker/login-action@v3.7.0
- name: Login to Docker Hub with OIDC
uses: docker/login-action@v4.7.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
username: onkernel
- name: Build E2E install artifacts
env:
GITHUB_TOKEN: ${{ github.token }}
Expand Down
Loading