From 929e9def69667aff88b0dd21458d7073cc31c801 Mon Sep 17 00:00:00 2001 From: midasdf Date: Fri, 3 Apr 2026 04:11:40 +0900 Subject: [PATCH 1/2] Add CI build/test and security audit workflow --- .github/workflows/ci.yml | 78 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bc87c26 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,78 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + schedule: + - cron: '0 0 * * 1' + +permissions: + contents: read + +jobs: + check: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + + - name: Install Zig + run: | + curl -sL "https://ziglang.org/download/0.15.2/zig-x86_64-linux-0.15.2.tar.xz" | tar -xJ + echo "$PWD/zig-x86_64-linux-0.15.2" >> "$GITHUB_PATH" + + - name: Format check + run: zig fmt --check src/ + + - name: Build + run: zig build + + security-audit: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Zig Security Audit + env: + GH_EVENT: ${{ github.event_name }} + GH_BASE_REF: ${{ github.event.pull_request.base.ref }} + run: | + echo "## Zig Security Audit" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "| Pattern | Count | Level |" >> "$GITHUB_STEP_SUMMARY" + echo "|---------|-------|-------|" >> "$GITHUB_STEP_SUMMARY" + + total=0 + + audit() { + local pattern="$1" level="$2" label="$3" + local count + count=$(grep -rn --include='*.zig' -e "$pattern" src/ 2>/dev/null | wc -l) + if [ "$count" -gt 0 ]; then + echo "| \`$label\` | $count | $level |" >> "$GITHUB_STEP_SUMMARY" + total=$((total + count)) + fi + if [ "$GH_EVENT" = "pull_request" ] && [ -n "$GH_BASE_REF" ]; then + git diff --name-only "origin/$GH_BASE_REF" -- '*.zig' 2>/dev/null | while read -r file; do + [ -f "$file" ] || continue + grep -n "$pattern" "$file" 2>/dev/null | while IFS=: read -r line content; do + echo "::warning file=$file,line=$line::[$level] $label: $content" + done + done + fi + } + + audit '@setRuntimeSafety\(false\)' 'Critical' '@setRuntimeSafety(false)' + audit '@ptrCast' 'Tracked' '@ptrCast' + audit '@ptrFromInt' 'Tracked' '@ptrFromInt' + audit '@intFromPtr' 'Tracked' '@intFromPtr' + audit '@alignCast' 'Tracked' '@alignCast' + audit 'catch unreachable' 'Review' 'catch unreachable' + audit 'orelse unreachable' 'Review' 'orelse unreachable' + audit '@cImport' 'Info' '@cImport' + + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "**Total: $total** patterns tracked" >> "$GITHUB_STEP_SUMMARY" + echo "_Not bugs — areas requiring careful review during changes._" >> "$GITHUB_STEP_SUMMARY" From 654d6f8b72e2368ae4cb4a6c1c9c3b2cb5c1eef9 Mon Sep 17 00:00:00 2001 From: midasdf Date: Fri, 3 Apr 2026 05:13:56 +0900 Subject: [PATCH 2/2] Make fmt check non-blocking (continue-on-error) --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc87c26..c2228f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,7 @@ jobs: echo "$PWD/zig-x86_64-linux-0.15.2" >> "$GITHUB_PATH" - name: Format check + continue-on-error: true run: zig fmt --check src/ - name: Build