Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.4] Support CI for Windows and MacOS (#1164) #1180

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/actions/install-dashboards/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: 'Install Dashboards with Plugin'
description: 'Installs OpenSearch Dashboard with a Plugin from github, then checkouts the correct dashboards version for the plugin, configures npm/yarn, and bootstraps Dashboards'

inputs:
plugin_name:
description: 'The the name of the plugin to use, such as security-dashboards-plugin'
required: true

outputs:
dashboards-directory:
description: "The directory where the dashboards has been configured"
value: ${{ steps.determine-dashboards-directory.outputs.dashboards-directory }}

plugin-directory:
description: "The directory where the plugin has been configured"
value: ${{ steps.determine-plugin-directory.outputs.plugin-directory }}


runs:
using: "composite"
steps:
- id: determine-dashboards-directory
run: echo "dashboards-directory=OpenSearch-Dashboards" >> $GITHUB_OUTPUT
shell: bash

- id: determine-plugin-directory
run: echo "::set-output name=plugin-directory::./OpenSearch-Dashboards/plugins/${{ inputs.plugin_name }}"
# run: echo "plugin-directory=./OpenSearch-Dashboards/plugins/${{ inputs.plugin_name }}" >> $GITHUB_OUTPUT
shell: bash

- uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards
repository: opensearch-project/OpenSearch-Dashboards
ref: 'main'
fetch-depth: 0

- run: mkdir -p plugins
working-directory: OpenSearch-Dashboards
shell: bash

- uses: actions/checkout@v2
with:
path: ${{ steps.determine-plugin-directory.outputs.plugin-directory }}
# ref: ${{ github.ref }}

- id: osd-version
continue-on-error: true
run: |
echo "::set-output name=osd-version::$(cat package.json | jq '.opensearchDashboards.version' | cut -c 2-4)"
echo "::set-output name=osd-x-version::$(cat package.json | jq '.opensearchDashboards.version' | cut -c 2-3)"
working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }}
shell: bash

- id: branch-switch-if-possible
continue-on-error: true # Defaults onto main if the branch switch doesn't work
if: ${{ steps.osd-version.outputs.osd-version }}
run: git checkout ${{ steps.osd-version.outputs.osd-version }} || git checkout ${{ steps.osd-version.outputs.osd-x-version }}x
working-directory: ./OpenSearch-Dashboards
shell: bash

- id: tool-versions
run: |
echo "node_version=$(cat .node-version)" >> $GITHUB_OUTPUT
echo "yarn_version=$(jq -r '.engines.yarn' package.json)" >> $GITHUB_OUTPUT
working-directory: OpenSearch-Dashboards
shell: bash

- uses: actions/setup-node@v1
with:
node-version: ${{ steps.tool-versions.outputs.node_version }}
registry-url: 'https://registry.npmjs.org'

- run: |
npm uninstall -g yarn
echo "Installing yarn ${{ steps.tool-versions.outputs.yarn_version }}"
npm i -g yarn@${{ steps.tool-versions.outputs.yarn_version }}
working-directory: OpenSearch-Dashboards
shell: bash

- run: yarn osd bootstrap --oss
working-directory: OpenSearch-Dashboards
shell: bash
68 changes: 9 additions & 59 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,70 +44,20 @@ jobs:
EOF
docker run -d --network=host -i opensearch-test:latest

- name: Checkout OpenSearch Dashboard
uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards
repository: opensearch-project/OpenSearch-Dashboards
ref: '2.x'
fetch-depth: 0

- name: Create plugins dir
run: |
cd ./OpenSearch-Dashboards
mkdir -p plugins

- name: Checkout OpenSearch Dashboard Security plugin
uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards/plugins/security-dashboards-plugin
ref: ${{ github.ref }}

- name: Check OpenSearch Running
continue-on-error: true
run: curl -XGET https://localhost:9200 -u 'admin:admin' -k
- uses: actions/checkout@v2

# - name: Get OpenSearch Dashboards version
# id: osd_version
# run: |
# echo "::set-output name=osd_version::$(jq -r '.opensearchDashboards.version' ./OpenSearch-Dashboards/plugins/security-dashboards-plugin/package.json)"

# - name: Check OpenSearch Dashboards release tag
# run: |
# cd ./OpenSearch-Dashboards
# git checkout tags/${{ steps.osd_version.outputs.osd_version }} -b v${{ steps.osd_version.outputs.osd_version }}

- name: Get node and yarn versions
id: versions
run: |
echo "::set-output name=node_version::$(cat ./OpenSearch-Dashboards/.node-version)"
echo "::set-output name=yarn_version::$(jq -r '.engines.yarn' ./OpenSearch-Dashboards/package.json)"

- name: Setup node
uses: actions/setup-node@v1
- id: install-dashboards
uses: ./.github/actions/install-dashboards
with:
node-version: ${{ steps.versions.outputs.node_version }}
registry-url: 'https://registry.npmjs.org'

- name: Install correct yarn version for OpenSearch Dashboards
run: |
npm uninstall -g yarn
echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}"
npm i -g yarn@${{ steps.versions.outputs.yarn_version }}

- name: Check OpenSearch Running
continue-on-error: true
run: curl -XGET https://localhost:9200 -u 'admin:admin' -k
plugin_name: security-dashboards-plugin

- name: Start Dashboards in background
run: node scripts/build_opensearch_dashboards_platform_plugins.js
working-directory: ${{ steps.install-dashboards.outputs.dashboards-directory }}

- name: Bootstrap OpenSearch Dashboards
run: |
cd ./OpenSearch-Dashboards
yarn osd bootstrap
node scripts/build_opensearch_dashboards_platform_plugins.js

- name: Run integration tests
run: |
echo "check if opensearch is ready"
curl -XGET https://localhost:9200 -u 'admin:admin' -k
cd ./OpenSearch-Dashboards/plugins/security-dashboards-plugin
yarn test:jest_server --coverage
working-directory: ${{ steps.install-dashboards.outputs.plugin-directory }}
87 changes: 22 additions & 65 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,35 @@ name: Unit Tests
on: [push, pull_request]

jobs:
tests:
unit-tests:
name: Run unit tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest , windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout OpenSearch Dashboard
uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards
repository: opensearch-project/OpenSearch-Dashboards
ref: 'main'
fetch-depth: 0
- name: Create plugins dir
run: |
cd ./OpenSearch-Dashboards
mkdir -p plugins
- name: Checkout
uses: actions/checkout@v2
with:
path: OpenSearch-Dashboards/plugins/security-dashboards-plugin
ref: ${{ github.ref }}
- name: Get OpenSearch Dashboards version
id: osd_version
run: |
echo "::set-output name=osd_version::$(jq -r '.opensearchDashboards.version' ./OpenSearch-Dashboards/plugins/security-dashboards-plugin/package.json)"
- name: Use OpenSearch release commit
run: |
cd ./OpenSearch-Dashboards
# git checkout tags/v${{ steps.osd_version.outputs.osd_version }} -b v${{ steps.osd_version.outputs.osd_version }}
- name: Get node and yarn versions
id: versions
run: |
echo "::set-output name=node_version::$(cat ./OpenSearch-Dashboards/.node-version)"
echo "::set-output name=yarn_version::$(jq -r '.engines.yarn' ./OpenSearch-Dashboards/package.json)"
- name: Setup node
uses: actions/setup-node@v1
- name: Enable longer filenames
if: ${{ matrix.os == 'windows-latest' }}
run: git config --system core.longpaths true

- uses: actions/checkout@v2

- id: install-dashboards
uses: ./.github/actions/install-dashboards
with:
node-version: ${{ steps.versions.outputs.node_version }}
registry-url: 'https://registry.npmjs.org'
- name: Install correct yarn version for OpenSearch Dashboards
run: |
npm uninstall -g yarn
echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}"
npm i -g yarn@${{ steps.versions.outputs.yarn_version }}
- name: Bootstrap OpenSearch Dashboards
run: |
cd ./OpenSearch-Dashboards
yarn osd bootstrap --oss
plugin_name: security-dashboards-plugin

- name: Run lint
run: |
cd ./OpenSearch-Dashboards/plugins/security-dashboards-plugin
yarn lint
run: yarn lint
working-directory: ${{ steps.install-dashboards.outputs.plugin-directory }}

- name: Run unit test
run: |
cd ./OpenSearch-Dashboards/plugins/security-dashboards-plugin
yarn test:jest_ui --coverage
run: yarn test:jest_ui --coverage
working-directory: ${{ steps.install-dashboards.outputs.plugin-directory }}

- name: Uploads coverage
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: build security plugin
id: build_zip
run: |
cd ./OpenSearch-Dashboards/plugins/security-dashboards-plugin
yarn build --opensearch-dashboards-version ${{ steps.osd_version.outputs.osd_version }}

artifact_path=`ls $(pwd)/build/security*.zip`
artifact_name=`basename $artifact_path`
echo "::set-output name=ARTIFACT_PATH::$artifact_path"
echo "::set-output name=ARTIFACT_NAME::$artifact_name"
- name: Upload Workflow Artifacts
uses: actions/upload-artifact@v1
with:
name: ${{ steps.build_zip.outputs.ARTIFACT_NAME }}
path: ${{ steps.build_zip.outputs.ARTIFACT_PATH }}