Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend template #121

Merged
merged 9 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
8 changes: 6 additions & 2 deletions .submodules/config/configs.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@
],
"description": "A devcontainer for a backend micro-service.",
"submodules": [
"codeforlife-template-backend",
"codeforlife-portal-backend"
],
"vscode": {
Expand All @@ -366,10 +367,10 @@
],
"!python.testing.pytestArgs": [
"-n=auto",
"--cov=src",
"--cov=api",
"--cov-report=html",
"-c=pyproject.toml",
"src"
"api"
]
},
"tasks": {
Expand All @@ -396,6 +397,9 @@
"runserver",
"localhost:8000"
],
"env": {
"?SERVICE_NAME": "replace-me"
},
"preLaunchTask": "setup"
}
]
Expand Down
1 change: 0 additions & 1 deletion codeforlife-service-template
Submodule codeforlife-service-template deleted from a08d96
1 change: 1 addition & 0 deletions codeforlife-template-backend
8 changes: 8 additions & 0 deletions scripts/backend/hard-install
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions scripts/backend/run
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions scripts/backend/setup
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions scripts/frontend/hard-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

rm -f yarn.lock
rm -rf node_modules
yarn cache clean codeforlife
yarn install --production=false
6 changes: 6 additions & 0 deletions scripts/frontend/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

wget -O - https://raw.githubusercontent.com/ocadotechnology/codeforlife-workspace/main/scripts/frontend/setup | bash

yarn dev
4 changes: 4 additions & 0 deletions scripts/frontend/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e

yarn install --production=false