Skip to content

fix: harden autofix paths and isolate CodeQL output #67

fix: harden autofix paths and isolate CodeQL output

fix: harden autofix paths and isolate CodeQL output #67

Workflow file for this run

name: Togi Mutation Testing (advisory)
on:
pull_request:
branches: [main]
permissions:
contents: read
pull-requests: write
security-events: write
jobs:
mutation-test:
name: Mutation testing (advisory)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ runner.arch }}-cargo-togi-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ runner.arch }}-cargo-togi-
- name: Install Togi
env:
TOGI_ARCHIVE: togi-linux-x86_64.tar.gz
TOGI_SHA256: f460f19e4f226241ad333cac46fbd01c9458866aabae34827715168c84fdda62
TOGI_VERSION: v0.2.0
run: |
set -euo pipefail
install_dir="$RUNNER_TEMP/togi"
mkdir -p "$install_dir" "$HOME/.local/bin"
curl --fail --location --retry 3 --silent --show-error \
"https://github.com/Darkroom4364/togi/releases/download/$TOGI_VERSION/$TOGI_ARCHIVE" \
--output "$install_dir/$TOGI_ARCHIVE"
(
cd "$install_dir"
printf '%s %s\n' "$TOGI_SHA256" "$TOGI_ARCHIVE" | sha256sum --check --strict -
)
tar xzf "$install_dir/$TOGI_ARCHIVE" -C "$install_dir"
install -m 0755 "$install_dir/togi" "$HOME/.local/bin/togi"
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Run advisory mutation check
id: togi
continue-on-error: true
env:
BASE_REF: ${{ github.base_ref }}
run: |
args=(
check
--base "origin/${BASE_REF}"
--test-cmd "cargo test --locked --all-features"
--timeout 60
--format sarif
--pr-comment togi-pr-comment.md
)
if [[ -f .togi-baseline ]]; then
args+=(--check-baseline)
fi
togi "${args[@]}" > togi-report.sarif
- name: Upload SARIF
if: ${{ always() && github.event.pull_request.head.repo.full_name == github.repository && hashFiles('togi-report.sarif') != '' }}
continue-on-error: true
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: togi-report.sarif
category: mutation-testing
- name: Publish PR summary
if: ${{ always() && github.event.pull_request.head.repo.full_name == github.repository && hashFiles('togi-pr-comment.md') != '' }}
continue-on-error: true
uses: actions/github-script@v7
with:
script: |
const fs = require("fs");
const marker = "<!-- togi-mutation-report -->";
const body = fs.readFileSync("togi-pr-comment.md", "utf8");
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(
(comment) =>
comment.user?.login === "github-actions[bot]" &&
comment.body?.includes(marker),
);
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}