-
Notifications
You must be signed in to change notification settings - Fork 2
118 lines (100 loc) · 3.5 KB
/
commit.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Copyright 2022 Tetrate
# Licensed under the Apache License, Version 2.0 (the "License")
name: "commit"
on:
push:
branches:
- master
paths-ignore:
- "**/*.md"
- "**/*.png"
pull_request:
branches:
- master
paths-ignore:
- "**/*.md"
- "**/*.png"
# Allows triggering the workflow manually in github actions page.
workflow_dispatch:
defaults:
run: # use bash for all operating systems unless overridden
shell: bash
jobs:
check:
name: check
runs-on: ubuntu-20.04
timeout-minutes: 90 # instead of 360 by default.
strategy:
fail-fast: false # don't fail fast as sometimes failures are operating system specific
steps:
- name: Cancel when duplicated
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v2 # shallow checkout.
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.17.x"
- name: Download cache for Tools
uses: actions/cache@v2
with:
path: ./.cache/tools
# Downloading cached tools needs to use an exact key, since we
# currently don't do versioning for each cached binary.
key: ${{ runner.os }}-check-tools-${{ hashFiles('Tools.mk') }}
- name: Download cache for Go
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
# When we update Tools.mk, there is a possibility we download a new Go dependencies.
key: ${{ runner.os }}-check-go-${{ hashFiles('go.mod', 'go.sum', 'Tools.mk') }}
restore-keys: ${{ runner.os }}-check-go
- name: Get Linter cache key
run: |
echo "::set-output name=name::$(/bin/date -u "+%Y%m%d")"
id: get-linter-cache-key
# We cache golangci-lint run per day.
- name: Download cache for Linter
uses: actions/cache@v2
with:
path: ./.cache/golangci-lint
key: ${{ runner.os }}-golangci-lint-${{ hashFiles('go.mod') }}-${{ steps.get-linter-cache-key.outputs.name }}
restore-keys: ${{ runner.os }}-golangci-lint-
- name: Check
run: make check # `make check` does all the necessary checks.
test:
needs: check
name: test
runs-on: ubuntu-20.04
timeout-minutes: 90 # instead of 360 by default.
strategy:
fail-fast: false # don't fail fast as sometimes failures are operating system specific
steps:
- name: Cancel when duplicated
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v2 # shallow checkout.
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.17.x"
- name: Download cache for Tools
uses: actions/cache@v2
with:
path: ./.cache/tools
# Downloading cached tools needs to use an exact key, since we
# currently don't do versioning for each cached binary.
key: ${{ runner.os }}-tools-${{ hashFiles('Tools.mk') }}
- name: Download cache for Go
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
# When we update Tools.mk, there is a possibility we download a new Go dependencies.
key: ${{ runner.os }}-go-${{ hashFiles('go.mod', 'go.sum', 'Tools.mk') }}
restore-keys: ${{ runner.os }}-go
- name: Test and build
run: make test build