forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (130 loc) · 5.02 KB
/
cypress.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
name: Cypress
on:
push:
branches:
- "develop"
- "feature/**"
pull_request:
types: [opened, synchronize, reopened]
# Allows workflow to be called from other workflows
workflow_call:
inputs:
ref:
required: true
type: string
# Avoid duplicate workflows on same branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-cypress
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest-8-cores
defaults:
run:
shell: bash --login -eo pipefail {0}
strategy:
fail-fast: false
matrix:
# In case of number of workers would change, update TOTAL_WORKERS env variable in "Cypress Tests" step.
# Be aware that specs should be sequential integers starting from 1 without gaps
# based on logic in "Cypress Tests" step.
# prettier-ignore
specs: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 ]
steps:
- name: Checkout Streamlit code
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
persist-credentials: false
submodules: "recursive"
fetch-depth: 2
- name: Set Python version vars
uses: ./.github/actions/build_info
- name: Set up Python ${{ env.PYTHON_MAX_VERSION }}
uses: actions/setup-python@v4
with:
python-version: "${{ env.PYTHON_MAX_VERSION }}"
- name: Setup virtual env
uses: ./.github/actions/make_init
- name: Install Cypress dependencies
run: |
sudo apt install -y xvfb libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 curl
- name: Run make develop
run: make develop
- name: Run make protobuf
run: make protobuf
- name: Run make frontend-lib
run: make frontend-lib
- name: Register Streamlit User & Mapbox Token
run: |
if [ ! -d $HOME/.streamlit ] ; then
mkdir $HOME/.streamlit
fi
echo '[mapbox]' > ~/.streamlit/config.toml
MAPBOX_TOKEN=$(curl -sS https://data.streamlit.io/tokens.json | jq -r '.["mapbox-localhost"]') \
&& echo 'token = "'$MAPBOX_TOKEN'"' >> ~/.streamlit/config.toml
echo '[general]' > ~/.streamlit/credentials.toml
echo 'email = "[email protected]"' >> ~/.streamlit/credentials.toml
- name: Cypress Tests
env:
CURRENT_RUN: ${{matrix.specs}}
CYPRESS_VERIFY_TIMEOUT: 90000
TOTAL_WORKERS: 22
run: |
js_specs=(e2e/specs/*)
# get how many specs to be split up into $TOTAL_WORKERS runs
totalTests=$(( ${#js_specs[@]} ))
testsPerWorker=$(( totalTests / TOTAL_WORKERS ))
# get the remainder of tests to be split up into the first $remainder workers
remainder=$(( totalTests % TOTAL_WORKERS ))
# We handle $CURRENT_RUN = 1 separately because bash interprets 0 as empty string in this case
if [ "$CURRENT_RUN" -eq 1 ]; then
startIndex=0
currentIntervalLength=$(( testsPerWorker + (remainder > 0 ? 1 : 0) ))
elif [ $CURRENT_RUN -le $remainder ]; then
startIndex=$(( (CURRENT_RUN - 1) * (testsPerWorker + 1) ))
currentIntervalLength=$(( testsPerWorker + 1 ))
else
startIndex=$(( remainder * (testsPerWorker + 1) + (CURRENT_RUN - remainder - 1) * testsPerWorker ))
currentIntervalLength=$(( testsPerWorker ))
fi
# ensure no blank specs list (which causes every spec to run)
if [[ "${js_specs[@]:${startIndex}:${currentIntervalLength}}" != "" ]]; then
echo "Specs tested in this job:"
echo "${js_specs[@]:${startIndex}:${currentIntervalLength}}"
scripts/run_e2e_tests.py -a "${js_specs[@]:${startIndex}:${currentIntervalLength}}"
fi
- name: Check that all screenshot have been committed
run: |
set -x;
UNTRACKED_FILE_COUNT=$(git ls-files --others --exclude-standard | grep cypress | wc -l | bc -l || echo '0')
echo "Untracked files count: ${UNTRACKED_FILE_COUNT}"
if [[ "${UNTRACKED_FILE_COUNT}" -gt 0 ]]; then
echo "Untracked files:";
git ls-files --others --exclude-standard | grep cypress;
exit 1;
fi
- name: Store Videos
uses: actions/upload-artifact@v3
if: always()
with:
name: cypress_videos
path: frontend/cypress/videos
- name: Store Snapshots
uses: actions/upload-artifact@v3
if: always()
with:
name: cypress_snapshots
path: frontend/cypress/snapshots
cypress_summary:
runs-on: ubuntu-latest
# Consolidates cypress test matrix results for a single pass/fail status check
if: ${{ always() }}
needs: test
defaults:
run:
shell: bash --login -eo pipefail {0}
steps:
- name: Check Cypress test matrix status
if: ${{ needs.test.result == 'failure' }}
run: exit 1