-
Notifications
You must be signed in to change notification settings - Fork 34
119 lines (117 loc) · 3.77 KB
/
build.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
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
name: Reusable stacker build
on:
workflow_call:
inputs:
# note >-, args needs to be strings to be used as inputs
# for the reusable build.yaml workflow
go-version:
required: false
type: string
description: 'Stringified JSON object listing go versions'
default: >-
["1.21.x"]
privilege-level:
required: false
type: string
description: 'Stringified JSON object listing stacker privilege-level'
default: >-
["unpriv", "priv"]
build-id:
required: false
type: string
description: 'build-id'
default: "${{ github.sha }}"
slow-test:
required: false
type: boolean
description: 'Should slow tests be run?'
default: true
secrets:
codecov_token:
required: true
jobs:
build:
runs-on: ubuntu-24.04
services:
registry:
image: ghcr.io/project-stacker/registry:2
ports:
- 5000:5000
strategy:
matrix:
go-version: ${{fromJson(inputs.go-version)}}
privilege-level: ${{fromJson(inputs.privilege-level)}}
name: "golang ${{ matrix.go-version }} privilege ${{ matrix.privilege-level }}"
steps:
- uses: actions/checkout@v3
- name: Clean disk space
uses: ./.github/actions/clean-runner
- uses: benjlevesque/[email protected]
id: short-sha
- name: Set up golang ${{ matrix.go-version }}
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Setup Environment
run: |
gopath=$PWD/.build/gopath
echo "GOPATH=$gopath" >> $GITHUB_ENV
echo "GOCACHE=$gopath/gocache" >> $GITHUB_ENV
echo "PATH=$gopath/bin:$PATH" >> $GITHUB_ENV
echo "SLOW_TEST=${{inputs.slow-test}}" >> $GITHUB_ENV
echo "STACKER_DOCKER_BASE=oci:$PWD/.build/oci-clone:" >> $GITHUB_ENV
echo "PWD=$PWD"
cat "$GITHUB_ENV"
- name: install dependencies
run: |
./install-build-deps.sh
echo "running kernel is: $(uname -a)"
- name: docker-clone
run: |
make docker-clone "STACKER_DOCKER_BASE=docker://" CLONE_D="$PWD/.build/oci-clone"
- name: Go-download
run: |
make go-download
- name: Show disk usage before building the binaries
uses: ./.github/actions/show-disk-usage
- name: Build-level1
run: |
make show-info
make stacker-dynamic VERSION_FULL=${{ inputs.build-id }}
- name: Build
run: |
make stacker VERSION_FULL=${{ inputs.build-id }}
env:
REGISTRY_URL: localhost:5000
ZOT_HOST: localhost
ZOT_PORT: 8080
- name: Show disk usage before running the tests
if: always()
uses: ./.github/actions/show-disk-usage
- name: Test
run: |
make check VERSION_FULL=${{ inputs.build-id }} PRIVILEGE_LEVEL=${{ matrix.privilege-level }}
env:
REGISTRY_URL: localhost:5000
ZOT_HOST: localhost
ZOT_PORT: 8080
- name: Show disk usage after running the tests
if: always()
uses: ./.github/actions/show-disk-usage
- name: Upload code coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.codecov_token }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: ${{ matrix.privilege-level == 'priv' }}
with:
# if there is more than 1 go-version, we would need to account for that here.
name: binary
path: stacker
if-no-files-found: error
- uses: actions/cache@v3
id: restore-build
with:
path: stacker
key: ${{ inputs.build-id }}