From f11fd39ee3d261230ac57a1cf9f7de8f43095a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Piku=C5=82a?= Date: Tue, 30 May 2023 09:35:27 +0200 Subject: [PATCH] Update devcontainer setup and use GHCR to host the image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marek PikuĊ‚a --- .devcontainer/Dockerfile | 18 ------------------ .devcontainer/devcontainer.json | 31 ++++++++++++++++++------------- .github/workflows/build.yml | 21 +++++++++++++++++++++ 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9077949..2e19b4c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,21 +3,3 @@ # [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster ARG VARIANT="3.7" FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} - -# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 -# ARG NODE_VERSION="none" -# RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi - -RUN pipx install poetry - -# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. -# COPY requirements.txt /tmp/pip-tmp/ -# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ -# && rm -rf /tmp/pip-tmp - -# [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends - -# [Optional] Uncomment this line to install global node packages. -# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6b95632..db17dc0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,14 +3,19 @@ { "name": "Python 3", "build": { - "dockerfile": "Dockerfile", - "context": "..", + "dockerfile": "./Dockerfile", + "context": ".", "args": { // Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6 // Append -bullseye or -buster to pin to an OS version. // Use -bullseye variants on local on arm64/Apple Silicon. - "VARIANT": "3.7", - } + "VARIANT": "3.7" + }, + "cacheFrom": "ghcr.io/systemrdl/peakrdl-markdown/devcontainer" + }, + "features": { + "ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {}, + "ghcr.io/devcontainers-contrib/features/poetry:2": {} }, // Configure tool-specific properties. @@ -27,18 +32,22 @@ "python.linting.mypyPath": "${workspaceFolder}/.venv/bin/mypy", "python.linting.pycodestylePath": "${workspaceFolder}/.venv/bin/pycodestyle", "python.linting.pydocstylePath": "${workspaceFolder}/.venv/bin/pydocstyle", - "python.venvPath": "${workspaceFolder}/.venv", + "python.venvPath": "${workspaceFolder}/.venv" }, // Add the IDs of extensions you want installed when the container is created. "extensions": [ "bungcip.better-toml", + "charliermarsh.ruff", + "github.vscode-github-actions", + "GitHub.vscode-pull-request-github", + "mhutchie.git-graph", "ms-python.python", + "njpwerner.autodocstring", "ms-python.vscode-pylance", "njpwerner.autodocstring", "ryanluker.vscode-coverage-gutters", - "mhutchie.git-graph", - "GitHub.vscode-pull-request-github" + "streetsidesoftware.code-spell-checker" ] } }, @@ -47,12 +56,8 @@ // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "poetry config virtualenvs.in-project true && poetry install", + "postCreateCommand": "poetry install --all-extras", // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode", - "features": { - "git": "os-provided", - "fish": "latest" - } + "remoteUser": "vscode" } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6267ffd..35238a0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,27 @@ on: jobs: + build-devcontainer: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + steps: + - name: Checkout (GitHub) + 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 and run Dev Container task + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/systemrdl/peakrdl-markdown/devcontainer + cacheFrom: ghcr.io/systemrdl/peakrdl-markdown/devcontainer + push: always + test: runs-on: ubuntu-latest strategy: