From 899e0917fd7f18d29eee8df8943bba5349dcab1f Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Mon, 27 Jan 2025 18:00:35 -0800 Subject: [PATCH] chore: update the Dev Container 24.01 Edition (#2975) --- .devcontainer/devcontainer.json | 102 ++++++++---------- .../actions/setup-dev-container/action.yml | 87 ++++++++------- apps/iatlas/api/poetry.lock | 18 ++-- apps/iatlas/api/pyproject.toml | 35 +++--- dev-env.sh | 25 ++++- libs/sandbox/py-lib/project.json | 9 +- package.json | 2 +- tools/check-devcontainer-version.js | 2 +- tools/workspace-install.sh | 15 +++ 9 files changed, 163 insertions(+), 132 deletions(-) create mode 100755 tools/workspace-install.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0d548718e3..18af15fe04 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { - "name": "Sage Dev Container", - "image": "ghcr.io/sage-bionetworks/sage-devcontainer:fab0893", + "name": "Sage Monorepo Dev Container", + "image": "ghcr.io/sage-bionetworks/sage-monorepo-devcontainer:sha-c7e2cdbc88fb8cc4815dafedd92b105e4b9544f2", "containerEnv": { "NX_BASE": "${localEnv:NX_BASE}", "NX_BRANCH": "${localEnv:NX_BRANCH}", @@ -14,58 +14,7 @@ "DOCKER_USERNAME": "${localEnv:DOCKER_USERNAME}", "DOCKER_PASSWORD": "${localEnv:DOCKER_PASSWORD}" }, - "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2.11.0": { - "version": "27.0.3", - "moby": false - } - }, - "customizations": { - "codespaces": { - "openFiles": ["README.md"] - }, - "vscode": { - "extensions": [ - "alefragnani.Bookmarks", - "Angular.ng-template", - "dbaeumer.vscode-eslint", - "donjayamanne.python-environment-manager", - "dorzey.vscode-sqlfluff", - "eamodio.gitlens", - "emeraldwalk.RunOnSave", - "esbenp.prettier-vscode", - "exiasr.hadolint", - "formulahendry.auto-rename-tag", - "github.vscode-github-actions", - "GitHub.vscode-pull-request-github", - "Gruntfuggly.todo-tree", - "humao.rest-client", - "mhutchie.git-graph", - "mongodb.mongodb-vscode", - "ms-playwright.playwright", - "ms-python.black-formatter", - "ms-python.python", - "ms-toolsai.jupyter", - "mtxr.sqltools-driver-mysql", - "mtxr.sqltools-driver-pg", - "mtxr.sqltools", - "njpwerner.autodocstring", - "Orta.vscode-jest", - "pranaygp.vscode-css-peek", - "ritwickdey.LiveServer", - "shengchen.vscode-checkstyle", - "SonarSource.sonarlint-vscode", - "stkb.rewrap", - "stylelint.vscode-stylelint", - "vmware.vscode-boot-dev-pack", - "vscjava.vscode-gradle", - "vscjava.vscode-java-pack" - ], - "settings": { - "workbench.startupEditor": "readme" - } - } - }, + "features": {}, "forwardPorts": [ 2432, 3306, 3333, 4200, 4211, 5000, 5200, 5432, 5601, 8010, 8071, 8000, 8080, 8081, 8082, 8084, 8085, 8086, 8090, 8200, 8888, 8889, 9200, 9411, 27017 @@ -164,7 +113,48 @@ "onAutoForward": "silent" } }, - "remoteUser": "vscode", + "otherPortsAttributes": { + "onAutoForward": "silent" + }, "shutdownAction": "stopContainer", - "runArgs": ["--name", "sage_devcontainer"] + "runArgs": ["--name", "sage-monorepo-devcontainer"], + "customizations": { + "vscode": { + "extensions": [ + "alefragnani.Bookmarks", + "Angular.ng-template", + "dbaeumer.vscode-eslint", + "donjayamanne.python-environment-manager", + "eamodio.gitlens", + "emeraldwalk.RunOnSave", + "esbenp.prettier-vscode", + "exiasr.hadolint", + "formulahendry.auto-rename-tag", + "github.vscode-github-actions", + "GitHub.vscode-pull-request-github", + "Gruntfuggly.todo-tree", + "humao.rest-client", + "mhutchie.git-graph", + "mongodb.mongodb-vscode", + "ms-playwright.playwright", + "ms-python.black-formatter", + "ms-python.python", + "ms-toolsai.jupyter", + "mtxr.sqltools-driver-mysql", + "mtxr.sqltools-driver-pg", + "mtxr.sqltools", + "njpwerner.autodocstring", + "Orta.vscode-jest", + "pranaygp.vscode-css-peek", + "ritwickdey.LiveServer", + "shengchen.vscode-checkstyle", + "SonarSource.sonarlint-vscode", + "stkb.rewrap", + "stylelint.vscode-stylelint", + "vmware.vscode-boot-dev-pack", + "vscjava.vscode-gradle", + "vscjava.vscode-java-pack" + ] + } + } } diff --git a/.github/actions/setup-dev-container/action.yml b/.github/actions/setup-dev-container/action.yml index a840d6f501..d18b6981e3 100644 --- a/.github/actions/setup-dev-container/action.yml +++ b/.github/actions/setup-dev-container/action.yml @@ -1,5 +1,10 @@ name: 'Set up the dev container' -description: 'Installs the dev container CLI, fetches caches (if exist), and starts the dev container' +description: 'Installs the dev container CLI, fetches caches (if exist), and starts the dev container.' +inputs: + devcontainer-user: + description: 'The dev container user.' + required: false + default: 'ubuntu' runs: using: 'composite' steps: @@ -11,43 +16,45 @@ runs: # restore-keys: | # ${{ runner.os }}-pnpm-store- - - name: Set up Renv cache - uses: actions/cache@v3 - with: - path: '/tmp/.cache/R/renv/cache' - key: ${{ runner.os }}-renv-cache-${{ hashFiles('**/renv.lock') }} - restore-keys: | - ${{ runner.os }}-renv-cache- + # - name: Set up Renv cache + # uses: actions/cache@v3 + # with: + # path: '/tmp/.cache/R/renv/cache' + # key: ${{ runner.os }}-renv-cache-${{ hashFiles('**/renv.lock') }} + # restore-keys: | + # ${{ runner.os }}-renv-cache- - - name: Set up Poetry cache - uses: actions/cache@v3 - with: - path: '/tmp/.cache/pypoetry' - key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} + # - name: Set up Poetry cache + # uses: actions/cache@v3 + # with: + # path: '/tmp/.cache/pypoetry' + # key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} - - name: Set up venv cache - uses: actions/cache@v3 - with: - path: | - /tmp/.local/share/virtualenv - **/.venv - key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }} + # - name: Set up venv cache + # uses: actions/cache@v3 + # with: + # path: | + # /tmp/.local/share/virtualenv + # **/.venv + # key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }} - - name: Set up Gradle cache - uses: actions/cache@v3 - with: - path: | - /tmp/.gradle/caches - /tmp/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- + # - name: Set up Gradle cache + # uses: actions/cache@v3 + # with: + # path: | + # /tmp/.gradle/caches + # /tmp/.gradle/wrapper + # key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + # restore-keys: | + # ${{ runner.os }}-gradle- - name: Install the Dev Container CLI shell: bash - run: npm install -g @devcontainers/cli@0.69.0 + run: npm install -g @devcontainers/cli@0.72.0 - name: Start the dev container + env: + DEVCONTAINER_USER: ${{ inputs.devcontainer-user }} shell: bash run: | mkdir -p \ @@ -60,21 +67,23 @@ runs: devcontainer up \ --mount type=bind,source=/tmp/.pnpm-store,target=/workspaces/sage-monorepo/.pnpm-store \ - --mount type=bind,source=/tmp/.cache/R/renv/cache,target=/home/vscode/.cache/R/renv/cache \ - --mount type=bind,source=/tmp/.cache/pypoetry,target=/home/vscode/.cache/pypoetry \ - --mount type=bind,source=/tmp/.local/share/virtualenv,target=/home/vscode/.local/share/virtualenv \ - --mount type=bind,source=/tmp/.gradle/caches,target=/home/vscode/.gradle/caches \ - --mount type=bind,source=/tmp/.gradle/wrapper,target=/home/vscode/.gradle/wrapper \ + --mount type=bind,source=/tmp/.cache/R/renv/cache,target=/home/${DEVCONTAINER_USER}/.cache/R/renv/cache \ + --mount type=bind,source=/tmp/.cache/pypoetry,target=/home/${DEVCONTAINER_USER}/.cache/pypoetry \ + --mount type=bind,source=/tmp/.local/share/virtualenv,target=/home/${DEVCONTAINER_USER}/.local/share/virtualenv \ + --mount type=bind,source=/tmp/.gradle/caches,target=/home/${DEVCONTAINER_USER}/.gradle/caches \ + --mount type=bind,source=/tmp/.gradle/wrapper,target=/home/${DEVCONTAINER_USER}/.gradle/wrapper \ --workspace-folder ../sage-monorepo - name: Prepare the workspace + env: + DEVCONTAINER_USER: ${{ inputs.devcontainer-user }} shell: bash run: | devcontainer exec --workspace-folder ../sage-monorepo bash -c " - sudo chown -R vscode:vscode \ + sudo chown -R ${DEVCONTAINER_USER}:${DEVCONTAINER_USER} \ /workspaces/sage-monorepo \ - /home/vscode/.cache \ - /home/vscode/.local \ - /home/vscode/.gradle \ + /home/${DEVCONTAINER_USER}/.cache \ + /home/${DEVCONTAINER_USER}/.local \ + /home/${DEVCONTAINER_USER}/.gradle \ && . ./dev-env.sh \ && workspace-install-affected" diff --git a/apps/iatlas/api/poetry.lock b/apps/iatlas/api/poetry.lock index c8ec28e104..4a2fdd04e6 100644 --- a/apps/iatlas/api/poetry.lock +++ b/apps/iatlas/api/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. [[package]] name = "ariadne" @@ -46,19 +46,19 @@ files = [ [[package]] name = "attrs" -version = "24.2.0" +version = "24.3.0" description = "Classes Without Boilerplate" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "attrs-24.2.0-py3-none-any.whl", hash = "sha256:81921eb96de3191c8258c199618104dd27ac608d9366f5e35d011eae1867ede2"}, - {file = "attrs-24.2.0.tar.gz", hash = "sha256:5cfb1b9148b5b086569baec03f20d7b6bf3bcacc9a42bebf87ffaaca362f6346"}, + {file = "attrs-24.3.0-py3-none-any.whl", hash = "sha256:ac96cd038792094f438ad1f6ff80837353805ac950cd2aa0e0625ef19850c308"}, + {file = "attrs-24.3.0.tar.gz", hash = "sha256:8f5c07333d543103541ba7be0e2ce16eeee8130cb0b3f9238ab904ce1e85baff"}, ] [package.extras] benchmark = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins", "pytest-xdist[psutil]"] cov = ["cloudpickle", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] -dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] docs = ["cogapp", "furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier (<24.7)"] tests = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"] @@ -776,12 +776,12 @@ files = [ [[package]] name = "uwsgi" -version = "2.0.19.1" +version = "2.0.28" description = "The uWSGI server" optional = false python-versions = "*" files = [ - {file = "uWSGI-2.0.19.1.tar.gz", hash = "sha256:faa85e053c0b1be4d5585b0858d3a511d2cd10201802e8676060fd0a109e5869"}, + {file = "uwsgi-2.0.28.tar.gz", hash = "sha256:79ca1891ef2df14508ab0471ee8c0eb94bd2d51d03f32f90c4bbe557ab1e99d0"}, ] [[package]] @@ -812,4 +812,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "3.8.20" -content-hash = "cc20f624b0a572b4d6e377386a4df25cd8b8034a249ebe2e1d9abf01ee651611" +content-hash = "5d916c47ddf016772ca11a37795ce9164c2d7f600de1d62750ed3cd90cea45c5" diff --git a/apps/iatlas/api/pyproject.toml b/apps/iatlas/api/pyproject.toml index 08388e59db..74b6faf5de 100644 --- a/apps/iatlas/api/pyproject.toml +++ b/apps/iatlas/api/pyproject.toml @@ -9,21 +9,24 @@ authors = [ ] readme = "README.md" -[tool.poetry.dependencies] -python = "3.8.20" -ariadne = "0.13.0" -click = "7.1.2" -flask = "1.1.2" -flask-sqlalchemy = "2.4.3" -graphql-core = "3.1.0" -itsdangerous = "1.1.0" -jinja2 = "2.11.2" -markupsafe = "1.1.1" -psycopg2-binary = "2.8.5" -sqlalchemy = "1.3.17" -starlette = "0.13.4" -typing-extensions = "3.7.4.2" -werkzeug = "1.0.1" + [[tool.poetry.packages]] + include = "api" + + [tool.poetry.dependencies] + python = "3.8.20" + ariadne = "0.13.0" + click = "7.1.2" + flask = "1.1.2" + flask-sqlalchemy = "2.4.3" + graphql-core = "3.1.0" + itsdangerous = "1.1.0" + jinja2 = "2.11.2" + markupsafe = "1.1.1" + psycopg2-binary = "2.8.5" + sqlalchemy = "1.3.17" + starlette = "0.13.4" + typing-extensions = "3.7.4.2" + werkzeug = "1.0.1" [tool.poetry.group.dev.dependencies] autopep8 = "1.5.4" @@ -36,7 +39,7 @@ pytest-xdist = "2.1.0" snakeviz = "2.1.0" [tool.poetry.group.prod.dependencies] -uWSGI = "2.0.19.1" +uWSGI = "2.0.28" [tool.pytest.ini_options] log_cli = true diff --git a/dev-env.sh b/dev-env.sh index 6e03e9a1b8..486c8623be 100644 --- a/dev-env.sh +++ b/dev-env.sh @@ -42,8 +42,9 @@ function workspace-install-affected { workspace-install-nodejs-dependencies workspace-install-python-dependencies nx affected --target=create-config - nx affected --target=prepare --exclude '!tag:language:java' --parallel=1 - nx affected --target=prepare --exclude 'tag:language:java' + nx affected --target=prepare --projects=tag:language:java --parallel=1 + nx affected --target=prepare --projects=tag:language:python --parallel=1 + nx affected --target=prepare --projects=tag:language:r } # Setup Python virtualenvs @@ -176,6 +177,22 @@ function workspace-initialize-env { export COREPACK_ENABLE_DOWNLOAD_PROMPT="0" } -function workspace-nuke-venv { - find . -name ".venv" -print0 | xargs -0 rm -fr +function workspace-nuke { + rm -fr \ + .angular \ + .cache \ + .nx \ + .pnpm-store \ + coverage \ + playwright-report \ + reports + + # find . -name "build" -print0 | xargs -0 rm -fr # but not OA build folders + find . -name ".coverage" -print0 | xargs -0 rm -fr + find . -name ".gradle" -print0 | xargs -0 rm -fr + find . -name ".pytest_cache" -print0 | xargs -0 rm -fr + find . -name ".venv" -print0 | xargs -0 rm -fr + find . -name "bin" -print0 | xargs -0 rm -fr + find . -name "dist" -print0 | xargs -0 rm -fr + find . -name "node_modules" -print0 | xargs -0 rm -fr } \ No newline at end of file diff --git a/libs/sandbox/py-lib/project.json b/libs/sandbox/py-lib/project.json index b6296c219f..8fb504df8b 100644 --- a/libs/sandbox/py-lib/project.json +++ b/libs/sandbox/py-lib/project.json @@ -22,13 +22,10 @@ } }, "prepare": { - "executor": "@nxlv/python:install", + "executor": "nx:run-commands", "options": { - "silent": false, - "args": "", - "cacheDir": ".cache/pypoetry", - "verbose": false, - "debug": false + "command": "./install.sh", + "cwd": "{projectRoot}" } }, "update": { diff --git a/package.json b/package.json index f2092b931b..d5174c3edd 100644 --- a/package.json +++ b/package.json @@ -196,5 +196,5 @@ "vite": "5.2.11", "vitest": "1.6.0" }, - "packageManager": "pnpm@9.9.0" + "packageManager": "pnpm@9.15.4" } diff --git a/tools/check-devcontainer-version.js b/tools/check-devcontainer-version.js index bef896a161..4c53055553 100644 --- a/tools/check-devcontainer-version.js +++ b/tools/check-devcontainer-version.js @@ -23,7 +23,7 @@ if (currentDevcontainerVersion === undefined) { process.exit(0); } -if (expectedDevcontainerVersion !== currentDevcontainerVersion) { +if (expectedDevcontainerVersion !== `sha-${currentDevcontainerVersion}`) { console.info('🐋 The dev container has changed. Please rebuild it.'); // console.debug(`Expected dev container version: ${expectedDevcontainerVersion}`); // console.debug(`Current dev container version: ${currentDevcontainerVersion}`); diff --git a/tools/workspace-install.sh b/tools/workspace-install.sh new file mode 100755 index 0000000000..7aa3b84259 --- /dev/null +++ b/tools/workspace-install.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Install Node.js dependencies +pnpm install --frozen-lockfile + +# Install workspace Python dependencies +# poetry env use $(pyenv which python) +# poetry install --with dev + +# Prepare projects +pnpm dlx nx run-many --target=create-config +pnpm dlx nx run-many --target=prepare --projects=tag:language:java --parallel=1 +# nx run-many --target=prepare --projects=tag:language:python --parallel=1 +pnpm dlx nx run-many --target=prepare --projects=tag:language:r +