From e5886599702514986d6e5950e89d22c383e46ffb Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Mon, 1 May 2023 05:43:32 +0000 Subject: [PATCH 1/9] Add prebuild script to copy utils to each src folder --- tools/prebuild.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 tools/prebuild.sh diff --git a/tools/prebuild.sh b/tools/prebuild.sh new file mode 100755 index 0000000..8e4c336 --- /dev/null +++ b/tools/prebuild.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +for id in src/*; do + id=$(basename "$id") + if [[ ! -d src/$id ]]; then + echo "🟨 Skipping $id..." + continue + fi + echo "🟪 Copying utils/ to src/$id/utils/..." + rsync -a utils/ "src/$id/utils/" + echo "🟩 Copied utils/ to src/$id/utils/" +done From 9501c7d2359519072c67715daefc03b00ffb4fe5 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Mon, 1 May 2023 05:43:52 +0000 Subject: [PATCH 2/9] Add test wrapper to run prebuild prior to testing --- tools/test.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 tools/test.sh diff --git a/tools/test.sh b/tools/test.sh new file mode 100755 index 0000000..d35b739 --- /dev/null +++ b/tools/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +tools/prebuild.sh +devcontainer features test "$@" From 869e957096ebcdf017c5346271413d716caa187c Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Mon, 1 May 2023 05:44:49 +0000 Subject: [PATCH 3/9] Add util scripts --- utils/clear_local_apt_index.sh | 8 ++++++++ utils/ensure_apt_packages.sh | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 utils/clear_local_apt_index.sh create mode 100644 utils/ensure_apt_packages.sh diff --git a/utils/clear_local_apt_index.sh b/utils/clear_local_apt_index.sh new file mode 100644 index 0000000..087c54e --- /dev/null +++ b/utils/clear_local_apt_index.sh @@ -0,0 +1,8 @@ +# shellcheck shell=bash + +clear_local_apt_index() ( + set -e + + rm -rf /var/lib/apt/lists/* + echo '🟩 Cleared local apt index' +) diff --git a/utils/ensure_apt_packages.sh b/utils/ensure_apt_packages.sh new file mode 100644 index 0000000..3d84438 --- /dev/null +++ b/utils/ensure_apt_packages.sh @@ -0,0 +1,19 @@ +# shellcheck shell=bash + +ensure_apt_packages() ( + set -e + + export DEBIAN_FRONTEND=noninteractive + if dpkg -s "$@" &>/dev/null; then + echo "🟦 $@ is already installed" + else + if [[ $(find /var/lib/apt/lists/* | wc -l) == 0 ]]; then + echo '🟪 Updating local apt index...' + apt-get update -y + echo '🟩 Updated local apt index' + fi + echo "🟪 Installing $@..." + apt-get install -y --no-install-recommends "$@" + echo "🟩 Installed $@" + fi +) From 3ebc6ec6bcde2d1335f8836cf3cf8c1d0bb5ad42 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Mon, 1 May 2023 05:53:00 +0000 Subject: [PATCH 4/9] Add gitignore to stop committing src/*/utils --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dc74129 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +src/*/utils + +logs +*.log From abf4a1464f18a45029a52238f8c6365c9220279a Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Mon, 1 May 2023 05:56:23 +0000 Subject: [PATCH 5/9] Redo publish script --- .github/workflows/publish.yml | 31 ++++++++++++++++++++++ .github/workflows/release.yaml | 47 ---------------------------------- 2 files changed, 31 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..65a0195 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,31 @@ +name: Publish +on: + workflow_dispatch: +concurrency: + group: publish + cancel-in-progress: true +permissions: write-all +jobs: + publish-ghcr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: tools/prebuild.sh + - uses: devcontainers/action@v1 + with: + publish-features: true + base-path-to-features: src + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + update-docs: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + packages: write + steps: + - uses: actions/checkout@v3 + - uses: devcontainers/action@v1 + with: + generate-docs: true + - uses: stefanzweifel/git-auto-commit-action@v4 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 935ef81..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,47 +0,0 @@ -name: "Release dev container features & Generate Documentation" -on: - workflow_dispatch: - -jobs: - deploy: - if: ${{ github.ref == 'refs/heads/main' }} - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - packages: write - steps: - - uses: actions/checkout@v3 - - - name: "Publish Features" - uses: devcontainers/action@v1 - with: - publish-features: "true" - base-path-to-features: "./src" - generate-docs: "true" - - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create PR for Documentation - id: push_image_info - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - set -e - echo "Start." - # Configure git and Push updates - git config --global user.email github-actions@github.com - git config --global user.name github-actions - git config pull.rebase false - branch=automated-documentation-update-$GITHUB_RUN_ID - git checkout -b $branch - message='Automated documentation update' - # Add / update and commit - git add */**/README.md - git commit -m 'Automated documentation update [skip ci]' || export NO_UPDATES=true - # Push - if [ "$NO_UPDATES" != "true" ] ; then - git push origin "$branch" - gh pr create --title "$message" --body "$message" - fi From 6a86f169a7037b32886d8b58bf18a904fcf67190 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Mon, 1 May 2023 05:58:12 +0000 Subject: [PATCH 6/9] Add back base path --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 65a0195..0a9d9b8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,5 +27,6 @@ jobs: - uses: actions/checkout@v3 - uses: devcontainers/action@v1 with: + base-path-to-features: src generate-docs: true - uses: stefanzweifel/git-auto-commit-action@v4 From 45536fbc84542179e758dca4ee8ddcce2abce2d4 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Mon, 1 May 2023 05:59:47 +0000 Subject: [PATCH 7/9] Redo test workflow too --- .github/workflows/test.yaml | 58 ---------------------------------- .github/workflows/test.yml | 27 ++++++++++++++++ .github/workflows/validate.yml | 16 ---------- 3 files changed, 27 insertions(+), 74 deletions(-) delete mode 100644 .github/workflows/test.yaml create mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/validate.yml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index 9e5f9bf..0000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,58 +0,0 @@ -name: "CI - Test Features" -on: - push: - branches: - - main - pull_request: - workflow_dispatch: - -jobs: - test-autogenerated: - runs-on: ubuntu-latest - continue-on-error: true - strategy: - matrix: - features: - - color - - hello - baseImage: - - debian:latest - - ubuntu:latest - - 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 - continue-on-error: true - strategy: - matrix: - features: - - color - - hello - 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 - continue-on-error: true - 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/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..31984a5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +name: Test +on: + push: + branches: [main] + paths: + - src/** + - "!src/**.md" + - test/** + - .github/workflows/test.yml + pull_request: + branches: [main] + paths: + - src/** + - "!src/**.md" + - test/** + - .github/workflows/test.yml + workflow_dispatch: +concurrency: + group: test-${{ github.ref }} + cancel-in-progress: true +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: npm install -g @devcontainers/cli + - run: tools/test.sh diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml deleted file mode 100644 index 5dcc21b..0000000 --- a/.github/workflows/validate.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: "Validate devcontainer-feature.json files" -on: - workflow_dispatch: - pull_request: - -jobs: - validate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: "Validate devcontainer-feature.json files" - uses: devcontainers/action@v1 - with: - validate-only: "true" - base-path-to-features: "./src" From e8b9b01546276a59c2f20ecf058950ac9623e0b8 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Mon, 1 May 2023 05:59:53 +0000 Subject: [PATCH 8/9] Add validate step to test script --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 31984a5..cde3995 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,4 +24,8 @@ jobs: steps: - uses: actions/checkout@v3 - run: npm install -g @devcontainers/cli + - uses: devcontainers/action@v1 + with: + validate-only: true + base-path-to-features: src - run: tools/test.sh From bb9f5dfec453a1d924b041dea5bc8879e428ae85 Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Mon, 1 May 2023 06:00:58 +0000 Subject: [PATCH 9/9] Remove validate and rely on test --- .github/workflows/test.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cde3995..41125ed 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,8 +24,5 @@ jobs: steps: - uses: actions/checkout@v3 - run: npm install -g @devcontainers/cli - - uses: devcontainers/action@v1 - with: - validate-only: true - base-path-to-features: src + # TODO: When features grow too numerous, test ONLY CHANGED features - run: tools/test.sh