Skip to content
Merged
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
25 changes: 16 additions & 9 deletions .github/workflows/codapult-guard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ jobs:
;;
esac
else
# This repository is a Guard integration fixture. Keep push runs
# focused on Guard; upstream project checks are covered separately.
# Keep this hosted fixture's push run focused on Guard itself.
check_args=(--no-project-checks --tools off)
fi
if [ -n "$POLICY_BASE" ]; then
Expand All @@ -134,15 +133,23 @@ jobs:
GUARD_POLICY_MODE: ${{ vars.CODAPULT_GUARD_POLICY_MODE || 'host-review' }}
run: |
node --input-type=module <<'NODE'
import { appendFileSync, existsSync, readFileSync, statSync } from 'node:fs';
import { appendFileSync, readFileSync } from 'node:fs';
const resultFile = process.env.GUARD_RESULT_FILE;
if (!resultFile || !existsSync(resultFile) || statSync(resultFile).size === 0) {
let resultContent;
try {
if (!resultFile) throw new Error('missing result file path');
resultContent = readFileSync(resultFile, 'utf8');
} catch {
appendFileSync(process.env.GITHUB_STEP_SUMMARY, '## Codapult Guard\n\n- Result: **incomplete** (verification did not produce a result file).\n');
process.exit(0);
}
if (resultContent.length === 0) {
appendFileSync(process.env.GITHUB_STEP_SUMMARY, '## Codapult Guard\n\n- Result: **incomplete** (verification did not produce a result file).\n');
process.exit(0);
}
let result;
try {
result = JSON.parse(readFileSync(resultFile, 'utf8'));
result = JSON.parse(resultContent);
} catch {
appendFileSync(process.env.GITHUB_STEP_SUMMARY, '## Codapult Guard\n\n- Result: **incomplete** (verification result was not valid JSON).\n');
process.exit(0);
Expand Down Expand Up @@ -245,12 +252,12 @@ jobs:
GUARD_STATEMENT_FILE: ${{ runner.temp }}/guard-verification.intoto.json
run: |
node --input-type=module <<'NODE'
import { existsSync, readFileSync, rmSync } from 'node:fs';
import { readFileSync, rmSync } from 'node:fs';
const statementFile = process.env.GUARD_STATEMENT_FILE;
const resultFile = process.env.GUARD_RESULT_FILE;
let result;
try {
if (!resultFile || !existsSync(resultFile)) throw new Error('missing result');
if (!resultFile) throw new Error('missing result path');
result = JSON.parse(readFileSync(resultFile, 'utf8'));
} catch {
if (statementFile) rmSync(statementFile, { force: true });
Expand All @@ -275,7 +282,7 @@ jobs:

- name: Upload verification receipt
if: always()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: codapult-guard-verification
path: |
Expand Down Expand Up @@ -310,7 +317,7 @@ jobs:

- name: Upload PR review packet
if: always() && github.event_name == 'pull_request'
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: codapult-guard-review
path: ${{ runner.temp }}/guard-review.json
Expand Down
Loading