From d4e6b325bfc80c3c7a9f47cc8b8e99abe69bcb9f Mon Sep 17 00:00:00 2001 From: Todd Treece <360020+toddtreece@users.noreply.github.com> Date: Mon, 25 Mar 2024 18:47:34 -0400 Subject: [PATCH] Chore: Add github action to check go module updates (#84936) --- .github/CODEOWNERS | 1 + .github/workflows/pr-go-workspace-check.yml | 47 +++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/pr-go-workspace-check.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a2e21194353..c71208a9291 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -694,6 +694,7 @@ embed.go @grafana/grafana-as-code /.github/workflows/i18n-crowdin-download.yml @grafana/grafana-frontend-platform /.github/workflows/feature-toggle-cleanup.yml @tolzhabayev /.github/workflows/scripts/feature-toggle-cleanup/feature-toggle-cleanup.js @tolzhabayev +/.github/workflows/pr-go-workspace-check.yml @grafana/grafana-app-platform-squad # Generated files not requiring owner approval /packages/grafana-data/src/types/featureToggles.gen.ts @grafanabot diff --git a/.github/workflows/pr-go-workspace-check.yml b/.github/workflows/pr-go-workspace-check.yml new file mode 100644 index 00000000000..ef7da237da8 --- /dev/null +++ b/.github/workflows/pr-go-workspace-check.yml @@ -0,0 +1,47 @@ +name: "Go Workspace Check" + +on: + workflow_dispatch: + pull_request: + branches: [main] + paths: + - '**/go.work' + - '**/go.work.sum' + - '**/go.mod' + - '**/go.sum' + +jobs: + check: + name: Go Workspace Check + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set go version + uses: actions/setup-go@v4 + with: + go-version: '1.21.8' + + - name: Workspace Sync + run: go work sync + + - name: Check for go mod & workspace changes + run: | + if ! git diff --exit-code --quiet; then + echo "Changes detected. Please run 'go work sync' and commit the changes." + exit 1 + fi + + - name: Build + run: make build-go + + - name: Check for go workspace changes + run: | + if ! git diff --exit-code --quiet; then + echo "Changes detected. Please run 'make build-go' and commit the changes." + exit 1 + fi \ No newline at end of file