Skip to content

Commit 5c61df1

Browse files
authored
add github actions workflow file (#299)
* add github actions workflow file * update gh actions
1 parent c06b9f4 commit 5c61df1

File tree

2 files changed

+176
-1
lines changed

2 files changed

+176
-1
lines changed

.github/workflows/ci.yml

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
name: NTH Continuous Integration and Release
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
env:
6+
DEFAULT_GO_VERSION: ^1.15
7+
GITHUB_USERNAME: ${{ secrets.EC2_BOT_GITHUB_USERNAME }}
8+
GITHUB_TOKEN: ${{ secrets.EC2_BOT_GITHUB_TOKEN }}
9+
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
10+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
11+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
12+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
13+
14+
jobs:
15+
16+
fastTests:
17+
name: Fast Tests and Lints
18+
runs-on: ubuntu-20.04
19+
steps:
20+
- name: Set up Go 1.x
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: ${{ env.DEFAULT_GO_VERSION }}
24+
25+
- name: Check out code into the Go module directory
26+
uses: actions/checkout@v2
27+
28+
- name: Unit Tests
29+
run: make unit-test
30+
31+
- name: Lints
32+
run: make spellcheck shellcheck helm-lint
33+
34+
- name: Go Report Card Tests
35+
run: make go-report-card-test
36+
37+
- name: Generate K8s YAML
38+
run: make generate-k8s-yaml
39+
40+
buildLinux:
41+
name: Build Linux Binaries
42+
runs-on: ubuntu-20.04
43+
steps:
44+
- name: Set up Go 1.x
45+
uses: actions/setup-go@v2
46+
with:
47+
go-version: ${{ env.DEFAULT_GO_VERSION }}
48+
49+
- name: Check out code into the Go module directory
50+
uses: actions/checkout@v2
51+
- name: Build Linux Binaries
52+
run: make build-binaries
53+
54+
buildLinuxDocker:
55+
name: Build Linux Docker Images
56+
runs-on: ubuntu-20.04
57+
steps:
58+
- name: Set up Go 1.x
59+
uses: actions/setup-go@v2
60+
with:
61+
go-version: ${{ env.DEFAULT_GO_VERSION }}
62+
63+
- name: Check out code into the Go module directory
64+
uses: actions/checkout@v2
65+
66+
- name: Build Linux Docker Images
67+
run: make build-docker-images
68+
69+
buildWindows:
70+
name: Build Windows Binaries
71+
runs-on: windows-2019
72+
steps:
73+
- name: Set up Go 1.x
74+
uses: actions/setup-go@v2
75+
with:
76+
go-version: ${{ env.DEFAULT_GO_VERSION }}
77+
78+
- name: Check out code into the Go module directory
79+
uses: actions/checkout@v2
80+
81+
- name: Build Windows Binaries
82+
run: choco install make && choco install zip && RefreshEnv.cmd && make build-binaries-windows
83+
84+
buildWindowsDocker:
85+
name: Build Windows Docker Images
86+
runs-on: windows-2019
87+
steps:
88+
- name: Set up Go 1.x
89+
uses: actions/setup-go@v2
90+
with:
91+
go-version: ${{ env.DEFAULT_GO_VERSION }}
92+
93+
- name: Check out code into the Go module directory
94+
uses: actions/checkout@v2
95+
96+
- name: Build Windows Docker Images
97+
run: choco install make && RefreshEnv.cmd && make build-docker-images-windows
98+
99+
e2e:
100+
name: E2E Tests
101+
runs-on: ubuntu-20.04
102+
strategy:
103+
matrix:
104+
k8sVersion: [1.14, 1.15, 1.16, 1.17, 1.18, 1.19]
105+
steps:
106+
- name: Set up Go 1.x
107+
uses: actions/setup-go@v2
108+
with:
109+
go-version: ${{ env.DEFAULT_GO_VERSION }}
110+
111+
- name: Check out code into the Go module directory
112+
uses: actions/checkout@v2
113+
114+
- name: E2E Tests
115+
run: test/k8s-local-cluster-test/run-test -v ${{ matrix.k8sVersion }}
116+
117+
releaseLinux:
118+
name: Release Linux
119+
runs-on: ubuntu-20.04
120+
needs: [e2e, buildWindows, buildWindowsDocker, buildLinux, buildLinuxDocker, fastTests]
121+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
122+
steps:
123+
- name: Set up Go 1.x
124+
uses: actions/setup-go@v2
125+
with:
126+
go-version: ${{ env.DEFAULT_GO_VERSION }}
127+
128+
- name: Check out code into the Go module directory
129+
uses: actions/checkout@v2
130+
131+
- name: License Check
132+
run: make license-test
133+
134+
- name: Release Linux Assets
135+
run: make release
136+
137+
releaseWindows:
138+
name: Release Windows
139+
runs-on: windows-2019
140+
needs: [e2e, buildWindows, buildWindowsDocker, buildLinux, buildLinuxDocker, fastTests]
141+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
142+
steps:
143+
- name: Set up Go 1.x
144+
uses: actions/setup-go@v2
145+
with:
146+
go-version: ${{ env.DEFAULT_GO_VERSION }}
147+
148+
- name: Check out code into the Go module directory
149+
uses: actions/checkout@v2
150+
151+
- name: Release Windows Assets
152+
run: choco install make && choco install zip && RefreshEnv.cmd && make release-windows
153+
154+
release:
155+
name: Release
156+
runs-on: ubuntu-20.04
157+
needs: [releaseLinux, releaseWindows]
158+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
159+
steps:
160+
- name: Set up Go 1.x
161+
uses: actions/setup-go@v2
162+
with:
163+
go-version: ${{ env.DEFAULT_GO_VERSION }}
164+
165+
- name: Check out code into the Go module directory
166+
uses: actions/checkout@v2
167+
168+
- name: Create eks-charts PR
169+
run: make ekscharts-sync-release
170+
171+
- name: Sync Readme to Dockerhub
172+
run: make sync-readme-to-dockerhub
173+
174+
- name: Create NTH README Update PR
175+
run: make create-release-prep-pr-readme

test/go-report-card-test/run-report-card-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ if grep -r -i -e 'cancelled' --exclude-dir={build,"$(basename $SCRIPTPATH)"} $SC
2424
EXIT_CODE=3
2525
fi
2626

27-
docker run -it -v $SCRIPTPATH/../../:/app go-report-card-cli /go/bin/goreportcard-cli -v -t $THRESHOLD
27+
docker run -t -v $SCRIPTPATH/../../:/app go-report-card-cli /go/bin/goreportcard-cli -v -t $THRESHOLD
2828

2929
exit $EXIT_CODE

0 commit comments

Comments
 (0)