forked from ko-build/ko
-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (57 loc) · 2.13 KB
/
e2e.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
name: Basic e2e test
on:
pull_request:
branches: ['main']
jobs:
e2e:
strategy:
fail-fast: false
matrix:
platform:
- ubuntu-latest
- windows-latest
name: e2e ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Build and run ko container
env:
KO_DOCKER_REPO: ko.local
shell: bash
run: |
set -euxo pipefail
# eval `go env`, compatible with Windows and Linux
# cribbed from https://gist.github.com/Syeberman/39d81b1e17d091be5657ecd6fbff0753
eval $(go env | sed -r 's/^(set )?(\w+)=("?)(.*)\3$/\2="\4"/gm')
export PLATFORM=${GOOS}/${GOARCH}
if [[ "${{ matrix.platform }}" == "windows-latest" ]]; then
OSVERSION="10.0.17763"
PLATFORM=${PLATFORM}:${OSVERSION}
export KO_DEFAULTBASEIMAGE=mcr.microsoft.com/windows/nanoserver:1809
else
# Explicitly test multiple platform builds (a subset of what's in the base!)
export PLATFORM=${PLATFORM},linux/arm64
fi
echo platform is ${PLATFORM}
# Build and run the ko binary, which should be runnable.
docker run $(go run ./ build ./ --platform=${PLATFORM} --preserve-import-paths) version
# Build and run the test/ binary, which should log "Hello there" served from KO_DATA_PATH
testimg=$(go run ./ build ./test --platform=${PLATFORM} --preserve-import-paths)
docker run ${testimg} --wait=false 2>&1 | grep "Hello there"
# Check that symlinks in kodata are chased.
# Skip this test on Windows.
if [[ "$RUNNER_OS" == "Linux" ]]; then
docker run ${testimg} --wait=false -f HEAD
fi
# Check that using ldflags to set variables works.
cat > .ko.yaml << EOF
builds:
- id: test
main: ./test/
ldflags:
- "-X main.version=${{ github.sha }}"
EOF
docker run $(go run ./ build ./test/ --platform=${PLATFORM}) --wait=false 2>&1 | grep "${{ github.sha }}"