Skip to content

Commit 647307e

Browse files
committed
Add CI workflow for testing Go project
On every push or pull request that modifies relevant files: - Build application and upload the binary as a workflow artifact for local testing - Run unit tests
1 parent c36c3d2 commit 647307e

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/test-go.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Test Go
2+
3+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
paths:
7+
- ".github/workflows/test-go.yml"
8+
- "Taskfile.yml"
9+
- "**.go"
10+
pull_request:
11+
paths:
12+
- ".github/workflows/test-go.yml"
13+
- "Taskfile.yml"
14+
- "**.go"
15+
workflow_dispatch:
16+
repository_dispatch:
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v2
25+
26+
- name: Install Go
27+
uses: actions/setup-go@v2
28+
with:
29+
go-version: "1.14"
30+
31+
- name: Install Taskfile
32+
uses: arduino/actions/setup-taskfile@master
33+
with:
34+
repo-token: ${{ secrets.GITHUB_TOKEN }}
35+
version: 3.x
36+
37+
- name: Configure Git for go get access to private repo
38+
run: git config --global url."https://${{ secrets.REPO_SCOPE_TOKEN }}:[email protected]/".insteadOf "https://github.com/"
39+
40+
- name: Build application
41+
run: task go:build
42+
43+
- name: Save binary as workflow artifact
44+
uses: actions/upload-artifact@v2
45+
with:
46+
if-no-files-found: error
47+
path: libraries-repository-engine
48+
name: libraries-repository-engine
49+
50+
test:
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v2
56+
57+
- name: Install Go
58+
uses: actions/setup-go@v2
59+
with:
60+
go-version: "1.14"
61+
62+
- name: Install Taskfile
63+
uses: arduino/actions/setup-taskfile@master
64+
with:
65+
repo-token: ${{ secrets.GITHUB_TOKEN }}
66+
version: 3.x
67+
68+
- name: Configure Git for go get access to private repo
69+
run: git config --global url."https://${{ secrets.REPO_SCOPE_TOKEN }}:[email protected]/".insteadOf "https://github.com/"
70+
71+
- name: Run tests
72+
run: task go:test

0 commit comments

Comments
 (0)