generated from ocadotechnology/codeforlife-template-backend
-
Notifications
You must be signed in to change notification settings - Fork 24
170 lines (145 loc) Β· 5.6 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Main
on:
pull_request:
push:
paths-ignore:
- "**/*.md"
- "**/.*"
workflow_dispatch:
env:
CYPRESS_WAIT_ON: http://localhost:8000
CYPRESS_WAIT_ON_TIMEOUT: 600
CYPRESS_SPEC: cypress/e2e/**/*.cy.ts
SERVICE: portal
PYTHON_VERSION: 3.8
jobs:
test-backend:
uses: ocadotechnology/codeforlife-workspace/.github/workflows/test-python-code.yaml@main
with:
working-directory: backend
# # The below code was adapted from this documentation.
# # https://docs.cypress.io/guides/continuous-integration/github-actions#Parallelization
# # https://github.com/cypress-io/cypress-docker-images/tree/master/browsers
# test-chrome:
# runs-on: ubuntu-latest
# steps:
# - name: π« Checkout
# uses: actions/checkout@v3
# - name: π Setup Python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ env.PYTHON_VERSION }}
# architecture: "x64"
# - name: π§ͺ Test on Chrome
# uses: cypress-io/[email protected]
# with:
# working-directory: frontend
# #TODO: Currently using the run script for local development
# start: bash ../run
# wait-on: ${{ env.CYPRESS_WAIT_ON }}
# wait-on-timeout: ${{ env.CYPRESS_WAIT_ON_TIMEOUT }}
# browser: chrome
# record: true
# spec: ${{ env.CYPRESS_SPEC }}
# cache-key: os-${{ runner.os }}-dependencies-${{ hashFiles('yarn.lock') }}
# env:
# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NODE_ENV: production
# # TODO: load these from a file.
# REACT_APP_API_BASE_URL: 'http://localhost:8000/api/'
# REACT_APP_PORTAL_BASE_URL: 'http://localhost:8000'
# - name: π Report test info
# working-directory: frontend
# run: npx cypress info
# - name: π Report CPU info
# working-directory: frontend
# run: node -p 'os.cpus()'
# - name: β
Upload coverage to Codecov
# uses: codecov/[email protected]
# build-and-deploy:
# runs-on: ubuntu-latest
# needs: [test-chrome]
# if: github.ref_name == 'production' || github.ref_name == 'development' || github.ref_name == 'staging'
# environment: ${{ github.ref_name }}
# steps:
# - name: π« Checkout
# uses: actions/checkout@v3
# - name: π Set up Node
# uses: actions/setup-node@v3
# with:
# node-version: 18
# - name: π Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ env.PYTHON_VERSION }}
# - name: π Authenticate with GCloud
# uses: google-github-actions/auth@v1
# with:
# credentials_json: ${{ secrets.GCP_CREDENTIALS }}
# - name: π€ Set up GCloud SDK
# uses: google-github-actions/setup-gcloud@v1
# - name: π Install Frontend Dependencies
# working-directory: ./frontend
# run: yarn install
# # TODO: fix dependencies and uncomment below lines
# # env:
# # NODE_ENV: production
# - name: π Build Frontend
# working-directory: ./frontend
# run: yarn run build
# env:
# NODE_ENV: production
# - name: π Bundle Frontend
# working-directory: ./frontend
# run: node djangoBundler.js
# env:
# NODE_ENV: production
# REACT_APP_API_BASE_URL: ${{ vars.REACT_APP_API_BASE_URL }}
# REACT_APP_PORTAL_BASE_URL: ${{ vars.REACT_APP_PORTAL_BASE_URL }}
# REACT_APP_SSO_SERVICE_NAME: ${{ vars.REACT_APP_SSO_SERVICE_NAME }}
# REACT_APP_SSO_SERVICE_PROTOCOL: 'https'
# REACT_APP_SSO_SERVICE_DOMAIN: 'codeforlife.education'
# REACT_APP_SSO_SERVICE_PORT: '443'
# - name: π Install Backend Dependencies
# working-directory: ./backend
# run: |
# python -m pip install --upgrade pip
# python -m pip install pipenv
# pipenv install
# - name: π Check Migrations
# working-directory: ./backend
# run: pipenv run python ./manage.py makemigrations --check --dry-run
# - name: π Generate requirements.txt
# working-directory: ./backend
# run: pipenv requirements > requirements.txt
# - name: π Collect Static Files
# working-directory: ./backend
# run: pipenv run python ./manage.py collectstatic --noinput --clear
# # https://mikefarah.gitbook.io/yq/
# - name: ποΈ Configure App Deployment
# uses: mikefarah/yq@master
# with:
# cmd: |
# SERVICE_NAME=$(
# if [ ${{ github.ref_name }} == "production" ]
# then echo ${{ env.SERVICE_NAME }}
# else echo ${{ github.ref_name }}-${{ env.SERVICE_NAME }}
# fi
# )
# SERVICE_IS_ROOT=$(
# if [ ${{ github.ref_name }} == "production" ]
# then echo "1"
# else echo "0"
# fi
# )
# yq -i '
# .service = "${{ github.ref_name }}-${{ env.SERVICE }}" |
# .env_variables.SECRET_KEY = "${{ vars.SECRET_KEY }}" |
# .env_variables.SERVICE_NAME = "$SERVICE_NAME" |
# .env_variables.SERVICE_IS_ROOT = "$SERVICE_IS_ROOT" |
# .env_variables.MODULE_NAME = "${{ github.ref_name }}"
# ' backend/app.yaml
# - name: π Deploy App on GCloud
# working-directory: ./backend
# run: gcloud app deploy