|
1 | | -# It runs all available Cypress tests and sends test data to Cypress Dashboard. |
2 | | -# It executes on every Monday at 01 a.m, and on demand by the user. |
3 | | -# The tests run with a fail-fast strategy, once one fails, the others will not run. |
4 | | -# If a test fails, it creates a set of screenshots showing the errors. |
5 | | -# |
6 | | -# Matrix: |
7 | | -# - Browser: chrome. |
8 | | -# - Test folder: All tests available on the `/tests` folder. |
9 | | -# |
10 | | -# Jobs: |
11 | | -# - Set up the Cypress Environment: `setup-cypress`. |
12 | | -# - Runs all tests on the matrix: `run-all-tests-matrix`. |
13 | | - |
14 | | -name: Run Cypress tests with npm packages |
15 | | - |
16 | | -on: |
17 | | - schedule: |
18 | | - # runs every Monday at 1 a.m |
19 | | - - cron: "0 1 * * 1" |
20 | | - filters: |
21 | | - branches: |
22 | | - only: |
23 | | - - stable |
24 | | - workflow_dispatch: |
25 | | - inputs: |
26 | | - # Sends data to Cy |
27 | | - cypress-record: |
28 | | - description: Send test data to Cypress Dashboard? Write 'Yes' to send data. |
29 | | - required: true |
30 | | - default: "No" |
31 | | - |
32 | | -jobs: |
33 | | - setup-cypress: |
34 | | - # Setup Cypress environment without cache. |
35 | | - name: Setup Cypress environment without cache |
36 | | - runs-on: ubuntu-latest |
37 | | - steps: |
38 | | - # 01. Checkout the repository. |
39 | | - - name: Checkout |
40 | | - uses: actions/checkout@v2 |
41 | | - |
42 | | - # 02. Install a specific version of Node using. |
43 | | - - name: Use Node.js |
44 | | - uses: actions/setup-node@v2 |
45 | | - with: |
46 | | - node-version: 16 |
47 | | - |
48 | | - # 03. Install dependencies and verify Cypress |
49 | | - - name: Install dependencies and verify Cypress |
50 | | - env: |
51 | | - # make sure every Cypress install prints minimal information |
52 | | - CI: 1 |
53 | | - # print Cypress and OS info |
54 | | - # This next command should use "npm ci" instead of "npm install" |
55 | | - run: | |
56 | | - npm ci |
57 | | - npx cypress verify |
58 | | - npx cypress info |
59 | | - npx cypress version |
60 | | - npx cypress version --component package |
61 | | - npx cypress version --component binary |
62 | | - npx cypress version --component electron |
63 | | - npx cypress version --component node |
64 | | -
|
65 | | - run-all-tests-matrix: |
66 | | - # Runs all tests. |
67 | | - runs-on: ubuntu-latest |
68 | | - needs: setup-cypress |
69 | | - strategy: |
70 | | - fail-fast: true |
71 | | - matrix: |
72 | | - # Define values for browsers from |
73 | | - browser: ["chrome"] |
74 | | - # browser: ['chrome', 'edge', 'firefox', 'chromium'] |
75 | | - type: ["all"] |
76 | | - # type: ['smoke','e2e', 'ui', 'validation'] |
77 | | - # env: ['local', 'public'] |
78 | | - name: Run ${{ matrix.type }} tests on ${{ matrix.browser }} |
79 | | - steps: |
80 | | - # 01. Checkout the repository. |
81 | | - - name: Checkout |
82 | | - uses: actions/checkout@v2 |
83 | | - |
84 | | - # 02. Install a specific version of Node. |
85 | | - - name: Use Node.js |
86 | | - uses: actions/setup-node@v2 |
87 | | - with: |
88 | | - node-version: 16 |
89 | | - |
90 | | - # 03a. Decide whether to send data to Cypress Dashboard, or not, for workflow_dispatch and schedule. |
91 | | - - name: Decide if we send data to Cypress 2 |
92 | | - if: ${{ github.event.inputs.cypress-record == 'Yes' || github.event_name == 'schedule' }} |
93 | | - run: | |
94 | | - echo "CY_RECORD_KEY=${{ secrets.CYPRESS_RECORD_KEY }}" >> $GITHUB_ENV |
95 | | - echo "CY_RECORD_FLAG=-- --record --key " >> $GITHUB_ENV |
96 | | -
|
97 | | - # 03a. Decide whether to send data to Cypress Dashboard, or not, for workflow_dispatch. |
98 | | - - name: Decide if we send data to Cypress 1 |
99 | | - # We don't want to send the tests to Dashboard through workflow dispatch |
100 | | - if: ${{ github.event.inputs.cypress-record != 'Yes' }} |
101 | | - # we set the environment variables dynamically to empty in order to avoid |
102 | | - # recording the test execution to Cypress Dashboard. |
103 | | - run: | |
104 | | - echo "CY_RECORD_KEY=" >> $GITHUB_ENV |
105 | | - echo "CY_RECORD_FLAG=" >> $GITHUB_ENV |
106 | | -
|
107 | | - # 04. Run the tests following the initial matrix: by browser and test type |
108 | | - - name: Run tests by browser |
109 | | - uses: cypress-io/github-action@v2 |
110 | | - timeout-minutes: 10 |
111 | | - with: |
112 | | - # 'build' starts the default demo |
113 | | - build: npm run build |
114 | | - # 'test:ci' runs tests over Docker image for build context |
115 | | - # we also send the Cypress Dashboard record key dynamically |
116 | | - command: npm run test:ci ${{ env.CY_RECORD_FLAG }} ${{ env.CY_RECORD_KEY }} |
117 | | - record: true |
118 | | - parallel: true |
119 | | - group: "${{ matrix.type }} tests on ${{ matrix.browser }}" |
120 | | - browser: ${{ matrix.browser }} |
121 | | - config: "video: true" |
122 | | - spec: | |
123 | | - cypress/tests/**/*.js |
124 | | - env: |
125 | | - # https://github.com/wiris/html-integrations/settings/secrets/actions |
126 | | - CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} |
127 | | - GITHUB_TOKEN: ${{ secrets.GH_CICD_TOKEN }} |
128 | | - |
129 | | - # 05a. Save videos and screenshots as test artifacts |
130 | | - # https://github.com/actions/upload-artifact |
131 | | - - name: Upload screenshots |
132 | | - uses: actions/upload-artifact@master |
133 | | - # there might be no screenshots created when: |
134 | | - # - there are no test failures |
135 | | - # so only upload screenshots if previous step has failed |
136 | | - if: failure() |
137 | | - with: |
138 | | - name: screenshots-${{ matrix.type }}-${{ matrix.browser }} |
139 | | - path: cypress/screenshots |
140 | | - |
141 | | - # 05b. Upload videos, since they are always be generated. |
142 | | - - name: Upload videos for all tests |
143 | | - uses: actions/upload-artifact@master |
144 | | - with: |
145 | | - name: videos-${{ matrix.type }}-${{ matrix.browser }} |
146 | | - path: cypress/videos |
0 commit comments