-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #548 from amazonlinux/pipeline-test-stage
reauto: pipeline test stage
- Loading branch information
Showing
5 changed files
with
117 additions
and
12 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
|
||
# Helper script for running commands in a golang build/runtime environment for testing/vendoring/building a go module | ||
|
||
set -e -o pipefail | ||
|
||
usage() { | ||
cat >&2 <<EOF | ||
$(basename "${0}") | ||
--module-path <path to Go module> | ||
--go-version <go version> | ||
--go-mod-cache <path to set up the go mod cache> | ||
--command "<command to run>" | ||
Runs | ||
Required: | ||
--module-path The path of the Go module to mount into the container | ||
--go-version Version of Go to use | ||
--go-mod-cache The Go module cache path to mount into the container | ||
--command The command to run in the golang container | ||
EOF | ||
} | ||
|
||
required_arg() { | ||
local arg="${1:?}" | ||
local value="${2}" | ||
if [ -z "${value}" ]; then | ||
echo "ERROR: ${arg} is required" >&2 | ||
exit 2 | ||
fi | ||
} | ||
|
||
parse_args() { | ||
while [ ${#} -gt 0 ] ; do | ||
case "${1}" in | ||
--help ) usage; exit 0 ;; | ||
--module-path ) shift; GO_MODULE_PATH="${1}" ;; | ||
--go-version ) shift; GO_VERSION="${1}" ;; | ||
--go-mod-cache ) shift; GO_MOD_CACHE="${1}" ;; | ||
--command ) shift; COMMAND="${@:1}" ;; | ||
*) ;; | ||
esac | ||
shift | ||
done | ||
|
||
# Required arguments | ||
required_arg "--module-path" "${GO_MODULE_PATH}" | ||
required_arg "--go-version" "${GO_VERSION}" | ||
required_arg "--go-mod-cache" "${GO_MOD_CACHE}" | ||
required_arg "--command" "${COMMAND}" | ||
} | ||
|
||
DOCKER_RUN_ARGS="--network=host" | ||
|
||
parse_args "${@}" | ||
|
||
docker run --rm \ | ||
-e GOPRIVATE='*' \ | ||
-e GOCACHE='/tmp/.cache' \ | ||
--user "$(id -u):$(id -g)" \ | ||
${DOCKER_RUN_ARGS} \ | ||
-v "${GO_MOD_CACHE}":/go/pkg/mod \ | ||
-v "${GO_MODULE_PATH}":/usr/src/host-ctr \ | ||
-w /usr/src/host-ctr \ | ||
golang:${GO_VERSION} \ | ||
bash -c "${COMMAND}" |
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,24 @@ | ||
version: 0.2 | ||
|
||
env: | ||
variables: | ||
# Path to infra tooling directory. | ||
INFRA_DIR: "./tools/infra" | ||
|
||
phases: | ||
install: | ||
runtime-versions: | ||
docker: 18 | ||
commands: | ||
- . "${INFRA_DIR}/env/lib/environment-setup" | ||
- . setup-rust-builder | ||
# TODO: rely on libsystemd in build container instead, see #545 | ||
- apt install -y libsystemd-dev | ||
pre_build: | ||
commands: | ||
- environment-report | ||
- write-build-meta | ||
build: | ||
commands: | ||
# Run rust workspaces and go unit tests | ||
- cargo make unit-tests |
File renamed without changes.