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

Compatibility with Opensearch 2.17.1 #5

Merged
merged 6 commits into from
Nov 7, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/cypress-e2e-reporting-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ env:
# avoid warnings like "tput: No value for $TERM and no -T specified"
TERM: xterm
OPENSEARCH_DASHBOARDS_VERSION: '2.x'
OPENSEARCH_VERSION: '2.14.0'
OPENSEARCH_PLUGIN_VERSION: '2.14.0.0'
OPENSEARCH_VERSION: '2.17.1'
OPENSEARCH_PLUGIN_VERSION: '2.17.1.0'
PLUGIN_NAME: dashboards-reporting

jobs:
Expand Down Expand Up @@ -154,14 +154,14 @@ jobs:
working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}

- name: Capture failure screenshots
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots-${{ matrix.os }}
path: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}/.cypress/screenshots

- name: Capture test video
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos-${{ matrix.os }}
Expand Down
245 changes: 123 additions & 122 deletions .github/workflows/dashboards-reports-test-and-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
PLUGIN_NAME: reportsDashboards
ARTIFACT_NAME: reports-dashboards
OPENSEARCH_VERSION: 'main'
OPENSEARCH_PLUGIN_VERSION: 2.14.0.0
OPENSEARCH_PLUGIN_VERSION: 2.17.1.0


jobs:
Expand Down Expand Up @@ -66,126 +66,127 @@ jobs:
whoami && yarn build && mv -v ./build/*.zip ./build/${{ env.ARTIFACT_NAME }}-${{ env.OPENSEARCH_PLUGIN_VERSION }}.zip"

- name: Upload Artifact For Linux
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: dashboards-reports-linux
path: ./OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}/build/${{ env.ARTIFACT_NAME }}-${{ env.OPENSEARCH_PLUGIN_VERSION }}.zip

windows-build:
runs-on: windows-latest
steps:

# Enable longer filenames for windows
- name: Enable longer filenames
run: git config --system core.longpaths true

- name: Checkout OpenSearch Dashboards
uses: actions/checkout@v1
with:
repository: opensearch-project/Opensearch-Dashboards
ref: ${{ env.OPENSEARCH_VERSION }}
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: Checkout Plugin
uses: actions/checkout@v1
with:
path: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}

- name: OpenSearch Dashboards Plugin Bootstrap
uses: nick-fields/retry@v1
with:
timeout_minutes: 30
max_attempts: 3
command: yarn osd bootstrap --single-version=loose

- name: Test
uses: nick-fields/retry@v1
with:
timeout_minutes: 30
max_attempts: 3
command: yarn test

- name: Build Artifact
run: |
yarn build
mv ./build/*.zip ./build/${{ env.ARTIFACT_NAME }}-${{ env.OPENSEARCH_PLUGIN_VERSION }}.zip

- name: Upload Artifact For Windows
uses: actions/upload-artifact@v1
with:
name: dashboards-reports-windows
path: ./build/${{ env.ARTIFACT_NAME }}-${{ env.OPENSEARCH_PLUGIN_VERSION }}.zip

macos-build:
runs-on: macos-latest
steps:
- name: Checkout OpenSearch Dashboards
uses: actions/checkout@v1
with:
repository: opensearch-project/Opensearch-Dashboards
ref: ${{ env.OPENSEARCH_VERSION }}
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: Checkout Plugin
uses: actions/checkout@v1
with:
path: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}

- name: OpenSearch Dashboards Plugin Bootstrap
uses: nick-fields/retry@v1
with:
timeout_minutes: 30
max_attempts: 3
command: yarn osd bootstrap --single-version=loose

- name: Test
uses: nick-fields/retry@v1
with:
timeout_minutes: 30
max_attempts: 3
command: yarn test

- name: Build Artifact
run: |
yarn build
mv ./build/*.zip ./build/${{ env.ARTIFACT_NAME }}-${{ env.OPENSEARCH_PLUGIN_VERSION }}.zip

- name: Upload Artifact For MacOS
uses: actions/upload-artifact@v1
with:
name: dashboards-reports-macosx
path: ./build/${{ env.ARTIFACT_NAME }}-${{ env.OPENSEARCH_PLUGIN_VERSION }}.zip
path: ./OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}/build/${{ env.ARTIFACT_NAME }}-${{ env.OPENSEARCH_PLUGIN_VERSION }}.zip

# Commenting out windows and macos build jobs as they are not required for now.
# windows-build:
# runs-on: windows-latest
# steps:

# # Enable longer filenames for windows
# - name: Enable longer filenames
# run: git config --system core.longpaths true

# - name: Checkout OpenSearch Dashboards
# uses: actions/checkout@v1
# with:
# repository: opensearch-project/Opensearch-Dashboards
# ref: ${{ env.OPENSEARCH_VERSION }}
# 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: Checkout Plugin
# uses: actions/checkout@v1
# with:
# path: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}

# - name: OpenSearch Dashboards Plugin Bootstrap
# uses: nick-fields/retry@v1
# with:
# timeout_minutes: 30
# max_attempts: 3
# command: yarn osd bootstrap --single-version=loose

# - name: Test
# uses: nick-fields/retry@v1
# with:
# timeout_minutes: 30
# max_attempts: 3
# command: yarn test

# - name: Build Artifact
# run: |
# yarn build
# mv ./build/*.zip ./build/${{ env.ARTIFACT_NAME }}-${{ env.OPENSEARCH_PLUGIN_VERSION }}.zip

# - name: Upload Artifact For Windows
# uses: actions/upload-artifact@v4
# with:
# name: dashboards-reports-windows
# path: ./build/${{ env.ARTIFACT_NAME }}-${{ env.OPENSEARCH_PLUGIN_VERSION }}.zip

# macos-build:
# runs-on: macos-latest
# steps:
# - name: Checkout OpenSearch Dashboards
# uses: actions/checkout@v1
# with:
# repository: opensearch-project/Opensearch-Dashboards
# ref: ${{ env.OPENSEARCH_VERSION }}
# 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: Checkout Plugin
# uses: actions/checkout@v1
# with:
# path: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}

# - name: OpenSearch Dashboards Plugin Bootstrap
# uses: nick-fields/retry@v1
# with:
# timeout_minutes: 30
# max_attempts: 3
# command: yarn osd bootstrap --single-version=loose

# - name: Test
# uses: nick-fields/retry@v1
# with:
# timeout_minutes: 30
# max_attempts: 3
# command: yarn test

# - name: Build Artifact
# run: |
# yarn build
# mv ./build/*.zip ./build/${{ env.ARTIFACT_NAME }}-${{ env.OPENSEARCH_PLUGIN_VERSION }}.zip

# - name: Upload Artifact For MacOS
# uses: actions/upload-artifact@v4
# with:
# name: dashboards-reports-macosx
# path: ./build/${{ env.ARTIFACT_NAME }}-${{ env.OPENSEARCH_PLUGIN_VERSION }}.zip
96 changes: 96 additions & 0 deletions .github/workflows/dev-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# This workflow downloads the source code at the given git reference
# (branch, tag or commit), an sets up an environment (Kibana or OpenSearch)
# to run this code and a command (build, test, ...).
#
# This workflow is used as a base for other workflows.

name: Base workflow - Environment

on:
workflow_call:
inputs:
reference:
required: true
type: string
default: master
description: Source code reference (branch, tag or commit SHA).
command:
required: true
type: string
default: 'yarn build'
description: Command to run in the environment
docker_run_extra_args:
type: string
default: ''
description: Additional paramaters for the docker run command.
required: false
artifact_name:
type: string
default: ''
description: Artifact name (will be automatically suffixed with .zip)
required: false
artifact_path:
type: string
default: ''
description: Folder to include in the archive.
required: false
notify_jest_coverage_summary:
type: boolean
default: false
required: false

jobs:
# Deploy the plugin in a development environment and run a command
# using a pre-built Docker image, hosted in Quay.io.
deploy_and_run_command:
name: Deploy and run command
runs-on: ubuntu-latest
steps:
- name: Step 01 - Download the plugin's source code
uses: actions/checkout@v3
with:
repository: wazuh/wazuh-dashboards-reporting
ref: ${{ inputs.reference }}
path: wazuh-dashboards-reporting

# Fix source code ownership so the internal user of the Docker
# container is also owner.
- name: Step 02 - Change code ownership
run: sudo chown 1000:1000 -R wazuh-dashboards-reporting;

- name: Step 03 - Set up the environment and run the command
run: |
# Read the platform version from the package.json file
echo "Reading the platform version from the package.json...";
platform_version=$(jq -r '.opensearchDashboards.version | select(. != null)' wazuh-dashboards-reporting/package.json);
echo "Plugin platform version: $platform_version";

# Up the environment and run the command
docker run -t --rm \
-e OPENSEARCH_DASHBOARDS_VERSION=${platform_version} \
-v `pwd`/wazuh-dashboards-reporting:/home/node/kbn/plugins/wazuh-dashboards-reporting \
${{ inputs.docker_run_extra_args }} \
quay.io/wazuh/osd-dev:${platform_version} \
bash -c '
yarn config set registry https://registry.yarnpkg.com;
cd /home/node/kbn/plugins/wazuh-dashboards-reporting && yarn && ${{ inputs.command }};
'
- name: Get the plugin version
run: |
echo "version=$(jq -r '.wazuh.version' $(pwd)/wazuh-dashboards-reporting/package.json)" >> $GITHUB_ENV
echo "revision=$(jq -r '.wazuh.revision' $(pwd)/wazuh-dashboards-reporting/package.json)" >> $GITHUB_ENV

- name: Step 04 - Upload artifact to GitHub
if: ${{ inputs.artifact_name && inputs.artifact_path }}
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact_name }}_${{ env.version }}-${{ env.revision }}_${{ inputs.reference }}.zip
path: ${{ inputs.artifact_path }}

- name: Step 05 - Upload coverage results to GitHub
if: ${{ inputs.notify_jest_coverage_summary && github.event_name == 'pull_request' }}
uses: AthleticNet/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: ./wazuh-dashboards-reporting/target/test-coverage/coverage-summary.json
title: "Code coverage (Jest)"
Loading
Loading