From d7fd9d2165edae2bbf26517127ded002d1bad810 Mon Sep 17 00:00:00 2001 From: SKairinos Date: Tue, 2 Jul 2024 17:08:50 +0100 Subject: [PATCH 1/9] add service template --- .github/workflows/backend.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backend.yaml b/.github/workflows/backend.yaml index 3c9d12c1..c659ebaf 100644 --- a/.github/workflows/backend.yaml +++ b/.github/workflows/backend.yaml @@ -8,6 +8,12 @@ on: type: number required: false default: 3.8 + # TODO: remove this after restructure and standardize source path. + source-path: + description: "The path to the source files." + type: string + required: false + default: "src" secrets: CODECOV_TOKEN: description: "The token used to gain access to Codecov." @@ -22,11 +28,11 @@ jobs: secrets: inherit with: python-version: ${{ inputs.python-version }} - source-path: src + source-path: ${{ inputs.source-path }} deploy: permissions: - id-token: 'write' # TODO: separate build and deploy jobs and create reusable deploy workflow + id-token: "write" # TODO: separate build and deploy jobs and create reusable deploy workflow runs-on: ubuntu-latest needs: [validate-pr-refs, test] # Deploy if: From f50cf854e35b38c844b1e26643f37de8e94ba84a Mon Sep 17 00:00:00 2001 From: SKairinos Date: Tue, 2 Jul 2024 17:08:59 +0100 Subject: [PATCH 2/9] add service template --- .submodules/config/configs.jsonc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.submodules/config/configs.jsonc b/.submodules/config/configs.jsonc index 14859433..f85a8362 100644 --- a/.submodules/config/configs.jsonc +++ b/.submodules/config/configs.jsonc @@ -357,6 +357,7 @@ ], "description": "A devcontainer for a backend micro-service.", "submodules": [ + "codeforlife-service-template", "codeforlife-portal-backend" ], "vscode": { @@ -396,6 +397,9 @@ "runserver", "localhost:8000" ], + "env": { + "?SERVICE_NAME": "replace-me" + }, "preLaunchTask": "setup" } ] From f0881c156a13c472819982bce3b7e19a661da478 Mon Sep 17 00:00:00 2001 From: SKairinos Date: Tue, 2 Jul 2024 17:10:04 +0100 Subject: [PATCH 3/9] fix default --- .github/workflows/backend.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend.yaml b/.github/workflows/backend.yaml index c659ebaf..b298e447 100644 --- a/.github/workflows/backend.yaml +++ b/.github/workflows/backend.yaml @@ -13,7 +13,7 @@ on: description: "The path to the source files." type: string required: false - default: "src" + default: "api" secrets: CODECOV_TOKEN: description: "The token used to gain access to Codecov." From 79a1c7b689e50b938ae8e6b34f14fd2efd3c6d65 Mon Sep 17 00:00:00 2001 From: SKairinos Date: Tue, 2 Jul 2024 17:10:45 +0100 Subject: [PATCH 4/9] set to api --- .submodules/config/configs.jsonc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.submodules/config/configs.jsonc b/.submodules/config/configs.jsonc index f85a8362..bf30a83d 100644 --- a/.submodules/config/configs.jsonc +++ b/.submodules/config/configs.jsonc @@ -367,10 +367,10 @@ ], "!python.testing.pytestArgs": [ "-n=auto", - "--cov=src", + "--cov=api", "--cov-report=html", "-c=pyproject.toml", - "src" + "api" ] }, "tasks": { From 8a6cdb632486cfac5e12f6f122e0b15d8052e095 Mon Sep 17 00:00:00 2001 From: SKairinos Date: Tue, 2 Jul 2024 17:20:14 +0100 Subject: [PATCH 5/9] remove codeforlife-service-template --- .gitmodules | 3 --- codeforlife-service-template | 1 - 2 files changed, 4 deletions(-) delete mode 160000 codeforlife-service-template diff --git a/.gitmodules b/.gitmodules index c12a8278..eacbaab1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,9 +16,6 @@ [submodule "codeforlife-package-javascript"] path = codeforlife-package-javascript url = https://github.com/ocadotechnology/codeforlife-package-javascript.git -[submodule "codeforlife-service-template"] - path = codeforlife-service-template - url = https://github.com/ocadotechnology/codeforlife-service-template.git [submodule "codeforlife-sso"] path = codeforlife-sso url = https://github.com/ocadotechnology/codeforlife-sso.git diff --git a/codeforlife-service-template b/codeforlife-service-template deleted file mode 160000 index a08d96e1..00000000 --- a/codeforlife-service-template +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a08d96e1b882b70b45881fc65c2b63e784265382 From b6d0607737ccaacf6577f67b147d2aae90e86464 Mon Sep 17 00:00:00 2001 From: SKairinos Date: Tue, 2 Jul 2024 17:21:37 +0100 Subject: [PATCH 6/9] add codeforlife-template-backend --- .gitmodules | 3 +++ codeforlife-template-backend | 1 + 2 files changed, 4 insertions(+) create mode 160000 codeforlife-template-backend diff --git a/.gitmodules b/.gitmodules index eacbaab1..a264e42c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -25,3 +25,6 @@ [submodule "codeforlife-portal-backend"] path = codeforlife-portal-backend url = https://github.com/ocadotechnology/codeforlife-portal-backend.git +[submodule "codeforlife-template-backend"] + path = codeforlife-template-backend + url = https://github.com/ocadotechnology/codeforlife-template-backend.git diff --git a/codeforlife-template-backend b/codeforlife-template-backend new file mode 160000 index 00000000..99ebb7f6 --- /dev/null +++ b/codeforlife-template-backend @@ -0,0 +1 @@ +Subproject commit 99ebb7f6f47cd56f19eddf1bf1f84d4b49ba9aae From 73a034de7dba7f53de742441359d66265dae25dc Mon Sep 17 00:00:00 2001 From: SKairinos Date: Tue, 2 Jul 2024 17:22:50 +0100 Subject: [PATCH 7/9] fix submodule name --- .submodules/config/configs.jsonc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.submodules/config/configs.jsonc b/.submodules/config/configs.jsonc index bf30a83d..eac5a4ae 100644 --- a/.submodules/config/configs.jsonc +++ b/.submodules/config/configs.jsonc @@ -357,7 +357,7 @@ ], "description": "A devcontainer for a backend micro-service.", "submodules": [ - "codeforlife-service-template", + "codeforlife-template-backend", "codeforlife-portal-backend" ], "vscode": { From 432362370723248f455f4fdaba1f987f77e8b053 Mon Sep 17 00:00:00 2001 From: SKairinos Date: Tue, 2 Jul 2024 17:36:19 +0100 Subject: [PATCH 8/9] do not deploy backend template --- .github/workflows/backend.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/backend.yaml b/.github/workflows/backend.yaml index b298e447..4b6591f2 100644 --- a/.github/workflows/backend.yaml +++ b/.github/workflows/backend.yaml @@ -39,10 +39,12 @@ jobs: # - the previous jobs did not fail (see [needs]). # - the workflow was not cancelled. # - the repo's owner is Ocado Tech. + # - the repo is not the backend template. # - a change is made to an environment's branch. if: | always() && !failure() && !cancelled() && - github.repository_owner_id == 2088731 && ( + github.repository_owner_id == 2088731 && + github.repository_id != 610204172 && ( github.ref_name == 'production' || github.ref_name == 'development' || github.ref_name == 'staging' From 72745e8342fbcab1a9317b3dbf6879a95deb02cf Mon Sep 17 00:00:00 2001 From: SKairinos Date: Thu, 4 Jul 2024 14:29:04 +0100 Subject: [PATCH 9/9] scripts --- scripts/backend/hard-install | 8 ++++++++ scripts/backend/run | 6 ++++++ scripts/backend/setup | 7 +++++++ scripts/frontend/hard-install | 7 +++++++ scripts/frontend/run | 6 ++++++ scripts/frontend/setup | 4 ++++ 6 files changed, 38 insertions(+) create mode 100644 scripts/backend/hard-install create mode 100644 scripts/backend/run create mode 100644 scripts/backend/setup create mode 100644 scripts/frontend/hard-install create mode 100644 scripts/frontend/run create mode 100644 scripts/frontend/setup diff --git a/scripts/backend/hard-install b/scripts/backend/hard-install new file mode 100644 index 00000000..eda5b2fc --- /dev/null +++ b/scripts/backend/hard-install @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +rm -f Pipfile.lock +shopt -s extglob +rm -rf .venv/!(".gitkeep") +shopt -u extglob +pipenv install --dev diff --git a/scripts/backend/run b/scripts/backend/run new file mode 100644 index 00000000..f60f3e7b --- /dev/null +++ b/scripts/backend/run @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +wget -O - https://raw.githubusercontent.com/ocadotechnology/codeforlife-workspace/main/scripts/backend/setup | bash + +pipenv run python manage.py runserver localhost:8000 diff --git a/scripts/backend/setup b/scripts/backend/setup new file mode 100644 index 00000000..65806c92 --- /dev/null +++ b/scripts/backend/setup @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +pipenv install --dev +pipenv run python manage.py migrate --noinput +pipenv run python manage.py load_fixtures api +pipenv run python manage.py collectstatic --noinput --clear diff --git a/scripts/frontend/hard-install b/scripts/frontend/hard-install new file mode 100644 index 00000000..8191494c --- /dev/null +++ b/scripts/frontend/hard-install @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +rm -f yarn.lock +rm -rf node_modules +yarn cache clean codeforlife +yarn install --production=false diff --git a/scripts/frontend/run b/scripts/frontend/run new file mode 100644 index 00000000..22994acd --- /dev/null +++ b/scripts/frontend/run @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +wget -O - https://raw.githubusercontent.com/ocadotechnology/codeforlife-workspace/main/scripts/frontend/setup | bash + +yarn dev diff --git a/scripts/frontend/setup b/scripts/frontend/setup new file mode 100644 index 00000000..94b55889 --- /dev/null +++ b/scripts/frontend/setup @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +yarn install --production=false