diff --git a/.devcontainer.json b/.devcontainer.json deleted file mode 100644 index 66ec3a4..0000000 --- a/.devcontainer.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "image": "mcr.microsoft.com/devcontainers/javascript-node:1-18-bullseye", - "customizations": { - "vscode": { - "settings": { - "json.schemas": [ - { - "fileMatch": [ - "*/devcontainer-feature.json" - ], - "url": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainerFeature.schema.json" - } - ] - }, - "extensions": [ - "mads-hartmann.bash-ide-vscode" - ] - } - }, - "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {} - }, - "remoteUser": "node", - "updateContentCommand": "npm install -g @devcontainers/cli" -} \ No newline at end of file diff --git a/.devcontainer/.devcontainer.json b/.devcontainer/.devcontainer.json new file mode 100644 index 0000000..2edda75 --- /dev/null +++ b/.devcontainer/.devcontainer.json @@ -0,0 +1,22 @@ +{ + "image": "mcr.microsoft.com/devcontainers/base:ubuntu-22.04", + "customizations": { + "vscode": { + "extensions": [ + "mads-hartmann.bash-ide-vscode" + ] + } + }, + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "configureZshAsDefaultShell": true + }, + "ghcr.io/devcontainers/features/node:1": { + "version": "20" + }, + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/audacioustux/devcontainers/common-utils-extras:1": {}, + "ghcr.io/audacioustux/devcontainers/taskfile:1": {} + }, + "updateContentCommand": "npm install -g @devcontainers/cli" +} \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index be5bb21..55f3789 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,7 +7,6 @@ on: - completed workflow_dispatch: pull_request: - jobs: test-autogenerated: runs-on: ubuntu-latest @@ -20,13 +19,10 @@ jobs: - mcr.microsoft.com/devcontainers/base:ubuntu steps: - uses: actions/checkout@v3 - - name: "Install latest devcontainer CLI" run: npm install -g @devcontainers/cli - - name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'" run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} . - test-scenarios: runs-on: ubuntu-latest if: ${{ !cancelled() }} @@ -51,21 +47,16 @@ jobs: - vegeta steps: - uses: actions/checkout@v3 - - name: "Install latest devcontainer CLI" run: npm install -g @devcontainers/cli - - name: "Generating tests for '${{ matrix.features }}' scenarios" run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated . - test-global: runs-on: ubuntu-latest if: ${{ !cancelled() }} steps: - uses: actions/checkout@v3 - - name: "Install latest devcontainer CLI" run: npm install -g @devcontainers/cli - - name: "Testing global scenarios" run: devcontainer features test --global-scenarios-only . diff --git a/Taskfile.yaml b/Taskfile.yaml new file mode 100644 index 0000000..9739f1a --- /dev/null +++ b/Taskfile.yaml @@ -0,0 +1,7 @@ +version: "3" + +tasks: + default: + cmd: task --list-all + silent: true + new: ./scripts/new.sh {{.CLI_ARGS}} diff --git a/scripts/new.sh b/scripts/new.sh new file mode 100755 index 0000000..77de447 --- /dev/null +++ b/scripts/new.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -eax + +# ensure 3 arguments were passed +if [ $# -ne 3 ]; then + echo "Usage: $0 " + exit 1 +fi + +FEATURE_ID=$1 +FEATURE_NAME=$2 +FEATURE_DESCRIPTION=$3 + +# ensure feature does not already exist +if [ -d src/$FEATURE_ID ]; then + echo "Feature $FEATURE_ID already exists" + exit 1 +fi +# ensure feature id is lowercase +if [ "$FEATURE_ID" != "${FEATURE_ID,,}" ]; then + echo "Feature id must be lowercase" + exit 1 +fi + +# copy feature template +cp -r templates/feature/src src/$FEATURE_ID +cp -r templates/feature/test test/$FEATURE_ID + +# update feature metadata +jq \ + --arg FEATURE_ID "$FEATURE_ID" \ + --arg FEATURE_NAME "$FEATURE_NAME" \ + --arg FEATURE_DESCRIPTION "$FEATURE_DESCRIPTION" \ + '.id = $FEATURE_ID | .name = $FEATURE_NAME | .description = $FEATURE_DESCRIPTION' \ + src/$FEATURE_ID/devcontainer-feature.json | sponge src/$FEATURE_ID/devcontainer-feature.json + +# update feature test metadata +jq \ + --arg FEATURE_ID "$FEATURE_ID" \ + '.available_for_nonroot_user.features += {($FEATURE_ID): {}}' \ + test/$FEATURE_ID/scenarios.json | sponge test/$FEATURE_ID/scenarios.json + +# update github workflow to include feature in matrix +yq e '.jobs.test-scenarios.strategy.matrix.features += strenv(FEATURE_ID)' -i .github/workflows/test.yaml \ No newline at end of file diff --git a/src/common-utils-extras/devcontainer-feature.json b/src/common-utils-extras/devcontainer-feature.json index 9d0879a..945a45f 100644 --- a/src/common-utils-extras/devcontainer-feature.json +++ b/src/common-utils-extras/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Common Utilities Extras", "id": "common-utils-extras", - "version": "1.0.4", + "version": "1.0.5", "description": "More Common utilities for development containers", "installsAfter": [ "ghcr.io/devcontainers/features/common-utils" diff --git a/src/common-utils-extras/install.sh b/src/common-utils-extras/install.sh index c5217f7..511ae74 100644 --- a/src/common-utils-extras/install.sh +++ b/src/common-utils-extras/install.sh @@ -22,7 +22,8 @@ apt-get install -yqq --no-install-recommends \ socat \ parallel \ gum \ - cloc + cloc \ + moreutils # create symlinks for bat and fd, as they are called batcat and fdfind in Ubuntu sudo -iu $_REMOTE_USER <