Skip to content

Merge pull request #355 from coryb/export-default-os #1009

Merge pull request #355 from coryb/export-default-os

Merge pull request #355 from coryb/export-default-os #1009

Workflow file for this run

name: Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
GO111MODULE: on
BUILDKIT_HOST: docker-container://buildkitd
jobs:
build:
name: Build
# expression language does not support ternary, so hack it via indexing boolean keys of an json object
runs-on: ${{ fromJSON('{true:"buildkitd",false:"ubuntu-latest"}')[github.repository == 'openllb/hlb'] }}
steps:
- name: Set up Go 1.21
uses: actions/setup-go@v2
with:
go-version: ^1.21
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Restore Cache
uses: actions/cache@v1
if: github.repository != 'openllb/hlb'
id: cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Get dependencies
run: go get
- name: Compile
run: |
go build -o build/hlb ./cmd/hlb
go build -o build/docgen ./cmd/docgen
go build -o build/builtingen ./cmd/builtingen
- name: Go Tests
run: go test -v ./...
- name: Start BuildkitD
if: github.repository != 'openllb/hlb'
run: docker run --name buildkitd --rm -d --privileged openllb/buildkit:experimental
- name: BuildkitD Wait
if: github.repository != 'openllb/hlb'
# waiting for buildkitd to report 1 worker (2 lines, 1 for column titles, one for the worker details)
run: while true; do lineCount=$(docker exec buildkitd buildctl debug workers | wc -l); if [ $lineCount -gt 1 ]; then break; fi; sleep 1; done
- name: GoLint
run: ./build/hlb run -t lint
- name: Ensure generated files
run: |
./build/hlb run -t gen
if ! git diff --quiet; then
echo "ERROR: Generated files need updating:" >&2
echo "" >&2
git ls-files -m | sed 's/^/ /g' >&2
echo "" >&2
echo "To resolve run:" >&2
echo " ./hlb run -t gen" >&2
echo "and add changes to the git branch" >&2
exit 1
fi
- name: Crosscompile
run: ./build/hlb run