-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to use harness-docker as a parent harness (#31)
While workspace only supports the harnessLayers atm and not auto configuration of them on `ws create`, it'd still be a big help to avoid all the duplication and upgrades needed to files harness-docker also manages. One change though here is to use a multi-stage build instead of intermediate layers for building an nginx image for pipeline/production
- Loading branch information
1 parent
54f8fd5
commit 0b4292e
Showing
83 changed files
with
612 additions
and
2,021 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,43 @@ | ||
pipeline { | ||
agent none | ||
environment { | ||
MY127WS_KEY = credentials('base-my127ws-key-20190523') | ||
} | ||
options { | ||
buildDiscarder(logRotator(daysToKeepStr: '30')) | ||
} | ||
triggers { cron(env.BRANCH_NAME ==~ /^\d+\.\d+\.x$/ ? 'H H(2-6) * * 1' : '') } | ||
stages { | ||
stage('BuildAndTest') { | ||
parallel { | ||
stage('Test (mode=static)') { | ||
agent { label "linux-amd64-preview" } | ||
steps { sh './.ci/test static' } | ||
post { | ||
always { | ||
cleanWs() | ||
} | ||
} | ||
} | ||
stage('Test (mode=dynamic)') { | ||
agent { label "linux-amd64-preview" } | ||
steps { sh './.ci/test dynamic' } | ||
post { | ||
always { | ||
cleanWs() | ||
} | ||
} | ||
} | ||
stage('Test (mode=dynamic, sync=mutagen)') { | ||
agent { label "linux-amd64-preview" } | ||
steps { sh './.ci/test dynamic mutagen' } | ||
post { | ||
always { | ||
cleanWs() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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 @@ | ||
#!/bin/bash | ||
set -e -o pipefail | ||
|
||
ANALYSE_PATH="${1-}" | ||
|
||
if ! docker image ls -a --format '{{ print .Repository ":" .Tag }}' | grep -q koalaman/shellcheck-alpine:stable; then | ||
docker pull koalaman/shellcheck-alpine:stable | ||
fi | ||
if ! docker image ls -a --format '{{ print .Repository ":" .Tag }}' | grep -q hadolint/hadolint:latest; then | ||
docker pull hadolint/hadolint:latest-alpine | ||
fi | ||
|
||
run_shellcheck() | ||
{ | ||
docker run --rm --volume "$(pwd):/app" koalaman/shellcheck-alpine:stable /bin/sh -c "find '/app/$ANALYSE_PATH' -type f ! -path '*/.git/*' ! -path '/app/tmp-test/*' ! -name '*.twig' -and \( -name "*.sh" -or -perm -0111 \) -print -exec shellcheck --exclude=SC1008,SC1091 {} +" | ||
} | ||
|
||
run_hadolint() | ||
{ | ||
docker run --rm --volume "$(pwd):/app" hadolint/hadolint:latest-alpine /bin/sh -c "find '/app/$ANALYSE_PATH' -type f -name '*Dockerfile' ! -path '*/.git/*' ! -path '/app/tmp-test/*' ! -path '/app/test/*' ! -name '*.orig' -print -exec hadolint --ignore DL3003 --ignore DL3008 --ignore DL3016 --ignore DL3018 --ignore SC1091 --ignore DL3002 {} +" | ||
} | ||
|
||
run_shellcheck | ||
run_hadolint |
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
workspace('ci-node-spa-sample-dynamic'): | ||
description: generated local workspace for ci-node-spa-sample. | ||
harness: inviqa/node-spa | ||
harnessLayers: | ||
- https://github.com/inviqa/harness-docker/archive/refs/tags/0.2.0-alpha1.tar.gz | ||
|
||
attribute('app.build'): dynamic | ||
|
||
attribute('aws.bucket'): null | ||
attribute('app.repository'): null | ||
attribute('aws.id'): null | ||
attribute('aws.key'): null |
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
workspace('ci-node-spa-sample-static'): | ||
description: generated local workspace for ci-node-spa-sample. | ||
harness: inviqa/node-spa | ||
harnessLayers: | ||
- https://github.com/inviqa/harness-docker/archive/refs/tags/0.2.0-alpha1.tar.gz | ||
|
||
attribute('app.build'): static | ||
|
||
attribute('aws.bucket'): null | ||
attribute('app.repository'): null | ||
attribute('aws.id'): null | ||
attribute('aws.key'): null |
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,164 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
export path_test=".ci/tmp-test" | ||
|
||
export TEST_MODE="${TEST_MODE:-full}" | ||
export REUSE_EXISTING_WORKSPACE="${REUSE_EXISTING_WORKSPACE:-no}" | ||
export TEARDOWN_ENVIRONMENT="${TEARDOWN_ENVIRONMENT:-yes}" | ||
|
||
function main() | ||
{ | ||
local mode="$1" | ||
local sync="${2:-}" | ||
|
||
local sync_path="" | ||
if [[ -n "$sync" ]]; then | ||
sync_path="-${sync}" | ||
fi | ||
export path_test=".ci/tmp-test-${mode}${sync_path}" | ||
|
||
if [[ "$TEARDOWN_ENVIRONMENT" == "yes" ]]; then | ||
trap 'clean' EXIT | ||
fi | ||
|
||
if [[ "$mode" == "static" ]]; then | ||
export MY127WS_ENV=pipeline | ||
fi | ||
|
||
if [[ "$REUSE_EXISTING_WORKSPACE" != "yes" ]]; then | ||
# Test default mode of static or dynamic harnesses | ||
# For dynamic this means a mountpoint for the application code | ||
# or mutagen | ||
setup "$mode" | ||
if [[ "$sync" == "" ]]; then | ||
setup_dynamic_mountpoint | ||
elif [[ "$sync" == "mutagen" ]]; then | ||
setup_dynamic_mutagen | ||
fi | ||
prepare_environment | ||
fi | ||
|
||
if [[ "$TEST_MODE" == "quality" || "$TEST_MODE" == "full" ]]; then | ||
test_harness_quality "$mode" "$sync" | ||
fi | ||
if [[ "$TEST_MODE" == "acceptance" || "$TEST_MODE" == "full" ]]; then | ||
test_harness_acceptance "$mode" "$sync" | ||
fi | ||
if [[ "$TEARDOWN_ENVIRONMENT" == "yes" ]]; then | ||
clean | ||
fi | ||
} | ||
|
||
function test_harness_quality() | ||
{ | ||
.ci/quality "${path_test}/.my127ws" | ||
} | ||
|
||
function test_harness_acceptance() | ||
( | ||
local mode="$1" | ||
local sync="$2" | ||
|
||
install_environment | ||
run_project_quality_tests | ||
check_environment_started "$mode" | ||
run_project_acceptance_tests | ||
restart_environment | ||
check_environment_started "$mode" | ||
) | ||
|
||
function setup() | ||
( | ||
local mode="$1" | ||
|
||
if [ -d "${path_test}" ]; then | ||
rm -rf "${path_test}" | ||
fi | ||
|
||
cp -ap ".ci/sample-${mode}" "${path_test}" | ||
|
||
# download parent harness layers | ||
pushd "${path_test}" >/dev/null | ||
ws harness download | ||
popd >/dev/null | ||
|
||
rsync --archive --exclude="**/.git" --exclude="**/.ci" ./ "${path_test}/.my127ws/" | ||
) | ||
|
||
function prepare_environment() | ||
( | ||
cd "${path_test}" | ||
ws harness prepare | ||
) | ||
|
||
function install_environment() | ||
( | ||
cd "${path_test}" | ||
ws install | ||
) | ||
|
||
function check_environment_started() | ||
( | ||
local mode="$1" | ||
|
||
cd "${path_test}" | ||
|
||
project="ci-sample-${mode}" | ||
if [[ "$mode" == "static" ]]; then | ||
project="$(git log -n 1 --pretty=format:'%H')" | ||
fi | ||
|
||
if [ "$(docker-compose -p "$project" ps | grep -v "lighthouse" | grep -c Exit)" -gt 0 ]; then | ||
echo 'Some containers failed to start' | ||
docker-compose -p "$project" ps | ||
return 1 | ||
fi | ||
) | ||
|
||
function run_project_quality_tests() | ||
( | ||
cd "${path_test}" | ||
|
||
ws helm kubeval --cleanup app | ||
) | ||
|
||
function run_project_acceptance_tests() | ||
( | ||
cd "${path_test}" | ||
) | ||
|
||
function restart_environment() | ||
( | ||
cd "${path_test}" | ||
ws disable | ||
ws enable | ||
) | ||
|
||
function setup_dynamic_mountpoint() | ||
( | ||
cd "${path_test}" | ||
echo "attribute('host.os'): linux" > workspace.override.yml | ||
) | ||
|
||
function setup_dynamic_mutagen() | ||
( | ||
cd "${path_test}" | ||
echo "attribute('host.os'): darwin" > workspace.override.yml | ||
echo "attribute('mutagen'): yes" >> workspace.override.yml | ||
) | ||
|
||
function clean() | ||
{ | ||
if [ -d "${path_test}/.my127ws" ]; then | ||
(cd "$path_test" && ws destroy) || (docker ps -a && return 1) | ||
fi | ||
|
||
if [ -d "$path_test" ]; then | ||
rm -rf "$path_test" | ||
fi | ||
} | ||
|
||
main "$@" |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.