From 9b0a81a325b56adcd3076c69b94caee7a1e1905b Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Tue, 3 Sep 2024 15:23:59 +0000 Subject: [PATCH] check docs and schema Signed-off-by: Austin Abro --- .github/workflows/check-go-mod.yml | 24 ++++++++++++++++++++++++ Makefile | 4 ++++ hack/check-go-mod.sh | 11 +++++++++++ 3 files changed, 39 insertions(+) create mode 100644 .github/workflows/check-go-mod.yml create mode 100755 hack/check-go-mod.sh diff --git a/.github/workflows/check-go-mod.yml b/.github/workflows/check-go-mod.yml new file mode 100644 index 0000000000..d311080195 --- /dev/null +++ b/.github/workflows/check-go-mod.yml @@ -0,0 +1,24 @@ +name: Check for go mod changes +on: + pull_request: + merge_group: + +permissions: + contents: read + +jobs: + validate-go-mod: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Setup golang + uses: ./.github/actions/golang + + - name: Docs and schemas + run: "make test-go-mod" + + - name: Save logs + if: always() + uses: ./.github/actions/save-logs diff --git a/Makefile b/Makefile index bdce6970d3..498ed34eb8 100644 --- a/Makefile +++ b/Makefile @@ -221,6 +221,10 @@ test-docs-and-schema: test-cves: go run main.go tools sbom scan . -o json --exclude './site' --exclude './examples' | grype --fail-on low +test-go-mod: + go mod tidy + hack/check-go-mod.sh + cve-report: ## Create a CVE report for the current project (must `brew install grype` first) @test -d ./build || mkdir ./build go run main.go tools sbom scan . -o json --exclude './site' --exclude './examples' | grype -o template -t hack/grype.tmpl > build/zarf-known-cves.csv diff --git a/hack/check-go-mod.sh b/hack/check-go-mod.sh new file mode 100755 index 0000000000..f5dae69023 --- /dev/null +++ b/hack/check-go-mod.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [ -z "$(git status -s go.mod go.sum)" ]; then + echo "Success!" + exit 0 +else + git diff go.mod go.sum + exit 1 +fi