From 9586c5b22eac8f4c2e6bfbcdfe01c9a85fe5b19e Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Wed, 30 Aug 2023 23:55:19 +0100 Subject: [PATCH 1/3] Make CI and deployment.yaml share the same dependency install script --- .github/workflows/test.yaml | 6 +----- deployment.yaml | 11 ++--------- scripts/install_eval_deps.sh | 3 +++ 3 files changed, 6 insertions(+), 14 deletions(-) create mode 100644 scripts/install_eval_deps.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 473b8a7a..3b20aa47 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -116,8 +116,4 @@ jobs: - name: Install eval deps run: | export IMAGE_SUFFIX='-venv:${{ inputs.version }}' - export PYTHONUSERBASE=/snekbox/user_base - docker compose run \ - --rm -T --entrypoint /bin/sh snekbox -c \ - find /lang/python -mindepth 1 -maxdepth 1 -type d -exec \ - {}/bin/python -m pip install --user -U -r requirements/eval-deps.pip \; + docker compose run --rm -T --entrypoint /bin/sh snekbox scripts/install_eval_deps.sh diff --git a/deployment.yaml b/deployment.yaml index 6f188c9f..d580dbd2 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -13,22 +13,15 @@ spec: app: snekbox spec: initContainers: - # Ensure "dry-run-deploy" job of test.yaml is updated with any changes to this init container - name: deps-install image: ghcr.io/python-discord/snekbox:latest imagePullPolicy: Always volumeMounts: - name: snekbox-user-base-volume mountPath: /snekbox/user_base - env: - - name: PYTHONUSERBASE - value: /snekbox/user_base command: - - "/bin/sh" - - "-c" - - >- - find /lang/python -mindepth 1 -maxdepth 1 -type d -exec - {}/bin/python -m pip install --user -U -r requirements/eval-deps.pip \; + - /bin/sh + - scripts/install_eval_deps.sh containers: - name: snekbox image: ghcr.io/python-discord/snekbox:latest diff --git a/scripts/install_eval_deps.sh b/scripts/install_eval_deps.sh new file mode 100644 index 00000000..b5b5fdc9 --- /dev/null +++ b/scripts/install_eval_deps.sh @@ -0,0 +1,3 @@ +export PYTHONUSERBASE=/snekbox/user_base +find /lang/python -mindepth 1 -maxdepth 1 -type d -exec \ + {}/bin/python -m pip install --user -U -r requirements/eval-deps.pip \; From b0180ee7cded3ca51ab832892ae162f13a0e1783 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Thu, 31 Aug 2023 10:06:47 +0100 Subject: [PATCH 2/3] squashme: add set -euo pipefail as sane defaults This also requires running under bash rather than sh --- .github/workflows/test.yaml | 2 +- deployment.yaml | 2 +- scripts/install_eval_deps.sh | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3b20aa47..6f89d87e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -116,4 +116,4 @@ jobs: - name: Install eval deps run: | export IMAGE_SUFFIX='-venv:${{ inputs.version }}' - docker compose run --rm -T --entrypoint /bin/sh snekbox scripts/install_eval_deps.sh + docker compose run --rm -T --entrypoint /bin/bash snekbox scripts/install_eval_deps.sh diff --git a/deployment.yaml b/deployment.yaml index d580dbd2..cad80371 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -20,7 +20,7 @@ spec: - name: snekbox-user-base-volume mountPath: /snekbox/user_base command: - - /bin/sh + - /bin/bash - scripts/install_eval_deps.sh containers: - name: snekbox diff --git a/scripts/install_eval_deps.sh b/scripts/install_eval_deps.sh index b5b5fdc9..716d513c 100644 --- a/scripts/install_eval_deps.sh +++ b/scripts/install_eval_deps.sh @@ -1,3 +1,5 @@ +set -euo pipefail + export PYTHONUSERBASE=/snekbox/user_base find /lang/python -mindepth 1 -maxdepth 1 -type d -exec \ {}/bin/python -m pip install --user -U -r requirements/eval-deps.pip \; From f637e544fb4be27804f9ee414e9174317e2499d4 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Thu, 31 Aug 2023 10:08:38 +0100 Subject: [PATCH 3/3] squashme: add make target for installing eval deps --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index a385a8eb..9ea46cb8 100644 --- a/Makefile +++ b/Makefile @@ -41,3 +41,7 @@ build: .PHONY: devsh devsh: docker compose run --entrypoint /bin/bash --rm snekbox + +.PHONY: eval-deps +eval-deps: + docker compose run --rm -T --entrypoint /bin/bash snekbox scripts/install_eval_deps.sh