Skip to content

Commit

Permalink
Fix CI failure on maps-dashboards
Browse files Browse the repository at this point in the history
Signed-off-by: Junqiu Lei <[email protected]>
  • Loading branch information
junqiu-lei committed Jan 19, 2024
1 parent 2fabf81 commit b51dec7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 16 deletions.
52 changes: 39 additions & 13 deletions .github/workflows/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ jobs:

- name: Sleep until OSD server starts - windows
if: ${{ matrix.os == 'windows-latest' }}
run: Start-Sleep -s 600
run: Start-Sleep -s 900
shell: powershell

- name: Sleep until OSD server starts - non-windows
if: ${{ matrix.os != 'windows-latest' }}
run: sleep 600
run: timeout 600 bash -c 'while [[ "$(curl http://localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done'
shell: bash

- name: Install Cypress
Expand All @@ -139,12 +139,14 @@ jobs:
cd OpenSearch-Dashboards/plugins/dashboards-maps
echo "::set-output name=cypress_version::$(cat ./package.json | jq '.dependencies.cypress' | tr -d '"')"
- name: Cache Cypress
id: cache-cypress
uses: actions/cache@v2
with:
path: ${{ matrix.cypress_cache_folder }}
key: cypress-cache-v2-${{ runner.os }}-${{ hashFiles('**/package.json') }}
# - name: Cache Cypress
# id: cache-cypress
# uses: actions/cache@v2
# with:
# path: ${{ matrix.cypress_cache_folder }}
# key: cypress-cache-v2-${{ runner.os }}-${{ hashFiles('package.json', '**/package.json') }}
# restore-keys: |
# cypress-cache-v2-${{ runner.os }}-${{ hashFiles('package.json', '**/package.json') }}

- name: Reset npm's script shell
if: ${{ matrix.os == 'windows-latest' }}
Expand All @@ -156,19 +158,43 @@ jobs:
uses: cypress-io/github-action@v5
with:
working-directory: OpenSearch-Dashboards/plugins/dashboards-maps
command: yarn run cypress run --browser electron --headless
env:
CYPRESS_CACHE_FOLDER: ${{ matrix.cypress_cache_folder }}
command: yarn run cypress run
browser: electron
# env:
# CYPRESS_CACHE_FOLDER: ${{ matrix.cypress_cache_folder }}

# - name: List directories
# run: |
# cd OpenSearch-Dashboards/plugins/dashboards-maps
# ls -la
# ls -la cypress
# ls -la cypress/screenshots
# ls -la cypress/videos

# - name: Check if the screenshot and video artifacts exist
# if: always()
# run: |
# cd OpenSearch-Dashboards/plugins/dashboards-maps
# if [ -d "cypress/screenshots" ]; then
# echo "Screenshots directory exists"
# else
# echo "Screenshots directory does not exist"
# fi
# if [ -d "cypress/videos" ]; then
# echo "Videos directory exists"
# else
# echo "Videos directory does not exist"
# fi

# Screenshots are only captured on failure, will change this once we do visual regression tests
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v4.2.0
if: failure()
with:
name: cypress-screenshots-${{ matrix.os }}
path: OpenSearch-Dashboards/plugins/dashboards-maps/cypress/screenshots

# Test run video was always captured, so this action uses "always()" condition
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v4.2.0
if: always()
with:
name: cypress-videos-${{ matrix.os }}
Expand Down
7 changes: 4 additions & 3 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { defineConfig } = require('cypress')
const { defineConfig } = require('cypress');

module.exports = defineConfig({
video: true,
defaultCommandTimeout: 120000,
env: {
opensearch_url: 'localhost:9200',
Expand All @@ -14,7 +15,7 @@ module.exports = defineConfig({
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
return require('./cypress/plugins/index.js')(on, config);
},
},
})
});

0 comments on commit b51dec7

Please sign in to comment.