diff --git a/.config/appveyor/main.yml b/.config/appveyor/main.yml deleted file mode 100644 index b1845c8..0000000 --- a/.config/appveyor/main.yml +++ /dev/null @@ -1,22 +0,0 @@ -version: 1.0.{build} -branches: - only: - - main -skip_tags: true -image: Ubuntu2004 -build_script: - - sh: >- - set -e - - npm install --global @devcontainers/cli - - devcontainer build --workspace-folder . -test_script: - - sh: >- - set -e - - devcontainer up --workspace-folder . - - devcontainer exec --workspace-folder . pnpm lint - - devcontainer exec --workspace-folder . pnpm test diff --git a/.config/appveyor/publish.yml b/.config/appveyor/publish.yml deleted file mode 100644 index 8d956fc..0000000 --- a/.config/appveyor/publish.yml +++ /dev/null @@ -1,22 +0,0 @@ -version: 1.0.{build} -branches: - only: - - main -skip_non_tags: true -image: Ubuntu2004 -environment: - CR_PAT: CR_PAT -build_script: - - sh: >- - set -e - - npm install --global @devcontainers/cli - - devcontainer build --workspace-folder . -deploy_script: - - sh: >- - set -e - - devcontainer up --workspace-folder . - - devcontainer exec --workspace-folder . --remote-env CR_PAT=${CR_PAT} pnpm run publish diff --git a/.config/git/ignore b/.config/git/ignore index 1366379..3e9b32f 100644 --- a/.config/git/ignore +++ b/.config/git/ignore @@ -4,6 +4,8 @@ _* !**/.devcontainer/** !.config/ !**/.config/** +!.github/ +!**/.github/** local.env node_modules/ diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 0d0d670..6363071 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,6 +1,12 @@ FROM mcr.microsoft.com/devcontainers/javascript-node:24-bookworm -RUN npm install --global pnpm@latest-11 +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + clang \ + zlib1g-dev \ + lld \ + && rm -rf /var/lib/apt/lists/* \ + && npm install --global pnpm@latest-11 RUN mkdir --parents /usr/share/dotnet /usr/share/devcontainer-config/NuGet/global-packages \ && chmod --recursive a+rwX /usr/share/dotnet /usr/share/devcontainer-config diff --git a/.devcontainer/features/test/user-init/index.test.ts b/.devcontainer/features/test/user-init/index.test.ts index 608ec80..8bfa9cd 100644 --- a/.devcontainer/features/test/user-init/index.test.ts +++ b/.devcontainer/features/test/user-init/index.test.ts @@ -1,16 +1,29 @@ import { R_OK, W_OK, X_OK } from "node:constants"; -import { access } from "node:fs/promises"; +import { access, stat } from "node:fs/promises"; +import { userInfo } from "node:os"; import { expect, test } from "vitest"; -test("uid", () => { - expect(process.getuid?.()).toBe(1000); +test("remote user home", async () => { + const { username, uid, gid, homedir } = userInfo(); + + expect(homedir).toBe(`/home/${username}`); + + const home = await stat(homedir); + expect(home.uid).toBe(uid); + expect(home.gid).toBe(gid); }); test("XDG base directories", async () => { - await access("/etc/devcontainer-config", R_OK | W_OK | X_OK); - await access("/var/cache/devcontainer-config", R_OK | W_OK | X_OK); - await access("/usr/share/devcontainer-config", R_OK | W_OK | X_OK); - await access("/var/lib/devcontainer-config", R_OK | W_OK | X_OK); - expect(true).toBe(true); + const dirs = { + XDG_CONFIG_HOME: "/etc/devcontainer-config", + XDG_CACHE_HOME: "/var/cache/devcontainer-config", + XDG_DATA_HOME: "/usr/share/devcontainer-config", + XDG_STATE_HOME: "/var/lib/devcontainer-config", + } as const; + + for (const [name, dir] of Object.entries(dirs)) { + expect(process.env[name]).toBe(dir); + await access(dir, R_OK | W_OK | X_OK); + } }); diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..bba9eaf --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,48 @@ +name: "Main" + +on: + pull_request: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + packages: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout (GitHub) + uses: actions/checkout@v7 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ github.token }} + + - name: Pre-build dev container image + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/${{ github.repository }}/devcontainer + cacheFrom: ghcr.io/${{ github.repository }}/devcontainer + push: filter + refFilterForPush: refs/heads/main + + - name: Lint + uses: devcontainers/ci@v0.3 + with: + cacheFrom: ghcr.io/${{ github.repository }}/devcontainer + push: never + runCmd: pnpm lint + + - name: Test + uses: devcontainers/ci@v0.3 + with: + cacheFrom: ghcr.io/${{ github.repository }}/devcontainer + push: never + runCmd: pnpm test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..fb51f1b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +name: "Publish" + +on: + push: + tags: + - "*_[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: + +permissions: + contents: read + packages: read + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout (GitHub) + uses: actions/checkout@v7 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ github.token }} + + - name: Publish + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/${{ github.repository }}/devcontainer + cacheFrom: ghcr.io/${{ github.repository }}/devcontainer + push: never + runCmd: pnpm run publish + env: | + CR_PAT=${{ secrets.CR_PAT }} diff --git a/ReadMe.md b/ReadMe.md index 6e9af28..6ff5566 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,9 +1,9 @@ # Devcontainer Features for Devcontainer Configurations -[AppVeyor Badge]: https://img.shields.io/appveyor/build/gdlol/devcontainer-config-features/main -[AppVeyor URL]: https://ci.appveyor.com/project/gdlol/devcontainer-config-features/branch/main +[CI Badge]: https://img.shields.io/github/actions/workflow/status/devcontainer-config/features/.github%2Fworkflows%2Fmain.yml +[CI URL]: https://github.com/devcontainer-config/features/actions/workflows/main.yml -[![AppVeyor Badge][AppVeyor Badge]][AppVeyor URL] +[![CI Badge][CI Badge]][CI URL] A set of devcontainer features for better developer experience setting up devcontainers. diff --git a/scripts/runner.ts b/scripts/runner.ts index 3727cf5..edf1f4c 100644 --- a/scripts/runner.ts +++ b/scripts/runner.ts @@ -30,8 +30,8 @@ export const createDevContainerRunner = async (env: Record = {}) return { workspaceFolder: workspacePath, start: async ({ skipPostCreate = false } = {}) => { - await $$`devcontainer build`; - await $$`devcontainer up --remove-existing-container ${skipPostCreate ? ["--skip-post-create"] : []} ${remoteEnv}`; + await $$`devcontainer build --no-lockfile`; + await $$`devcontainer up --no-lockfile --remove-existing-container ${skipPostCreate ? ["--skip-post-create"] : []} ${remoteEnv}`; }, exec: async (command: string, ...args: string[]): Promise => { await $$`devcontainer exec ${remoteEnv} ${command} ${args}`; @@ -44,7 +44,7 @@ export const createDevContainerRunner = async (env: Record = {}) reject: false, stdio: "ignore", env: { COMPOSE_PROJECT_NAME: composeProject }, - })`devcontainer up --remove-existing-container`; + })`devcontainer up --no-lockfile --remove-existing-container`; await removeComposeProject(composeProject);