Skip to content

Commit

Permalink
Use Github workflow cache for Go CI builds (#2499)
Browse files Browse the repository at this point in the history
We cache downloaded Go modules and the Go build cache. The cache is
OS-specific. See
https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds

Signed-off-by: Antonin Bas <abas@vmware.com>
  • Loading branch information
antoninbas authored Aug 4, 2021
1 parent 552da38 commit 17b0a7b
Showing 1 changed file with 59 additions and 28 deletions.
87 changes: 59 additions & 28 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
- main
- release-*

env:
go-cache-name: go

jobs:
test-unit:
name: Unit test
Expand All @@ -17,18 +20,28 @@ jobs:
os: [ubuntu-latest, windows-2019]
runs-on: ${{ matrix.os }}
steps:

- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15

- name: Check-out code
uses: actions/checkout@v2

- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ env.go-cache-name }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ env.go-cache-name }}-
- name: Run unit tests
run: make test-unit

- name: Codecov
uses: codecov/codecov-action@v1
with:
Expand All @@ -37,26 +50,35 @@ jobs:
flags: unit-tests
name: codecov-unit-test


golangci-lint:
name: Golangci-lint
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:

- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15

- name: Check-out code
uses: actions/checkout@v2

- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ env.go-cache-name }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ env.go-cache-name }}-
- name: Run golangci-lint
run: make golangci

- name: Run golangci-lint for netpol
working-directory: hack/netpol
run: make golangci
Expand All @@ -65,89 +87,98 @@ jobs:
name: Build Antrea and antctl binaries
runs-on: [ubuntu-latest]
steps:

- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15

- name: Check-out code
uses: actions/checkout@v2

- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ env.go-cache-name }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ env.go-cache-name }}-
- name: Build Antrea binaries for amd64
run: GOARCH=amd64 make bin

- name: Build Antrea binaries for arm64
run: GOARCH=arm64 make bin

- name: Build Antrea binaries for arm
run: GOARCH=arm make bin

- name: Build antctl binaries
run: make antctl

windows-bin:
name: Build Antrea Windows binaries
runs-on: [ubuntu-latest]
steps:

- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15

- name: Check-out code
uses: actions/checkout@v2

- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ env.go-cache-name }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ env.go-cache-name }}-
- name: Build Antrea windows binaries
run: make windows-bin

tidy-codegen-manifest:
name: Check tidy, code generation and manifest
runs-on: [ubuntu-latest]
steps:

- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15

- name: Check-out code
uses: actions/checkout@v2

# tidy check need to be run before code generation which will regenerate codes.
- name: Check tidy
run: make test-tidy

- name: Check code generation
run: ./ci/check-codegen.sh

- name: Check manifest
run: ./ci/check-manifest.sh

verify:
name: Verify docs and spelling
runs-on: [ubuntu-latest]
steps:

- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15

- name: Check-out code
uses: actions/checkout@v2

- name: Run verify scripts
run: make verify

- name: Checking for broken Markdown links
uses: antoninbas/github-action-markdown-link-check@1.0.9-pre
with:
folder-path: './docs'
file-path: './README.md, ./CHANGELOG.md, ./CONTRIBUTING.md, ./GOVERNANCE.md, ./MAINTAINERS.md, ./ROADMAP.md, ./SECURITY.md'
config-file: 'hack/.md_links_config.json'

- name: Markdownlint
run: |
sudo npm install -g markdownlint-cli
Expand Down

0 comments on commit 17b0a7b

Please sign in to comment.