Skip to content

Commit

Permalink
[2.x]Manually backport to 2.x from main (opensearch-project#180)
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 10, 2023
1 parent 7b80c07 commit 0cf87c8
Show file tree
Hide file tree
Showing 117 changed files with 6,842 additions and 614 deletions.
57 changes: 27 additions & 30 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: '2.5'
GEOSPATIAL_PLUGIN_BRANCH: '2.5'
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,44 +100,44 @@ 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
yarn start --no-base-path --no-watch &
shell: bash

# Window is slow so wait longer
- name: Sleep until OSD server starts - windows
if: ${{ matrix.os == 'windows-latest' }}
# Window is slow so wait longer
run: Start-Sleep -s 400
shell: powershell

- 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.0'
OPENSEARCH_DASHBOARDS_BRANCH: '2.5'
jobs:
tests:
strategy:
Expand All @@ -27,26 +22,27 @@ 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
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 @@ -58,17 +54,16 @@ jobs:
npm uninstall -g yarn
echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}"
npm i -g yarn@${{ steps.versions_step.outputs.yarn_version }}
- name: Move plugin to OpenSearch-Dashboard Plugins Directory
run: mv dashboards-maps OpenSearch-Dashboards/plugins/dashboards-maps

- name: Move custom_import_map to Plugins Dir
run: mv custom_import_map OpenSearch-Dashboards/plugins/custom_import_map

- 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
uses: codecov/codecov-action@v1
7 changes: 3 additions & 4 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,20 @@ echo 'src/plugins/custom_import_map/*' >> .git/info/sparse-checkout
git config core.sparseCheckout true
git checkout main
```
6. Retain only `custom_import_map` directory within plugins and remove `src/plugins` from the path.
6. Run `yarn osd bootstrap` inside `OpenSearch-Dashboards/plugins/custom_import_map`.
6. Run `yarn osd bootstrap` inside `OpenSearch-Dashboards/plugins/src/plugins/custom_import_map`.

Ultimately, your directory structure should look like this:

```md
.
├── OpenSearch-Dashboards
│ └── plugins
│ └── custom_import_map
│ └── src/plugins/custom_import_map
```

### Run

From OpenSearch-Dashboards repo (root folder), run the following command -
From OpenSearch-Dashbaords repo (root folder), run the following command -
- `yarn start`

Starts OpenSearch Dashboards and includes this plugin. OpenSearch Dashboards will be available on `localhost:5601`.
Expand Down
Loading

0 comments on commit 0cf87c8

Please sign in to comment.