-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workflows/e2e: Use local envtest github action
Use local actions/envtest to setup envtest. The envtest action downloads the envtest binaries for a given version inside a container and moves them to the host. The binaries also include the setup-envtest binary. The env var KUBEBUILDER_ASSETS is also set to the directory containing the envtest binaries. The cache in /github/home/.cache populated when installing setup-envtest causes the builds to fail in `make test` target due to the cached go build files, maybe due to some incompatibilities. Deleting them at the end of the action helps avoid affecting other build steps in the workflow. Since the run-test action runs in a container, the host $PATH is not passed to the test container. The ENV directive in Dockerfile is used to append the PATH with envtest binary path. This helps avoid redownload of the envtest binaries when it's not found in the path via the Makefile targets. Signed-off-by: Sunny <darkowlzz@protonmail.com>
- Loading branch information
Showing
5 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM golang:1.16-buster | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypoint.sh | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Setup envtest | ||
description: A GitHub Action for setting up controller-runtime envtest | ||
author: Flux authors | ||
branding: | ||
color: blue | ||
icon: command | ||
inputs: | ||
version: | ||
description: 'Kubernetes version' | ||
required: false | ||
default: "latest" | ||
runs: | ||
using: docker | ||
image: Dockerfile | ||
args: | ||
- ${{ inputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
# envtest kubernetes version. | ||
VERSION=${1:-latest} | ||
|
||
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest | ||
setup-envtest use $VERSION | ||
|
||
ENVTEST_DIR=$(setup-envtest use -i $VERSION -p path) | ||
SETUP_ENVTEST_PATH=$(which setup-envtest) | ||
|
||
mkdir -p $GITHUB_WORKSPACE/envtest | ||
mv $ENVTEST_DIR/* $GITHUB_WORKSPACE/envtest | ||
mv $SETUP_ENVTEST_PATH $GITHUB_WORKSPACE/envtest | ||
ls -lh $GITHUB_WORKSPACE/envtest | ||
|
||
echo "$GITHUB_WORKSPACE/envtest" >> $GITHUB_PATH | ||
echo "$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/envtest" >> $GITHUB_PATH | ||
echo "KUBEBUILDER_ASSETS=$GITHUB_WORKSPACE/envtest" >> $GITHUB_ENV | ||
|
||
# Cleanup cache to avoid affecting other builds. Some go builds may get | ||
# affected by this cache populated in the above operations. | ||
rm -rf /github/home/.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters