Skip to content

Commit 921d412

Browse files
authored
Merge pull request #8 from bcmi-labs/add-build-test-infrastructure
Set up infrastructure for building and testing Go project
2 parents ddf7642 + 647307e commit 921d412

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-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

Taskfile.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# See: https://taskfile.dev/#/usage
2+
version: "3"
3+
4+
env:
5+
GOPATH: "$(echo $PWD)"
6+
7+
tasks:
8+
go:deps:
9+
desc: Install dependencies
10+
cmds:
11+
- go get github.com/arduino/arduino-modules/git
12+
- go get github.com/arduino/golang-concurrent-workers
13+
- go get github.com/blang/semver
14+
- go get github.com/google/go-github/github
15+
- go get github.com/stretchr/testify
16+
- go get github.com/vaughan0/go-ini
17+
18+
go:build:
19+
desc: Build the project
20+
deps:
21+
- task: go:deps
22+
cmds:
23+
- go build arduino.cc/repository/libraries-repository-engine
24+
25+
go:test:
26+
desc: Run unit tests
27+
deps:
28+
- task: go:deps
29+
cmds:
30+
- go test -v ./src/arduino.cc/repository/libraries/...

0 commit comments

Comments
 (0)