mirror of
https://github.com/ko-build/ko.git
synced 2026-06-18 20:14:08 +02:00
* Add .ko.yaml to base ko container image on golang:1.17 Ignore this in e2e tests, since even though golang:1.17 provides a Windows base image, ko's base image platform selection doesn't take osversion into account. The e2e tests don't exercise golang usage at all, so it shouldn't matter. * Update README
66 lines
2.1 KiB
YAML
66 lines
2.1 KiB
YAML
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')
|
|
|
|
if [[ "${{ matrix.platform }}" == "windows-latest" ]]; then
|
|
# Always use the nanoserver base image, which matches the Windows
|
|
# version used by the GitHub Actions Windows runner.
|
|
rm .ko.yaml
|
|
export KO_DEFAULTBASEIMAGE=mcr.microsoft.com/windows/nanoserver:1809
|
|
fi
|
|
|
|
echo platform is ${GOOS}/${GOARCH}
|
|
# Build and run the ko binary, which should be runnable.
|
|
docker run $(go run ./ publish ./ --platform=${GOOS}/${GOARCH} --preserve-import-paths) version
|
|
|
|
# Build and run the test/ binary, which should log "Hello there" served from KO_DATA_PATH
|
|
testimg=$(go run ./ publish ./test --platform=${GOOS}/${GOARCH} --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 ./ publish ./test/ --platform=${GOOS}/${GOARCH}) --wait=false 2>&1 | grep "${{ github.sha }}"
|
|
|