Skip to content

Commit

Permalink
Update CI workflow (#174)
Browse files Browse the repository at this point in the history
Signed-off-by: Junqiu Lei <[email protected]>
  • Loading branch information
junqiu-lei authored Jan 9, 2023
1 parent 5cf86b5 commit b75cf16
Show file tree
Hide file tree
Showing 17 changed files with 538 additions and 95 deletions.
55 changes: 26 additions & 29 deletions .github/workflows/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ on:
branches:
- main
- 2.*
- feature/**
push:
branches:
- main
- 2.*
env:
OPENSEARCH_DASHBOARDS_VERSION: '2.4'
OPENSEARCH_VERSION: '2.4.0-SNAPSHOT'
OPENSEARCH_DASHBOARDS_BRANCH: 'main'
GEOSPATIAL_PLUGIN_BRANCH: 'main'
jobs:
tests:
env:
Expand All @@ -23,16 +24,15 @@ jobs:
# This setting says that all jobs should finish, even if one fails
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
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
- os: macos-latest
cypress_cache_folder: ~/Library/Caches/Cypress

name: Test and Build Dashboards Maps on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -48,43 +48,40 @@ jobs:
run: subst 'X:' .

- name: Checkout geospatial plugin
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: geospatial
repository: opensearch-project/geospatial
ref: '2.4'
ref: ${{ env.GEOSPATIAL_PLUGIN_BRANCH }}

- name: Run Opensearch with plugin
working-directory: ${{ env.WORKING_DIR }}
run: |
# Install coreutils for macOS since timeout doesn't seem to available on that OS even when forcing bash shell
if [ "$RUNNER_OS" == "macOS" ]; then
brew install coreutils
fi
cd geospatial
./gradlew run &
timeout 600 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9200)" != "200" ]]; do sleep 5; done'
shell: bash
env:
_JAVA_OPTIONS: ${{ matrix.os_java_options }}

- name: Checkout Plugin
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: dashboards-maps

- name: Checkout OpenSearch Dashboards
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: opensearch-project/OpenSearch-Dashboards
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
ref: ${{ env.OPENSEARCH_DASHBOARDS_BRANCH }}
path: OpenSearch-Dashboards

- name: Get node and yarn versions
id: versions_step
run: |
echo "::set-output name=node_version::$(node -p "(require('./OpenSearch-Dashboards/package.json').engines.node).match(/[.0-9]+/)[0]")"
echo "::set-output name=yarn_version::$(node -p "(require('./OpenSearch-Dashboards/package.json').engines.yarn).match(/[.0-9]+/)[0]")"
- name: Setup node
uses: actions/setup-node@v1
with:
Expand All @@ -103,15 +100,15 @@ jobs:
# 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 custom_import_map to Plugins Dir
- name: Move plugin to OpenSearch-Dashboards Plugins Directory
run: |
mv dashboards-maps/custom_import_map OpenSearch-Dashboards/plugins/custom_import_map
- name: Bootstrap plugin/opensearch-dashboards
mv dashboards-maps OpenSearch-Dashboards/plugins/dashboards-maps
- name: Bootstrap plugin
run: |
cd OpenSearch-Dashboards/plugins/custom_import_map
cd OpenSearch-Dashboards/plugins/dashboards-maps
yarn osd bootstrap
- name: Run OpenSearch Dashboards server
run: |
cd OpenSearch-Dashboards
Expand All @@ -126,21 +123,21 @@ jobs:

- name: Sleep until OSD server starts - non-windows
if: ${{ matrix.os != 'windows-latest' }}
run: sleep 300
run: sleep 400
shell: bash

- name: Install Cypress
run: |
cd OpenSearch-Dashboards/plugins/custom_import_map
# This will install Cypress in case the binary is missing which can happen on Windows and Mac
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/custom_import_map
cd OpenSearch-Dashboards/plugins/dashboards-maps
echo "::set-output name=cypress_version::$(cat ./package.json | jq '.dependencies.cypress' | tr -d '"')"
- name: Cache Cypress
Expand All @@ -157,9 +154,9 @@ jobs:
npm config delete script-shell
- name: Run Cypress tests
uses: cypress-io/github-action@v2
uses: cypress-io/github-action@v5
with:
working-directory: OpenSearch-Dashboards/plugins/custom_import_map
working-directory: OpenSearch-Dashboards/plugins/dashboards-maps
command: yarn run cypress run --browser chrome
wait-on: 'http://localhost:5601'
env:
Expand All @@ -170,11 +167,11 @@ jobs:
if: failure()
with:
name: cypress-screenshots-${{ matrix.os }}
path: OpenSearch-Dashboards/plugins/custom_import_map/cypress/screenshots
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/custom_import_map/cypress/videos
path: OpenSearch-Dashboards/plugins/dashboards-maps/cypress/videos
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@ name: Unit tests workflow
on:
push:
branches:
- "*"
- "feature/**"
paths:
- src/plugins/custom_import_map/**
- .github/workflows/unit-tests-workflow-for-customImportMap.yml
- main
- 2.*
pull_request:
branches:
- "*"
- "feature/**"
paths:
- src/plugins/custom_import_map/**
- .github/workflows/unit-tests-workflow-for-customImportMap.yml
- main
- 2.*
- feature/**

env:
OPENSEARCH_DASHBOARDS_VERSION: '2.4'
OPENSEARCH_DASHBOARDS_BRANCH: 'main'
jobs:
tests:
strategy:
Expand All @@ -27,18 +22,20 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Plugin
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: dashboards-maps

# Enable longer filenames for windows
- name: Enable longer filenames
if: ${{ matrix.os == 'windows-latest' }}
run: git config --system core.longpaths true

- name: Checkout OpenSearch Dashboards
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: opensearch-project/OpenSearch-Dashboards
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
ref: ${{ env.OPENSEARCH_DASHBOARDS_BRANCH }}
path: OpenSearch-Dashboards

- name: Get node and yarn versions
Expand All @@ -59,17 +56,17 @@ jobs:
echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}"
npm i -g yarn@${{ steps.versions_step.outputs.yarn_version }}
- name: Move custom_import_map to Plugins Dir
run: mv custom_import_map OpenSearch-Dashboards/plugins/custom_import_map
- name: Move plugin to OpenSearch-Dashboard Plugins Directory
run: mv dashboards-maps OpenSearch-Dashboards/plugins/dashboards-maps

- name: Bootstrap plugin/opensearch-dashboards
- name: Bootstrap plugin
run: |
cd OpenSearch-Dashboards/plugins/custom_import_map
cd OpenSearch-Dashboards/plugins/dashboards-maps
yarn osd bootstrap
- name: Run tests with coverage
run: |
cd OpenSearch-Dashboards/plugins/custom_import_map
cd OpenSearch-Dashboards/plugins/dashboards-maps
yarn run test:jest --coverage
- name: Uploads coverage
Expand Down
56 changes: 56 additions & 0 deletions cypress/integration/documentsLayer.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { BASE_PATH } from '../utils/constants';

describe('Documents layer', () => {
before(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, {
retryOnStatusCodeFailure: true,
timeout: 60000,
});
cy.get('div[data-test-subj="sampleDataSetCardflights"]', { timeout: 60000 })
.contains(/(Add|View) data/)
.click();
cy.wait(60000);
});

const uniqueName = 'saved-map-' + Date.now().toString();

it('Add new documents layer with configuration', () => {
cy.visit(`${BASE_PATH}/app/maps-dashboards`);
cy.contains('Create map').click();
cy.get("button[data-test-subj='addLayerButton']").click();
cy.contains('Documents').click();
cy.contains('Select data source', { timeout: 60000 }).click({ force: true });
cy.contains('opensearch_dashboards_sample_data_flights').click();
cy.contains('Select data field', { timeout: 60000 }).click({ force: true });
cy.contains('DestLocation').click();
cy.get('[data-test-subj="indexPatternSelect"]').should(
'contain',
'opensearch_dashboards_sample_data_flights'
);
cy.get('[data-test-subj="geoFieldSelect"]').should('contain', 'DestLocation');
cy.get(`button[testSubj="styleTab"]`).click();
cy.contains('Fill color').click();
cy.get(`button[aria-label="Select #E7664C as the color"]`).click();
cy.contains('Border color').click();
cy.get(`button[aria-label="Select #DA8B45 as the color"]`).click();
cy.get(`button[testSubj="settingsTab"]`).click();
cy.get('[name="layerName"]').clear().type('Documents layer 1');
cy.get(`button[data-test-subj="updateButton"]`).click();
cy.get('[data-test-subj="layerControlPanel"]').should('contain', 'Documents layer 1');
cy.wait(5000).get('[data-test-subj="top-nav"]').click();
cy.wait(5000).get('[data-test-subj="savedObjectTitle"]').type(uniqueName);
cy.wait(5000).get('[data-test-subj="confirmSaveSavedObjectButton"]').click();
});

it('Open saved map with documents layer', () => {
cy.visit(`${BASE_PATH}/app/maps-dashboards`);
cy.get('[data-test-subj="mapListingPage"]').should('contain', uniqueName);
cy.contains(uniqueName).click();
cy.get('[data-test-subj="layerControlPanel"]').should('contain', 'Documents layer 1');
});
});
25 changes: 13 additions & 12 deletions cypress/integration/geojson_file_upload.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ import 'cypress-file-upload';

describe('Verify successful custom geojson file upload', () => {
before(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`);
// Click on "Sample data" tab
cy.contains('Sample data').click({ force: true });
// Load sample flights data
cy.get(`button[data-test-subj="addSampleDataSetflights"]`).click({
force: true,
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, {
retryOnStatusCodeFailure: true,
timeout: 60000,
});

// Verify that sample data is add by checking toast notification
cy.contains('Sample flight data installed', { timeout: 240000 });
cy.get('div[data-test-subj="sampleDataSetCardflights"]', { timeout: 60000 })
.contains(/(Add|View) data/)
.click();
cy.wait(60000);

cy.visit(`${BASE_PATH}/app/visualize#/`);

Expand All @@ -40,11 +38,14 @@ describe('Verify successful custom geojson file upload', () => {
cy.get('[data-testId="filePicker"]').attachFile('sample_geojson.json');
cy.get('[data-testId="customIndex"]').type('sample');
cy.contains('Import file').click({ force: true });
cy.contains('Successfully added 2 features to sample-map. Refresh to visualize the uploaded map.', { timeout: 240000 });
})
cy.contains(
'Successfully added 2 features to sample-map. Refresh to visualize the uploaded map.',
{ timeout: 240000 }
);
});

after(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`);
cy.get('button[data-test-subj="removeSampleDataSetflights"]').should('be.visible').click();
})
});
});
20 changes: 9 additions & 11 deletions cypress/integration/import_vector_map_tab.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ import { BASE_PATH } from '../utils/constants';

describe('Verify the presence of import custom map tab in region map plugin', () => {
before(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`);
// Click on "Sample data" tab
cy.contains('Sample data').click({ force: true });
// Load sample flights data
cy.get(`button[data-test-subj="addSampleDataSetflights"]`).click({
force: true,
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, {
retryOnStatusCodeFailure: true,
timeout: 60000,
});

// Verify that sample data is add by checking toast notification
cy.contains('Sample flight data installed', { timeout: 240000 });
cy.get('div[data-test-subj="sampleDataSetCardflights"]', { timeout: 60000 })
.contains(/(Add|View) data/)
.click();
cy.wait(60000);

cy.visit(`${BASE_PATH}/app/visualize#/`);

Expand All @@ -35,10 +33,10 @@ describe('Verify the presence of import custom map tab in region map plugin', ()
it('checks import custom map tab is present', () => {
// Click on "Import Vector Map" tab, which is part of customImportMap plugin
cy.contains('Import Vector Map').click({ force: true });
})
});

after(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`);
cy.get('button[data-test-subj="removeSampleDataSetflights"]').should('be.visible').click();
})
});
});
Loading

0 comments on commit b75cf16

Please sign in to comment.