Skip to content

Commit 87b385f

Browse files
authored
backend template (#121)
* add service template * add service template * fix default * set to api * remove codeforlife-service-template * add codeforlife-template-backend * fix submodule name * do not deploy backend template * scripts
1 parent 0c3f6fd commit 87b385f

File tree

11 files changed

+59
-9
lines changed

11 files changed

+59
-9
lines changed

.github/workflows/backend.yaml

+11-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ on:
88
type: number
99
required: false
1010
default: 3.8
11+
# TODO: remove this after restructure and standardize source path.
12+
source-path:
13+
description: "The path to the source files."
14+
type: string
15+
required: false
16+
default: "api"
1117
secrets:
1218
CODECOV_TOKEN:
1319
description: "The token used to gain access to Codecov."
@@ -22,21 +28,23 @@ jobs:
2228
secrets: inherit
2329
with:
2430
python-version: ${{ inputs.python-version }}
25-
source-path: src
31+
source-path: ${{ inputs.source-path }}
2632

2733
deploy:
2834
permissions:
29-
id-token: 'write' # TODO: separate build and deploy jobs and create reusable deploy workflow
35+
id-token: "write" # TODO: separate build and deploy jobs and create reusable deploy workflow
3036
runs-on: ubuntu-latest
3137
needs: [validate-pr-refs, test]
3238
# Deploy if:
3339
# - the previous jobs did not fail (see [needs]).
3440
# - the workflow was not cancelled.
3541
# - the repo's owner is Ocado Tech.
42+
# - the repo is not the backend template.
3643
# - a change is made to an environment's branch.
3744
if: |
3845
always() && !failure() && !cancelled() &&
39-
github.repository_owner_id == 2088731 && (
46+
github.repository_owner_id == 2088731 &&
47+
github.repository_id != 610204172 && (
4048
github.ref_name == 'production' ||
4149
github.ref_name == 'development' ||
4250
github.ref_name == 'staging'

.gitmodules

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
[submodule "codeforlife-package-javascript"]
1717
path = codeforlife-package-javascript
1818
url = https://github.com/ocadotechnology/codeforlife-package-javascript.git
19-
[submodule "codeforlife-service-template"]
20-
path = codeforlife-service-template
21-
url = https://github.com/ocadotechnology/codeforlife-service-template.git
2219
[submodule "codeforlife-sso"]
2320
path = codeforlife-sso
2421
url = https://github.com/ocadotechnology/codeforlife-sso.git
@@ -28,3 +25,6 @@
2825
[submodule "codeforlife-portal-backend"]
2926
path = codeforlife-portal-backend
3027
url = https://github.com/ocadotechnology/codeforlife-portal-backend.git
28+
[submodule "codeforlife-template-backend"]
29+
path = codeforlife-template-backend
30+
url = https://github.com/ocadotechnology/codeforlife-template-backend.git

.submodules/config/configs.jsonc

+6-2
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@
357357
],
358358
"description": "A devcontainer for a backend micro-service.",
359359
"submodules": [
360+
"codeforlife-template-backend",
360361
"codeforlife-portal-backend"
361362
],
362363
"vscode": {
@@ -366,10 +367,10 @@
366367
],
367368
"!python.testing.pytestArgs": [
368369
"-n=auto",
369-
"--cov=src",
370+
"--cov=api",
370371
"--cov-report=html",
371372
"-c=pyproject.toml",
372-
"src"
373+
"api"
373374
]
374375
},
375376
"tasks": {
@@ -396,6 +397,9 @@
396397
"runserver",
397398
"localhost:8000"
398399
],
400+
"env": {
401+
"?SERVICE_NAME": "replace-me"
402+
},
399403
"preLaunchTask": "setup"
400404
}
401405
]

codeforlife-service-template

-1
This file was deleted.

codeforlife-template-backend

scripts/backend/hard-install

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
4+
rm -f Pipfile.lock
5+
shopt -s extglob
6+
rm -rf .venv/!(".gitkeep")
7+
shopt -u extglob
8+
pipenv install --dev

scripts/backend/run

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
4+
wget -O - https://raw.githubusercontent.com/ocadotechnology/codeforlife-workspace/main/scripts/backend/setup | bash
5+
6+
pipenv run python manage.py runserver localhost:8000

scripts/backend/setup

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -e
3+
4+
pipenv install --dev
5+
pipenv run python manage.py migrate --noinput
6+
pipenv run python manage.py load_fixtures api
7+
pipenv run python manage.py collectstatic --noinput --clear

scripts/frontend/hard-install

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -e
3+
4+
rm -f yarn.lock
5+
rm -rf node_modules
6+
yarn cache clean codeforlife
7+
yarn install --production=false

scripts/frontend/run

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
4+
wget -O - https://raw.githubusercontent.com/ocadotechnology/codeforlife-workspace/main/scripts/frontend/setup | bash
5+
6+
yarn dev

scripts/frontend/setup

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -e
3+
4+
yarn install --production=false

0 commit comments

Comments
 (0)