diff --git a/.github/workflows/backend.yaml b/.github/workflows/backend.yaml index 3c9d12c1..4b6591f2 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: "api" secrets: CODECOV_TOKEN: description: "The token used to gain access to Codecov." @@ -22,21 +28,23 @@ 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: # - 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' diff --git a/.gitmodules b/.gitmodules index c12a8278..a264e42c 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 @@ -28,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/.submodules/config/configs.jsonc b/.submodules/config/configs.jsonc index 14859433..eac5a4ae 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-template-backend", "codeforlife-portal-backend" ], "vscode": { @@ -366,10 +367,10 @@ ], "!python.testing.pytestArgs": [ "-n=auto", - "--cov=src", + "--cov=api", "--cov-report=html", "-c=pyproject.toml", - "src" + "api" ] }, "tasks": { @@ -396,6 +397,9 @@ "runserver", "localhost:8000" ], + "env": { + "?SERVICE_NAME": "replace-me" + }, "preLaunchTask": "setup" } ] 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 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 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