diff --git a/.github/actions/smoke-test/action.yaml b/.github/actions/smoke-test/action.yaml deleted file mode 100644 index 3ee80e7..0000000 --- a/.github/actions/smoke-test/action.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: 'Smoke test' -inputs: - template: - description: 'Template to test' - required: true - -runs: - using: composite - steps: - - name: Checkout main - id: checkout_release - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 - - - 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 }} \ No newline at end of file diff --git a/.github/actions/smoke-test/build.sh b/.github/actions/smoke-test/build.sh deleted file mode 100755 index 60a5fff..0000000 --- a/.github/actions/smoke-test/build.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -TEMPLATE_ID="$1" - -set -e - -shopt -s dotglob - -SRC_DIR="/tmp/${TEMPLATE_ID}" -cp -R "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 -Rp test/test-utils/* ${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}" diff --git a/.github/actions/smoke-test/test.sh b/.github/actions/smoke-test/test.sh deleted file mode 100755 index 5de1a2c..0000000 --- a/.github/actions/smoke-test/test.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/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}" diff --git a/.github/workflows/devcontainer-feature.yml b/.github/workflows/devcontainer-feature.yml new file mode 100644 index 0000000..5edf972 --- /dev/null +++ b/.github/workflows/devcontainer-feature.yml @@ -0,0 +1,22 @@ +name: "CI - Test Features" + +on: + pull_request: + paths: + - ".github/workflows/devcontainer-feature.yml" + - "src/git-kura/**" + - "test/git-kura/**" + - "test/test-utils/**" + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + + - name: Install Dev Container CLI + run: npm install -g @devcontainers/cli + + - name: Test git-kura Feature + run: devcontainer features test --features git-kura --skip-scenarios --base-image mcr.microsoft.com/devcontainers/base:ubuntu . diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5a322bb..3f1639e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -name: "Release Dev Container & Generate Documentation" +name: "Release Dev Container Features & Generate Documentation" on: workflow_dispatch: @@ -13,11 +13,11 @@ jobs: steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 - - name: "Publish Templates" + - name: "Publish Features" uses: devcontainers/action@1082abd5d2bf3a11abccba70eef98df068277772 # v1 with: - publish-templates: "true" - base-path-to-templates: "./src" + publish-features: "true" + base-path-to-features: "./src" generate-docs: "true" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-pr.yaml b/.github/workflows/test-pr.yaml deleted file mode 100644 index 600534e..0000000 --- a/.github/workflows/test-pr.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: "CI - Test Templates" -on: - pull_request: - -jobs: - detect-changes: - runs-on: ubuntu-latest - outputs: - templates: ${{ steps.filter.outputs.changes }} - steps: - - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4 - id: filter - with: - filters: | - color: ./**/color/** - hello: ./**/hello/** - - test: - needs: [detect-changes] - runs-on: ubuntu-latest - continue-on-error: true - strategy: - matrix: - templates: ${{ fromJSON(needs.detect-changes.outputs.templates) }} - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 - - - name: Smoke test for '${{ matrix.templates }}' - id: smoke_test - uses: ./.github/actions/smoke-test - with: - template: "${{ matrix.templates }}" diff --git a/README.md b/README.md index dacf5d7..f7d61c4 100644 --- a/README.md +++ b/README.md @@ -1,122 +1,11 @@ -# Dev Container Templates: Self Authoring Guide +# Dev Container Features -> This repo provides a starting point and example for creating your own custom [Dev Container Templates](https://containers.dev/implementors/templates), hosted for free on GitHub Container Registry. The example in this repository follows the [Dev Container Template distribution specification](https://containers.dev/implementors/templates-distribution/). -> -> To provide feedback on the distribution spec, please leave a comment [on spec issue #71](https://github.com/devcontainers/spec/issues/71). +This repository publishes Dev Container Features. -## Repo and Template Structure +## Features -This repository contains a _collection_ of two Templates - `hello` and `color`. These Templates serve as simple template implementations which helps containerize the project. Similar to the [`devcontainers/templates`](https://github.com/devcontainers/templates) repo, this repository has a `src` folder. Each Template has its own sub-folder, containing at least a `devcontainer-template.json` and `.devcontainer/devcontainer.json`. +- `git-kura`: installs `git-kura`, a keyed Git worktree resolver. -``` -├── src -│ ├── color -│ │ ├── devcontainer-template.json -│ │ └──| .devcontainer -│ │ └── devcontainer.json -│ ├── hello -│ │ ├── devcontainer-template.json -│ │ └──| .devcontainer -│ │ ├── devcontainer.json -│ │ └── Dockerfile -| ├── ... -│ │ ├── devcontainer-template.json -│ │ └──| .devcontainer -│ │ └── devcontainer.json -├── test -│ ├── color -│ │ └── test.sh -│ ├── hello -│ │ └── test.sh -│ └──test-utils -│ └── test-utils.sh -... -``` +## Publishing -### Options - -All available options for a Template should be declared in the `devcontainer-template.json`. The syntax for the `options` property can be found in the [devcontainer Template json properties reference](https://containers.dev/implementors/templates#devcontainer-templatejson-properties). - -For example, the `color` Template provides three possible options (`red`, `gold`, `green`), where the default value is set to "red". - -```jsonc -{ - // ... - "options": { - "favorite": { - "type": "string", - "description": "Choose your favorite color.", - "proposals": [ - "red", - "gold", - "green" - ], - "default": "red" - } - } -} -``` - -An [implementing tool](https://containers.dev/supporting#tools) will use the `options` property from [the documented Dev Container Template properties](https://containers.dev/implementors/templates#devcontainer-templatejson-properties) for customizing the Template. See [option resolution example](https://containers.dev/implementors/templates#option-resolution-example) for details. - -## Distributing Templates - -**Note**: *Allow GitHub Actions to create and approve pull requests* should be enabled in the repository's `Settings > Actions > General > Workflow permissions` for auto generation of `src/