github: cache ~/go/pkg/mod

Cache ~/go/pkg/mod using actions/cache@v1. And update actions/checkout to v2 for some improved performance.

Change-Id: I00b7feaa205593bd56162e6bb89c2ef9c17bbd89
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4780
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 34351ff..7df84f5 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -20,8 +20,17 @@
       uses: actions/setup-go@v1
       with:
         go-version: ${{ matrix.go-version }}
+
     - name: Checkout code
-      uses: actions/checkout@v1
+      uses: actions/checkout@v2
+
+    - name: Cache Go modules
+      uses: actions/cache@v1
+      with:
+        path: ~/go/pkg/mod
+        key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
+        restore-keys: |
+          ${{ runner.os }}-${{ matrix.go-version }}-go-
 
     - name: Test
       run: go test ./...