From d824c4f7675cb0abccef810bee147e39e058c53b Mon Sep 17 00:00:00 2001 From: harshitsinghbhandari <24b4506@iitb.ac.in> Date: Tue, 26 May 2026 21:02:58 +0530 Subject: [PATCH] ci: add Go build/test and gitleaks secret-scan workflows - go.yml: gofmt check, build, vet, and race-enabled tests for backend/, triggered on backend changes and pushes to main. - gitleaks.yml: secret scanning on PRs and main using gitleaks-action v1 (license-free; v2 requires GITLEAKS_LICENSE for org repos). Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/gitleaks.yml | 22 +++++++++++++++++ .github/workflows/go.yml | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .github/workflows/gitleaks.yml create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/gitleaks.yml b/.github/workflows/gitleaks.yml new file mode 100644 index 000000000..15c70781d --- /dev/null +++ b/.github/workflows/gitleaks.yml @@ -0,0 +1,22 @@ +name: gitleaks + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + scan: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # gitleaks-action v1 scans for committed secrets and needs no license + # key (v2 requires GITLEAKS_LICENSE for organization repos). + - name: Scan for secrets + uses: zricethezav/gitleaks-action@v1.6.0 diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 000000000..e3ceaf1cc --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,44 @@ +name: Go + +on: + push: + branches: [main] + pull_request: + paths: + - "backend/**" + - ".github/workflows/go.yml" + +permissions: + contents: read + +jobs: + build-test: + runs-on: ubuntu-latest + defaults: + run: + working-directory: backend + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + cache: false + + - name: Check formatting + run: | + unformatted=$(gofmt -l .) + if [ -n "$unformatted" ]; then + echo "These files need gofmt:" + echo "$unformatted" + exit 1 + fi + + - name: Build + run: go build ./... + + - name: Vet + run: go vet ./... + + - name: Test + run: go test -race ./...