-
Notifications
You must be signed in to change notification settings - Fork 2
55 lines (55 loc) · 1.84 KB
/
reusable-go-build-smoke-test.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
name: Reusable Go build smoke test
on:
workflow_call:
inputs:
paths:
required: false
type: string
description: |
the Go entrypoint paths for applications, where there they have `package main`
e.g: ./cmd/thing1 ./cmd/thing2
setup:
required: false
type: string
description: |
shell commands to setup the test environment
working-directory:
required: false
type: string
description: |
the working directory to run the build
jobs:
go-build-smoke-test:
runs-on: ubuntu-latest
steps:
- if: ${{ startsWith(github.repository, 'GeoNet/') == false }}
name: require GeoNet org
run: |
exit 1
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: go.mod
cache-dependency-path: go.sum
check-latest: true
- id: run-info
name: collect job run info
working-directory: ${{ inputs.working-directory }}
run: |
if [ -n "${{ inputs.paths }}" ]; then
echo "paths=$(echo '${{ inputs.paths }}' | tr '\n' ' ')" >> $GITHUB_OUTPUT
else
PATHS="$(go list -json ./... | jq -r -s '.[] | select (.Name == "main") | .ImportPath' | xargs)"
echo "paths="$PATHS"" >> $GITHUB_OUTPUT
fi
- name: setup
working-directory: ${{ inputs.working-directory }}
run: |
eval '${{ inputs.setup }}'
- id: build
name: build
working-directory: ${{ inputs.working-directory }}
env:
PATHS: ${{ steps.run-info.outputs.paths }}
run: |
echo "$PATHS" | tr ' ' '\n' | xargs -i -n 1 go build -v -o /dev/null '{}'