Skip to content

Commit 4603183

Browse files
committed
chore: add GitHub Actions workflows for Go cross-platform testing and main process
1 parent 4ede36c commit 4603183

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

.github/workflows/go-cross.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Go Matrix
2+
on: [push, pull_request]
3+
4+
jobs:
5+
6+
cross:
7+
name: Go
8+
runs-on: ${{ matrix.os }}
9+
env:
10+
CGO_ENABLED: 0
11+
12+
strategy:
13+
matrix:
14+
go-version: [ 1.19, 1.x ]
15+
os: [ubuntu-latest, macos-latest, windows-latest]
16+
17+
steps:
18+
# https://github.com/marketplace/actions/setup-go-environment
19+
- name: Set up Go ${{ matrix.go-version }}
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: ${{ matrix.go-version }}
23+
24+
# https://github.com/marketplace/actions/checkout
25+
- name: Checkout code
26+
uses: actions/checkout@v2
27+
28+
# https://github.com/marketplace/actions/cache
29+
- name: Cache Go modules
30+
uses: actions/cache@v3
31+
with:
32+
# In order:
33+
# * Module download cache
34+
# * Build cache (Linux)
35+
# * Build cache (Mac)
36+
# * Build cache (Windows)
37+
path: |
38+
~/go/pkg/mod
39+
~/.cache/go-build
40+
~/Library/Caches/go-build
41+
%LocalAppData%\go-build
42+
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
43+
restore-keys: |
44+
${{ runner.os }}-${{ matrix.go-version }}-go-
45+
46+
- name: Test
47+
run: go test -v -cover ./...

.github/workflows/main.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
11+
main:
12+
name: Main Process
13+
runs-on: ubuntu-latest
14+
env:
15+
GO_VERSION: 1.19
16+
GOLANGCI_LINT_VERSION: v1.50.0
17+
YAEGI_VERSION: v0.14.2
18+
CGO_ENABLED: 0
19+
defaults:
20+
run:
21+
working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
22+
23+
steps:
24+
25+
# https://github.com/marketplace/actions/setup-go-environment
26+
- name: Set up Go ${{ env.GO_VERSION }}
27+
uses: actions/setup-go@v2
28+
with:
29+
go-version: ${{ env.GO_VERSION }}
30+
31+
# https://github.com/marketplace/actions/checkout
32+
- name: Check out code
33+
uses: actions/checkout@v2
34+
with:
35+
path: go/src/github.com/${{ github.repository }}
36+
fetch-depth: 0
37+
38+
# https://github.com/marketplace/actions/cache
39+
- name: Cache Go modules
40+
uses: actions/cache@v3
41+
with:
42+
path: ${{ github.workspace }}/go/pkg/mod
43+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
44+
restore-keys: |
45+
${{ runner.os }}-go-
46+
47+
# https://golangci-lint.run/usage/install#other-ci
48+
- name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }}
49+
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
50+
51+
- name: Install Yaegi ${{ env.YAEGI_VERSION }}
52+
run: curl -sfL https://raw.githubusercontent.com/traefik/yaegi/master/install.sh | bash -s -- -b $(go env GOPATH)/bin ${YAEGI_VERSION}
53+
54+
- name: Setup GOPATH
55+
run: go env -w GOPATH=${{ github.workspace }}/go
56+
57+
- name: Check and get dependencies
58+
run: |
59+
go mod tidy
60+
git diff --exit-code go.mod
61+
# git diff --exit-code go.sum
62+
go mod download
63+
go mod vendor
64+
# git diff --exit-code ./vendor/
65+
66+
- name: Lint and Tests
67+
run: make
68+
69+
- name: Run tests with Yaegi
70+
run: make yaegi_test
71+
env:
72+
GOPATH: ${{ github.workspace }}/go

0 commit comments

Comments
 (0)