From 7026174458ab15e2ac2d1c01c1cd24ed0e05b5d2 Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Sun, 21 May 2023 20:59:53 -0700 Subject: [PATCH] Meta: Prebuild repo dev container This commit adds a GitHub Workflow to prebuild the dev container file present at .devcontainer/devcontainer.json. This prebuilt image is pushed to GitHub Container Registry (ghcr). An additional devcontainer.json is added consuming that image. This dev container can be selected in editors that process dev containers (ie GitHub Codespaces), to speed up time to editor. --- .devcontainer/devcontainer.json | 4 +- .../serenity/devcontainer-feature.json | 0 .../{ => features}/serenity/install.sh | 0 .devcontainer/optimized/.devcontainer.json | 11 ++++++ .github/workflows/dev-container.yml | 39 +++++++++++++++++++ 5 files changed, 52 insertions(+), 2 deletions(-) rename .devcontainer/{ => features}/serenity/devcontainer-feature.json (100%) rename .devcontainer/{ => features}/serenity/install.sh (100%) create mode 100644 .devcontainer/optimized/.devcontainer.json create mode 100644 .github/workflows/dev-container.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index aa74ed32726..0594109ed08 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,12 @@ { - "name": "Ubuntu", + "name": "SerenityOS", "image": "mcr.microsoft.com/devcontainers/base:jammy", // Features to add to the dev container. More info: https://containers.dev/implementors/features. "features": { "ghcr.io/devcontainers/features/github-cli:1": {}, "ghcr.io/devcontainers-contrib/features/pre-commit:1": {}, - "./serenity": { + "./features/serenity": { "llvm_version": 15, "enable_ladybird": true, "enable_serenity": true diff --git a/.devcontainer/serenity/devcontainer-feature.json b/.devcontainer/features/serenity/devcontainer-feature.json similarity index 100% rename from .devcontainer/serenity/devcontainer-feature.json rename to .devcontainer/features/serenity/devcontainer-feature.json diff --git a/.devcontainer/serenity/install.sh b/.devcontainer/features/serenity/install.sh similarity index 100% rename from .devcontainer/serenity/install.sh rename to .devcontainer/features/serenity/install.sh diff --git a/.devcontainer/optimized/.devcontainer.json b/.devcontainer/optimized/.devcontainer.json new file mode 100644 index 00000000000..c7c9c44a191 --- /dev/null +++ b/.devcontainer/optimized/.devcontainer.json @@ -0,0 +1,11 @@ +// The docker image used below was generated from '.devcontainer/devcontainer.json' +// by the '.github/workflows/dev-container.yml' workflow. +// +// By building this dev container image in advance, tools +// like GitHub Codespaces (https://containers.dev/supporting) +// do not need to install all the prerequsite dependencies from scratch, +// getting you into your development environment faster! +{ + "name": "SerenityOS (Pre-Built Image)", + "image": "ghcr.io/SerenityOS/serenity-devcontainer:base" +} diff --git a/.github/workflows/dev-container.yml b/.github/workflows/dev-container.yml new file mode 100644 index 00000000000..be3947750bc --- /dev/null +++ b/.github/workflows/dev-container.yml @@ -0,0 +1,39 @@ +# This workflow builds a docker image with the Dev Container CLI (https://github.com/devcontainers/cli) +# +name: 'Build Dev Container Image' +on: + workflow_dispatch: + push: + paths: + - '.devcontainer/**' + schedule: + # https://crontab.guru/#0_0_*_*_1 + - cron: '0 0 * * 1' + + +permissions: + contents: read + # Push images to GHCR. + packages: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Base Dev Container Image + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/${{ github.repository_owner }}/serenity-devcontainer + imageTag: base,latest + push: always