-
Notifications
You must be signed in to change notification settings - Fork 31
116 lines (99 loc) · 3.34 KB
/
test-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
110
111
112
113
114
115
116
name: test-changes
on:
pull_request:
branches:
- staging
jobs:
check:
name: check for changed frontends
outputs:
run_analytics_platform: ${{ steps.check_files.outputs.run_analytics_platform }} # analytics platform
run_docs: ${{ steps.check_files.outputs.run_docs }} # docs
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: check modified frontends
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_analytics_platform=false" >>$GITHUB_OUTPUT
echo "run_docs=false" >>$GITHUB_OUTPUT
while IFS= read -r file
do
if [[ $file == platform/* ]]; then
echo "run_analytics_platform=true" >>$GITHUB_OUTPUT
fi
if [[ $file == docs/* ]]; then
echo "run_docs=true" >>$GITHUB_OUTPUT
fi
done < files.txt
### test analytics platform changes ###
analytics-platform:
name: test-analytics-platform-changes
needs: [check]
if: needs.check.outputs.run_analytics_platform == 'true'
runs-on: ubuntu-latest
container: cypress/browsers:node16.14.0-chrome99-ff97
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Google login
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SA_CREDENTIALS }}
- name: Setup Cloud SDK(gcloud)
uses: google-github-actions/setup-gcloud@v1
- name: Create .env file
run: |
gcloud secrets versions access latest --secret="sta-env-next-platform" > platform/.env
echo "INSTRUMENT_CODE=1" >> platform/.env
- name: Cypress run
uses: cypress-io/github-action@v5
with:
working-directory: ./platform/
build: yarn build
start: yarn start
browser: chrome
record: true
env:
CYPRESS_RECORD_KEY: ${{ secrets.ANALYTICS_PLATFORM_CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: code-coverage
- name: Deploy code coverage report 🚀
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
directory: platform/coverage/
### test docs changes ###
docs:
name: test-docs-changes
needs: [check]
if: needs.check.outputs.run_docs == 'true'
runs-on: ubuntu-latest
container: cypress/browsers:node16.14.0-chrome99-ff97
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress run
uses: cypress-io/github-action@v5
with:
working-directory: ./docs/
start: yarn preview
wait-on: http://localhost:3000
browser: chrome
record: true
env:
CYPRESS_RECORD_KEY: ${{ secrets.DOCS_CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: code-coverage
- name: Deploy code coverage report 🚀
uses: codecov/codecov-action@v3
with:
directory: ./docs/coverage/lcov-report