generated from devcontainers/template-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
Localstack_template #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
79acb4d
chore: update LICENSE
lakkeger 23eabfa
ci: exclude some files from trigger
lakkeger e40c032
feat: bump version for project devcontainer
lakkeger 13f1f18
feat: add persistence for project devcontainer
lakkeger 14d8d8c
feat: add merge behaviour for testing purposes to build script
lakkeger 0759dd9
feat: add initial version of localstack-dood
lakkeger 7a7a82f
chore: clean up sample templates
lakkeger 46e10ee
fix: add more descriptive name for LocalStack volume
lakkeger fc5fe45
fix: remove authToken option due to security concerns
lakkeger 9677431
feat: add initial version of localstack-dind
lakkeger c96d959
fix: add sudo to ensure to remove test folder
lakkeger 9db22fc
feat: add scenario testing similar to devcontainer feature
lakkeger a60239f
feat: improve error handling
lakkeger 67dc95a
ci: separate scenario testing into its own pipeline
lakkeger d012685
fix: improve exit conditions
lakkeger 85fa780
docs: add READMEs
lakkeger 8ee88a3
fix: add cli test to postCreateCommand in dind template
lakkeger b5a2876
feat: add merging behaviour in scenario build script for options not …
lakkeger 5778f4c
fix: update imageVariant proposals
lakkeger d26756e
fix: inherit auth token in devcontainer
lakkeger c9fb66f
feat: add scenario testing
lakkeger 913e6e6
fix: add exit code to scenario code suite to reflec results
lakkeger f0e3f87
fix: create volume folder for dind in smoke test
lakkeger 29c2115
fix: remove focal from scenario test
lakkeger afca093
ci: add LOCALSTACK_AUTH_TOKEN
lakkeger bfa04f6
feat: add ci key support
lakkeger 0dc4fcf
feat: add network and ls container removal in scenario tests
lakkeger 4eb6238
fix: change default volume name
lakkeger 761fba1
fix: pin ls version for dind pod test
lakkeger 06f0506
feat: add dood scenario tests
lakkeger e233bf1
fix: pin image version in dind's pod test
lakkeger 0565332
docs: update readme and notes
lakkeger 7f98ba5
ci: add LOCALSTACK_API_KEY to smoke tests
lakkeger 903bdcb
fix: add 3.6.0 proposal to version
lakkeger 9a5310b
fix: remove unnecessary inputs.json from dood
lakkeger fc1eed1
feat: add additional options merging to smoke tests
lakkeger 3ffbf5f
docs: typo fixes
lakkeger e04ef3a
docs: templates goes Template
lakkeger dbfb1c5
feat: add network options and tini
lakkeger 8c51ecb
fix: add comments on LS feature options
lakkeger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,17 @@ | ||
name: 'Scenario test(s)' | ||
inputs: | ||
template: | ||
description: 'Template to test' | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Checkout main | ||
id: checkout_release | ||
uses: actions/checkout@v3 | ||
|
||
- name: Test scenario templates | ||
id: test_template | ||
shell: bash | ||
run: ${{ github.action_path }}/controller.sh ${{ inputs.template }} |
This file contains hidden or 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,99 @@ | ||
#!/bin/bash | ||
TEMPLATE_ID="$1" | ||
SCENARIO="$2" | ||
SRC_DIR="/tmp/${TEMPLATE_ID}-${SCENARIO}" | ||
|
||
set -e | ||
|
||
shopt -s dotglob | ||
|
||
function remove_comments { | ||
sed -i -re 's/[[:blank:]]*(\/\/\s.*)//' ${1} | ||
} | ||
|
||
function merge { | ||
cp .devcontainer/devcontainer.json .devcontainer/devcontainer.json.bak | ||
remove_comments .devcontainer/devcontainer.json.bak | ||
|
||
if [ -f inputs.json ] ; then | ||
jq -s ".[0] * .[1]" .devcontainer/devcontainer.json.bak ./inputs.json > .devcontainer/devcontainer.json | ||
cp -f .devcontainer/devcontainer.json .devcontainer/devcontainer.json.bak | ||
fi | ||
|
||
jq -s ".[0] * .[1].${SCENARIO}" .devcontainer/devcontainer.json.bak test-project/scenarios.json > .devcontainer/devcontainer.json | ||
cp -f .devcontainer/devcontainer.json .devcontainer/devcontainer.json.bak | ||
|
||
# Clean up unneeded keys | ||
printf -v tmp_str '.%s,' "${OPTIONS[@]}" | ||
jq "del($(echo "${tmp_str%,}"))" .devcontainer/devcontainer.json.bak > .devcontainer/devcontainer.json | ||
|
||
rm .devcontainer/devcontainer.json.bak | ||
} | ||
|
||
function gen_config { | ||
echo "(*) Generating config files" | ||
# Configure templates only if `devcontainer-template.json` contains the `options` property. | ||
OPTIONS=( $(jq -r '.options | keys[]' devcontainer-template.json) ) | ||
|
||
if [ "${OPTIONS[0]}" != "" ] && [ "${OPTIONS[0]}" != "null" ] ; then | ||
echo "(!) Configuring template options for '${TEMPLATE_ID}-${SCENARIO}'" | ||
for OPTION in "${OPTIONS[@]}" | ||
do | ||
OPTION_KEY="\${templateOption:$OPTION}" | ||
|
||
OPTION_VALUE=$( jq -r ".${SCENARIO}.${OPTION}" test-project/scenarios.json) | ||
|
||
if ( [ "${OPTION_VALUE}" = "" ] || [ "${OPTION_VALUE}" = "null" ] ) && [ -f inputs.json ] ; then | ||
OPTION_VALUE=$(jq -r ".${OPTION}" inputs.json) | ||
fi | ||
|
||
if [ "${OPTION_VALUE}" = "" ] || [ "${OPTION_VALUE}" = "null" ] ; then | ||
OPTION_VALUE=$(jq -r ".options | .${OPTION} | .default" devcontainer-template.json) | ||
fi | ||
|
||
# For empty default values use " " | ||
if [ "${OPTION_VALUE}" = "" ] || [ "${OPTION_VALUE}" = "null" ] ; then | ||
echo "Template '${TEMPLATE_ID}-${SCENARIO}' is missing a default value for option '${OPTION}'" | ||
exit 1 | ||
fi | ||
|
||
echo "(!) Replacing '${OPTION_KEY}' with '${OPTION_VALUE}'" | ||
OPTION_VALUE_ESCAPED=$(sed -e 's/[]\/$*.^[]/\\&/g' <<<"${OPTION_VALUE}") | ||
find ./ -type f -print0 | xargs -0 sed -i "s/${OPTION_KEY}/${OPTION_VALUE_ESCAPED}/g" | ||
|
||
if [ "${OPTION}" == "volumePath" ] ; then | ||
mkdir -p ${SRC_DIR}/${OPTION_VALUE} | ||
fi | ||
|
||
unset OPTION_VALUE | ||
done | ||
|
||
merge | ||
fi | ||
} | ||
|
||
function create_scenario { | ||
cp -R "src/${TEMPLATE_ID}" "${SRC_DIR}" | ||
|
||
TEST_DIR="test/${TEMPLATE_ID}" | ||
if [ -d "${TEST_DIR}" ] ; then | ||
echo "(*) Copying test folder" | ||
DEST_DIR="${SRC_DIR}/test-project" | ||
mkdir -p ${DEST_DIR} | ||
cp -p ${TEST_DIR}/${SCENARIO}.sh ${TEST_DIR}/scenarios.json ${DEST_DIR} | ||
cp test/test-utils/test-utils.sh ${DEST_DIR} | ||
fi | ||
|
||
pushd "${SRC_DIR}" | ||
|
||
gen_config | ||
|
||
popd | ||
|
||
echo | ||
echo "🏗️ Building Dev Container - ${SCENARIO}" | ||
ID_LABEL="test-container=${TEMPLATE_ID}-${SCENARIO}" | ||
devcontainer up --id-label ${ID_LABEL} --workspace-folder "${SRC_DIR}" && echo "🚀 Launched container." | ||
} | ||
|
||
create_scenario |
This file contains hidden or 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,78 @@ | ||
#!/bin/bash | ||
TEMPLATE_ID="$1" | ||
ALL_RESULTS=" ================== 📋 TEST REPORT ==================\n" | ||
EXIT_CODE=0 | ||
|
||
set +e | ||
|
||
function reportAllScenarioResults { | ||
if [ ${2} -eq 0 ] ; then | ||
RES="✅ Passed:\t" | ||
else | ||
RES="❌ Failed:\t" | ||
EXIT_CODE=1 | ||
fi | ||
ALL_RESULTS="$ALL_RESULTS\n$RES'${1}'" | ||
} | ||
|
||
function cleanup { | ||
# Clean up | ||
echo "🧹 Cleaning up..." | ||
local ID_LABEL=${2} | ||
CONTAINER_ID=$(docker container ls -f "label=${ID_LABEL}" -q) | ||
if [ "${CONTAINER_ID:-x}" != "x" ]; then | ||
docker rm -f "${CONTAINER_ID}" > /dev/null && echo "🧹 Removing container ${CONTAINER_ID}" | ||
echo "🧹 Removing container localstack-main (if exists)" && docker rm -f "localstack-main" &> /dev/null | ||
fi | ||
echo "🧹 Removing container network ${ID_LABEL/*=/}_devcontainer_ls (if exists)" && docker network rm -f "${ID_LABEL/*=/}_devcontainer_ls" > /dev/null | ||
sudo rm -rf "${1}" && echo "🧹 Removing scenario files ${SCENARIO}" | ||
} | ||
|
||
function no_scenarios { | ||
echo | ||
echo "(!) No scenarios collected. Exiting. Bye! 👋" | ||
exit | ||
} | ||
|
||
echo "⏱️ Scenario tests - ${TEMPLATE_ID}" | ||
echo -n "(*) Collecting scenarios..." | ||
|
||
if ! [ -f test/${TEMPLATE_ID}/scenarios.json ]; then | ||
no_scenarios | ||
fi | ||
|
||
SCENARIOS=( $(jq -r 'keys[]' test/${TEMPLATE_ID}/scenarios.json) ) | ||
|
||
if [ ${#SCENARIOS[@]} -eq 0 ] ; then | ||
no_scenarios | ||
fi | ||
|
||
echo "found ${#SCENARIOS[@]}" | ||
echo | ||
printf '%s\n' "${SCENARIOS[@]}" | ||
echo | ||
|
||
type devcontainer &> /dev/null | ||
if [ $? -ne 0 ] ; then | ||
export DOCKER_BUILDKIT=1 | ||
set -e | ||
echo "(*) Installing @devcontainer/cli" | ||
npm install -g @devcontainers/cli | ||
set +e | ||
fi | ||
|
||
for SCENARIO in ${SCENARIOS[@]}; do | ||
ID_LABEL="test-container=${TEMPLATE_ID}-${SCENARIO}" | ||
SRC_DIR="/tmp/${TEMPLATE_ID}-${SCENARIO}" | ||
|
||
echo | ||
echo "🔄 Running scenario - ${SCENARIO}" | ||
$(dirname $0)/build.sh ${TEMPLATE_ID} ${SCENARIO} && \ | ||
$(dirname $0)/test.sh ${TEMPLATE_ID} ${SCENARIO} | ||
reportAllScenarioResults ${SCENARIO} $? | ||
cleanup ${SRC_DIR} ${ID_LABEL} | ||
echo | ||
done | ||
|
||
echo -e "${ALL_RESULTS}" | ||
exit ${EXIT_CODE} |
This file contains hidden or 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 @@ | ||
#!/bin/bash | ||
TEMPLATE_ID="$1" | ||
SCENARIO="$2" | ||
|
||
set -e | ||
|
||
function run_scenario { | ||
local SRC_DIR="/tmp/${TEMPLATE_ID}-${SCENARIO}" | ||
local ID_LABEL="test-container=${TEMPLATE_ID}-${SCENARIO}" | ||
devcontainer exec --workspace-folder "${SRC_DIR}" --id-label ${ID_LABEL} /bin/sh -c "set -e && if [ -f \"test-project/${SCENARIO}.sh\" ]; then cd test-project && if [ \"$(id -u)\" = \"0\" ]; then chmod +x ${SCENARIO}.sh; else sudo chmod +x ${SCENARIO}.sh; fi && ./${SCENARIO}.sh; else ls -a; fi" | ||
} | ||
|
||
echo | ||
echo "🔍 Running Scenario Test - ${SCENARIO}" | ||
run_scenario | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.