From d4ebf99e5e22f800a88c8314ea0f6cd27eb9396b Mon Sep 17 00:00:00 2001
From: Tam Mach <sayboras@yahoo.com>
Date: Mon, 21 Sep 2020 07:48:49 +1000
Subject: [PATCH] build(go): Check if go.mod and go.sum are up to dated (#1377)

This commit is to add job to check if go.mod and go.sum are up to
date.

Also add go.sum into .gitattributes so that it will be considered
as generated file in PR review.

Signed-off-by: Tam Mach <sayboras@yahoo.com>
---
 .gitattributes           |  1 +
 .github/workflows/pr.yml | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
 create mode 100644 .gitattributes

diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..32f1001b
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+go.sum linguist-generated
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index 6311caa7..c4b6fd39 100644
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/pr.yml
@@ -8,6 +8,21 @@ on:
       - master
   pull_request:
 jobs:
+  # Check if there any dirty change for go mod tidy
+  go-mod:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Install Go
+        uses: actions/setup-go@v2
+        with:
+          go-version: 1.15
+      - name: Checkout code
+        uses: actions/checkout@v2
+      - name: Check go mod
+        run: |
+          go mod tidy
+          git diff --exit-code
+
   # We already run the current golangci-lint in tests, but here we test
   # our GitHub action with the latest stable golangci-lint.
   golangci-lint: