-
Notifications
You must be signed in to change notification settings - Fork 31
109 lines (91 loc) · 3.62 KB
/
website-tests-changes.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
name: website-code-tests
on:
pull_request:
branches:
- main
- staging
- master
jobs:
check:
name: check for changes in Website
outputs:
run_website_tests: ${{ steps.check_files.outputs.run_website_tests }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: check modified website folder
id: check_files
run: |
echo "=============== list modified files ==============="
git diff --name-only HEAD^ HEAD
echo "========== check paths of modified files =========="
git diff --name-only HEAD^ HEAD > files.txt
echo "run_website_tests=false" >>$GITHUB_OUTPUT
while IFS= read -r file
do
echo $file
if [[ $file == website/* ]]; then
echo "run_website_tests=true" >>$GITHUB_OUTPUT
fi
done < files.txt
drive:
name: website code tests
needs: [check]
if: needs.check.outputs.run_website_tests == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: website
steps:
- name: Checkout
uses: actions/checkout@v3.5.2
- name: Google login
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.GCP_FRONTEND_PROJECT_SA_CREDENTIALS }}"
- name: Setup Cloud SDK(gcloud)
uses: "google-github-actions/setup-gcloud@v1"
- name: Create google_application_credentials.json file
id: create-google-application-credentials-file
uses: jsdaniell/create-json@1.1.2
with:
name: "google_application_credentials.json"
json: ${{ secrets.GCP_FRONTEND_PROJECT_SA_CREDENTIALS }}
dir: "website/"
- name: Create app.yaml and .env.yaml files
run: |
echo "========== Creating app.yaml file =========="
echo "runtime: python" > app.yaml
echo "env: flex" >> app.yaml
echo "service: staging" >> app.yaml
echo "includes:" >> app.yaml
echo " - .env.yaml" >> app.yaml
echo "========== Creating .env.yaml file =========="
echo "env_variables:" > .env.yaml
echo " SECRET: ${{ secrets.WEBSITE_SECRET }}" >> .env.yaml
echo " CLOUDINARY_KEY: ${{ secrets.WEBSITE_CLOUDINARY_KEY }}" >> .env.yaml
echo " CLOUDINARY_NAME: ${{ secrets.WEBSITE_CLOUDINARY_NAME }}" >> .env.yaml
echo " CLOUDINARY_SECRET: ${{ secrets.WEBSITE_CLOUDINARY_SECRET }}" >> .env.yaml
echo " DATABASE_URI: ${{ secrets.WEBSITE_STAGE_DATABASE_URI }}" >> .env.yaml
echo " GS_BUCKET_NAME: ${{ secrets.WEBSITE_STAGE_GS_BUCKET_NAME }}" >> .env.yaml
echo " REACT_WEB_STATIC_HOST: ${{ secrets.WEBSITE_STAGE_REACT_WEB_STATIC_HOST }}" >> .env.yaml
echo " SECRET_KEY: ${{ secrets.WEBSITE_STAGE_SECRET_KEY }}" >> .env.yaml
echo " DJANGO_ALLOWED_HOSTS: ${{ secrets.WEBSITE_DJANGO_ALLOWED_HOSTS }}" >> .env.yaml
echo " DEBUG: False" >> .env.yaml
echo " GOOGLE_APPLICATION_CREDENTIALS: /app/google_application_credentials.json" >> .env.yaml
- name: Node setup
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install requirements
run: npm install
- name: Run tests and collect coverage
run: npm test -- --coverage
continue-on-error: true
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}