-
Notifications
You must be signed in to change notification settings - Fork 8
121 lines (104 loc) · 3.22 KB
/
main.yml
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
119
120
121
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Build and Test
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
strategy:
matrix:
arch:
- "amd64"
- "aarch64"
name: "Build - ${{ matrix.arch }}"
runs-on: ubuntu-latest
steps:
- name: Checkout - amd64
if: matrix.arch == 'amd64'
uses: actions/checkout@v3
- name: Checkout - aarch64
if: matrix.arch == 'aarch64'
uses: actions/checkout@v3
with:
path: 'repo'
- name: Go module cache - amd64
if: matrix.arch == 'amd64'
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-${{ matrix.arch }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-go-
- name: Go module cache - aarch64
if: matrix.arch == 'aarch64'
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/go
key: ${{ runner.os }}-${{ matrix.arch }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.arch }}-go-
- name: Set up Go - amd64
if: matrix.arch == 'amd64'
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Build - amd64
if: matrix.arch == 'amd64'
run: make
- name: Run tests - amd64
if: matrix.arch == 'amd64'
run: make test
- name: Run tests - aarch64
if: matrix.arch == 'aarch64'
uses: pguyot/arm-runner-action@v2
id: arm-image
with:
cpu: 'cortex-a53'
base_image: 'https://raspi.debian.net/tested/20230102_raspi_4_bullseye.img.xz'
bind_mount_repository: true
import_github_env: true
image_additional_mb: 2000
# language=Shell script
commands: |
echo '::group::Update and install OS dependencies'
apt update \
&& apt upgrade -y \
&& apt install -y \
build-essential \
ca-certificates \
curl \
gcc \
openssl \
tar \
unzip \
wget
echo '::endgroup'
echo '::group::Ensure go is installed'
if ! [ -d "$(pwd)/go" ]; then
wget -q https://go.dev/dl/go1.19.5.linux-arm64.tar.gz
tar -C "$(pwd)/" -xzf go1.19.5.linux-arm64.tar.gz
fi
echo '::endgroup'
echo '::Setup GOPATH and PATH'
export GOPATH="/$(pwd)/go"
export PATH="$GOPATH/bin:$PATH"
echo "GOPATH=$GOPATH"
echo "PATH=$PATH"
echo '::endgroup'
# move into repo dir
cd repo \
&& echo '::group::go build...' \
&& go build \
&& echo '::endgroup' \
&& echo '::group::go vet...' \
&& go vet ./... \
&& echo '::endgroup' \
&& echo '::group::go test...' \
&& go test ./... \
&& echo '::endgroup'