Skip to content
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

chore: cleanup github actions, add missing actions #10

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/actions/smoke-test/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Smoke test"
description: "Tests the provided template."
inputs:
template:
description: "Template to test"
required: true

runs:
using: composite
steps:
- name: Checkout main
id: checkout_release
uses: actions/checkout@v3

- name: Build template
id: build_template
shell: bash
run: ${{ github.action_path }}/build.sh ${{ inputs.template }}

- name: Test template
id: test_template
shell: bash
run: ${{ github.action_path }}/test.sh ${{ inputs.template }}
55 changes: 55 additions & 0 deletions .github/actions/smoke-test/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
TEMPLATE_ID="$1"

set -e

shopt -s dotglob

SRC_DIR="/tmp/${TEMPLATE_ID}"
cp -R "templates/src/${TEMPLATE_ID}" "${SRC_DIR}"

pushd "${SRC_DIR}"

# Configure templates only if `devcontainer-template.json` contains the `options` property.
OPTION_PROPERTY=( $(jq -r '.options' devcontainer-template.json) )

if [ "${OPTION_PROPERTY}" != "" ] && [ "${OPTION_PROPERTY}" != "null" ] ; then
OPTIONS=( $(jq -r '.options | keys[]' devcontainer-template.json) )

if [ "${OPTIONS[0]}" != "" ] && [ "${OPTIONS[0]}" != "null" ] ; then
echo "(!) Configuring template options for '${TEMPLATE_ID}'"
for OPTION in "${OPTIONS[@]}"
do
OPTION_KEY="\${templateOption:$OPTION}"
OPTION_VALUE=$(jq -r ".options | .${OPTION} | .default" devcontainer-template.json)

if [ "${OPTION_VALUE}" = "" ] || [ "${OPTION_VALUE}" = "null" ] ; then
echo "Template '${TEMPLATE_ID}' 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"
done
fi
fi

popd

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 -Rp ${TEST_DIR}/* ${DEST_DIR}
cp test/test-utils/test-utils.sh ${DEST_DIR}
fi

export DOCKER_BUILDKIT=1
echo "(*) Installing @devcontainer/cli"
npm install -g @devcontainers/cli

echo "Building Dev Container"
ID_LABEL="test-container=${TEMPLATE_ID}"
devcontainer up --id-label ${ID_LABEL} --workspace-folder "${SRC_DIR}"
13 changes: 13 additions & 0 deletions .github/actions/smoke-test/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
TEMPLATE_ID="$1"
set -e

SRC_DIR="/tmp/${TEMPLATE_ID}"
echo "Running Smoke Test"

ID_LABEL="test-container=${TEMPLATE_ID}"
devcontainer exec --workspace-folder "${SRC_DIR}" --id-label ${ID_LABEL} /bin/sh -c 'set -e && if [ -f "test-project/test.sh" ]; then cd test-project && if [ "$(id -u)" = "0" ]; then chmod +x test.sh; else sudo chmod +x test.sh; fi && ./test.sh; else ls -a; fi'

# Clean up
docker rm -f $(docker container ls -f "label=${ID_LABEL}" -q)
rm -rf "${SRC_DIR}"
65 changes: 0 additions & 65 deletions .github/workflows/baseimage-builder.yaml

This file was deleted.

61 changes: 0 additions & 61 deletions .github/workflows/baseimage-metabuilder.yaml

This file was deleted.

50 changes: 0 additions & 50 deletions .github/workflows/baseimage.yaml

This file was deleted.

66 changes: 0 additions & 66 deletions .github/workflows/get-versions-builder.yaml

This file was deleted.

Loading
Loading