Skip to content

Fix CI failure on maps-dashboards #67

Fix CI failure on maps-dashboards

Fix CI failure on maps-dashboards #67

name: E2E Cypress tests
on:
pull_request:
branches:
- main
- 2.*
- feature/**
push:
branches:
- main
- 2.*
env:
OPENSEARCH_DASHBOARDS_BRANCH: 'main'
OPENSEARCH_VERSION: '3.0.0-SNAPSHOT'
GEOSPATIAL_PLUGIN_BRANCH: 'main'
jobs:
tests:
env:
# prevents extra Cypress installation progress messages
CI: 1
# avoid warnings like "tput: No value for $TERM and no -T specified"
TERM: xterm
WORKING_DIR: ${{ matrix.working_directory }}.
strategy:
# This setting says that all jobs should finish, even if one fails
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]
include:
- os: windows-latest
working_directory: X:\
os_java_options: -Xmx4068M
cypress_cache_folder: ~/AppData/Local/Cypress/Cache
- os: ubuntu-latest
cypress_cache_folder: ~/.cache/Cypress
name: Test and Build Dashboards Maps on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
# This is a hack, but this step creates a link to the X: mounted drive, which makes the path
# short enough to work on Windows
- name: Shorten Path
if: ${{ matrix.os == 'windows-latest' }}
run: subst 'X:' .
- name: Checkout geospatial plugin
uses: actions/checkout@v3
with:
path: geospatial
repository: opensearch-project/geospatial
ref: ${{ env.GEOSPATIAL_PLUGIN_BRANCH }}
- name: Run Opensearch with plugin
working-directory: ${{ env.WORKING_DIR }}
run: |
cd geospatial
./gradlew run -Dopensearch.version=${{ env.OPENSEARCH_VERSION }} &
sleep 300
shell: bash
env:
_JAVA_OPTIONS: ${{ matrix.os_java_options }}
- name: Checkout Plugin
uses: actions/checkout@v3
with:
path: dashboards-maps
- name: Checkout OpenSearch Dashboards
uses: actions/checkout@v3
with:
repository: opensearch-project/OpenSearch-Dashboards
ref: ${{ env.OPENSEARCH_DASHBOARDS_BRANCH }}
path: OpenSearch-Dashboards
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: './OpenSearch-Dashboards/.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Install Yarn
# Need to use bash to avoid having a windows/linux specific step
shell: bash
run: |
YARN_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').engines.yarn")
echo "Installing yarn@$YARN_VERSION"
npm i -g yarn@$YARN_VERSION
- run: node -v
- run: yarn -v
- name: Set npm to use bash for shell
if: ${{ matrix.os == 'windows-latest' }}
run: |
# Sets Windows to use bash for npm shell so the script commands work as intended
npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
- name: Move plugin to OpenSearch-Dashboards Plugins Directory
run: |
mv dashboards-maps OpenSearch-Dashboards/plugins/dashboards-maps
- name: Bootstrap plugin
run: |
cd OpenSearch-Dashboards/plugins/dashboards-maps
yarn osd bootstrap
- name: Run OpenSearch Dashboards server
run: |
cd OpenSearch-Dashboards
yarn start --no-base-path --no-watch --server.host="0.0.0.0" &
shell: bash
- name: Sleep until OSD server starts - windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
$timeout = New-TimeSpan -Seconds 420
$sw = [System.Diagnostics.Stopwatch]::StartNew()
while ($sw.Elapsed -lt $timeout) {
try {
$response = Invoke-WebRequest -Uri "http://localhost:5601/api/status" -UseBasicParsing
$status = ($response.Content | ConvertFrom-Json).status.overall.state
if ($status -eq "green") {
Write-Host "OpenSearch Dashboards server is in 'green' state."
break
}
} catch {
Write-Error "Error encountered: $_"
}
Start-Sleep -Seconds 5
}
shell: powershell
- name: Sleep until OSD server starts - non-windows
if: ${{ matrix.os != 'windows-latest' }}
run: timeout 420 bash -c 'while [[ "$(curl -s localhost:5601/api/status | jq -r \".status.overall.state\")" != "green" ]]; do sleep 5; done'
shell: bash
- name: Install Cypress
run: |
cd OpenSearch-Dashboards/plugins/dashboards-maps
# This will install Cypress in case the binary is missing which can happen on Windows
# If the binary exists, this will exit quickly so it should not be an expensive operation
npx cypress install
shell: bash
- name: Get Cypress version
id: cypress_version
run: |
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: Reset npm's script shell
if: ${{ matrix.os == 'windows-latest' }}
run: |
# Resetting npm's script shell for Windows so `yarn run cypress` doesn't have conflicts
npm config delete script-shell
- name: Run Cypress tests
uses: cypress-io/github-action@v5
with:
working-directory: OpenSearch-Dashboards/plugins/dashboards-maps
command: yarn run cypress run --browser chrome
wait-on: 'http://localhost:5601'
env:
CYPRESS_CACHE_FOLDER: ${{ matrix.cypress_cache_folder }}
# Screenshots are only captured on failure, will change this once we do visual regression tests
- uses: actions/upload-artifact@v1
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
if: always()
with:
name: cypress-videos-${{ matrix.os }}
path: OpenSearch-Dashboards/plugins/dashboards-maps/cypress/videos