-
Notifications
You must be signed in to change notification settings - Fork 144
77 lines (76 loc) · 2.39 KB
/
main.yaml
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
name: Build and Test
# This workflow will run on master branch and on any pull requests targeting master
on:
push:
branches:
- master
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize
- ready_for_review
- converted_to_draft
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Free space
run: |
# cleanup up space to free additional ~20GiB of memory
# which are lacking for multiplaform images build
formatByteCount() { echo $(numfmt --to=iec-i --suffix=B --padding=7 $1'000'); }
getAvailableSpace() { echo $(df -a $1 | awk 'NR > 1 {avail+=$4} END {print avail}'); }
BEFORE=$(getAvailableSpace)
sudo rm -rf /usr/local/lib/android || true
sudo rm -rf /usr/share/dotnet || true
sudo rm -rf /opt/ghc || true
sudo rm -rf /usr/local/.ghcup || true
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
echo "Saved $(formatByteCount $SAVED)"
- name: Checkout code
uses: actions/checkout@v4
- name: Restore binaries from cache
uses: actions/cache/restore@v4
with:
path: ./bin
key: binary
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
id: go
- name: Set output variables
id: vars
run: |
IMAGE_TAG=${GITHUB_SHA:0:7}
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Lint, Test and Build
if: github.event.pull_request.draft == false
env:
GO111MODULE: on
DOCKER_BUILD_ARGS: --cache-from=type=gha --cache-to=type=gha,mode=max
TAG: ${{ steps.vars.outputs.IMAGE_TAG }}
run: |
make lint
make test
TAG=${TAG} make test-e2e
if [ -n '${{secrets.REPO_KEY}}' ]; then
echo ${{secrets.REPO_KEY}} | docker login --username ${{secrets.REPO_USER}} --password-stdin
make publish
else
echo "there is no docker secret, just build"
make build
fi
- name: Prapare binary cache
uses: actions/cache@v4
with:
path: ./bin
key: binary