Skip to content
Open
4 changes: 2 additions & 2 deletions .github/workflows/commercial-readiness-agent-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ permissions:
contents: read

concurrency:
group: commercial-readiness-agent-coverage-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
exact-commercial-agent-coverage:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/controlplane-schema-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ permissions:
contents: read

concurrency:
group: controlplane-schema-coverage-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
exact-controlplane-schema-coverage:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/openssf-evidence-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
exact-openssf-evidence-coverage:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pinned-https-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
exact-pinned-https-coverage:
runs-on: ubuntu-latest
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/prepare-pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ on:
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.repository }}
Comment thread
seonghobae marked this conversation as resolved.
queue: max
cancel-in-progress: false

jobs:
prepare-release:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -215,7 +220,7 @@ jobs:

- name: Clean local release artifacts
run: |
rm -rf build dist *.egg-info release-sbom.cdx.json release-provenance.json
rm -rf -- build dist ./*.egg-info release-sbom.cdx.json release-provenance.json

- name: Commit and push release branch
run: |
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.repository }}
Comment thread
seonghobae marked this conversation as resolved.
queue: max
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/retention-audit-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ permissions:
contents: read

concurrency:
group: retention-audit-coverage-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
exact-retention-audit-coverage:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/scan-path-context-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
exact-coverage:
runs-on: ubuntu-latest
Expand Down
47 changes: 4 additions & 43 deletions .github/workflows/security-process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ on:
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
appguardrail-scan:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -51,46 +55,3 @@ jobs:
path: appguardrail-scan.txt
if-no-files-found: error
retention-days: 7
Comment thread
seonghobae marked this conversation as resolved.

trivy-fs:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Run Trivy FS scan
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: fs
scan-ref: .
scanners: vuln,secret,misconfig
severity: CRITICAL,HIGH
ignore-unfixed: true
format: sarif
output: trivy-results.sarif
exit-code: "1"

- name: Upload Trivy SARIF to code scanning
if: >-
always()
&& hashFiles('trivy-results.sarif') != ''
&& (github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository)
uses: github/codeql-action/upload-sarif@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
with:
sarif_file: trivy-results.sarif

- name: Upload Trivy SARIF artifact
if: always() && hashFiles('trivy-results.sarif') != ''
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: trivy-results
path: trivy-results.sarif
if-no-files-found: error
retention-days: 7
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
Comment thread
seonghobae marked this conversation as resolved.

jobs:
pytest:
name: Unit tests (Python ${{ matrix.python-version }})
Expand Down
2 changes: 1 addition & 1 deletion tests/test_retention_audit_release_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_exact_coverage_workflow_tracks_every_core_surface() -> None:
).read_text(encoding="utf-8")

assert "permissions:\n contents: read" in workflow
assert "cancel-in-progress: true" in workflow
assert "cancel-in-progress: ${{ github.event_name == 'pull_request' }}" in workflow
assert "appguardrail_core/audit_events.py" in workflow
assert "appguardrail_core/retention_policy.py" in workflow
assert "tests/test_audit_events.py" in workflow
Expand Down
35 changes: 35 additions & 0 deletions tests/test_workflow_concurrency_contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""GitHub Actions concurrency contracts."""

from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
WORKFLOWS = ROOT / ".github" / "workflows"
PR_WORKFLOWS = (
"commercial-readiness-agent-coverage.yml",
"controlplane-schema-coverage.yml",
"openssf-evidence-coverage.yml",
"pinned-https-coverage.yml",
"retention-audit-coverage.yml",
"scan-path-context-coverage.yml",
"security-process.yml",
"tests.yml",
)
RELEASE_WORKFLOWS = ("prepare-pypi-release.yml", "publish-pypi.yml")


def test_pr_workflows_cancel_only_superseded_heads() -> None:
for name in PR_WORKFLOWS:
workflow = (WORKFLOWS / name).read_text(encoding="utf-8")
assert "${{ github.workflow }}-${{ github.repository }}-" in workflow
assert "github.event.pull_request.number || github.run_id" in workflow
assert "cancel-in-progress: ${{ github.event_name == 'pull_request' }}" in workflow


def test_release_workflows_serialize_without_dropping_delivery() -> None:
for name in RELEASE_WORKFLOWS:
workflow = (WORKFLOWS / name).read_text(encoding="utf-8")
assert "group: ${{ github.workflow }}-${{ github.repository }}" in workflow
assert "github.run_id" not in workflow.split("jobs:", 1)[0]
assert "queue: max" in workflow
assert "cancel-in-progress: false" in workflow
Loading