diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index edee3bc4febb..6e2636b705c7 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,7 +1,9 @@ -# https://github.com/microsoft/vscode-dev-containers/blob/main/containers/python-3/README.md -ARG VARIANT=3.13-bookworm -FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT} -COPY requirements.txt /tmp/pip-tmp/ -RUN python3 -m pip install --upgrade pip \ - && python3 -m pip install --no-cache-dir -r /tmp/pip-tmp/requirements.txt \ - && pipx install pre-commit ruff +# https://github.com/devcontainers/images/tree/main/src/python +# Mirrors the image used by devcontainer.json. Dependencies live in +# pyproject.toml/uv.lock (there is no requirements.txt), so contributors +# install them with `uv sync` inside the container. +ARG VARIANT=latest +FROM mcr.microsoft.com/devcontainers/python:${VARIANT} +RUN pipx install pre-commit \ + && pipx install ruff \ + && pipx install uv diff --git a/.github/workflows/devcontainer_ci.yml b/.github/workflows/devcontainer_ci.yml index f521dad9e72b..0249147f33cd 100644 --- a/.github/workflows/devcontainer_ci.yml +++ b/.github/workflows/devcontainer_ci.yml @@ -2,6 +2,8 @@ name: Test DevContainer Build on: push: + branches: + - master paths: - ".devcontainer/**" - ".github/workflows/devcontainer_ci.yml" @@ -9,15 +11,51 @@ on: paths: - ".devcontainer/**" - ".github/workflows/devcontainer_ci.yml" + workflow_dispatch: + +permissions: + contents: read jobs: - build: + dockerfile: + name: Build .devcontainer/Dockerfile + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - name: Build the image + run: docker build --tag devcontainer-dockerfile .devcontainer + - name: Check the tools are installed + run: | + docker run --rm devcontainer-dockerfile bash -lc ' + set -e + python3 --version + pre-commit --version + ruff --version + uv --version + ' + + devcontainer: + name: Build devcontainer and run post_install runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: persist-credentials: false + # Builds the container from devcontainer.json, runs postCreateCommand + # (which runs .devcontainer/post_install), then runs runCmd inside it. - uses: devcontainers/ci@v0.3 with: push: never - runCmd: "true" + runCmd: | + set -e + pre-commit --version + ruff --version + uv --version + test -f .git/hooks/pre-commit + ZSH_PLUGINS="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins" + test -d "$ZSH_PLUGINS/zsh-autosuggestions" + test -d "$ZSH_PLUGINS/zsh-syntax-highlighting" + grep -q '^plugins=(git zsh-autosuggestions zsh-syntax-highlighting)' ~/.zshrc + echo "Devcontainer initialization verified."