Skip to content
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
44 changes: 44 additions & 0 deletions .github/workflows/4_builderpackage_ml_commons_plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 📝 Based on: `4_builderprecompiled_base-dev-environment.yml`
#
# 📦 Manual Build Workflow for Wazuh Dashboard ML Commons Plugin
#
# ⚡ Overview:
# This workflow builds and tests production-ready packages for Wazuh Dashboard ML Commons plugin,
# either manually or triggered by other workflows.
#
# 🚀 Key Features:
# - 🖇️ Manual or Automated Builds: Supports manual execution or invocation from other workflows,
# specifying any valid code reference (branch, tag, or commit SHA).
# - 🏗️ Production-Ready Package Generation: Builds a production-ready package from the provided code reference.
# - 🌐 Reusable Build Environment: Reuses a preconfigured build environment, ensuring consistency and easier maintenance.
#

name: Build app package (on demand)

on:
workflow_call:
inputs:
reference:
required: true
type: string
description: Git reference (branch, tag, or commit SHA) to build from.
default: '4.14.0'
workflow_dispatch:
inputs:
reference:
required: true
type: string
default: '4.14.0'
description: Git reference (branch, tag, or commit SHA) to build from.

jobs:
# Build an app package from the given source code reference.
build:
name: Build app package
uses: ./.github/workflows/4_builderprecompiled_base-dev-environment.yml
with:
reference: ${{ inputs.reference }}
command: 'yarn build'
artifact_name: 'ml-commons-dashboards'
artifact_path: './wazuh-dashboard-ml-commons/build'
secrets: inherit
114 changes: 114 additions & 0 deletions .github/workflows/4_builderprecompiled_base-dev-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# 📚 Base Workflow - Environment Setup and Command Execution
#
# ⚡ Overview:
# This workflow serves as a reusable base for other workflows, providing a
# standardized environment to execute custom commands (e.g., `yarn build`, `yarn test`)
# on source code fetched from a specified Git reference.
#
# 🚀 Key Features:
# - 💻 Docker-Based Environment Setup: Prepares a Docker environment with OpenSearch Dashboards or Kibana.
# - ⚙️ Custom Command Execution: Runs any specified command on the downloaded source code.
# - 📦 Artifact and Coverage Upload: Uploads build artifacts and test coverage results to GitHub when configured.
#
# 🔗 Designed for: Easy integration and reuse by other workflows.

name: Base workflow - Environment

on:
workflow_call:
inputs:
reference:
required: true
type: string
default: '4.14.0'
description: Git reference (branch, tag, or commit SHA) to build from.
command:
required: true
type: string
default: 'yarn build'
description: Command to run in the environment.
docker_run_extra_args:
type: string
default: ''
description: Additional parameters 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-24.04
steps:
- name: Step 01 - Download the plugin's source code
uses: actions/checkout@v4
with:
repository: wazuh/wazuh-dashboard-ml-commons
ref: ${{ inputs.reference }}
path: wazuh-dashboard-ml-commons

# 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-dashboard-ml-commons;

- 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-dashboard-ml-commons/package.json);
echo "Plugin platform version: $platform_version";

# Get Wazuh version and concatenate with platform version
wazuh_version=$(jq -r '.wazuh.version' wazuh-dashboard-ml-commons/package.json);
echo "Wazuh version: $wazuh_version";

# Concatenate versions in format: <Opensearch version>-<Wazuh version>
combined_version="${platform_version}-${wazuh_version}";
echo "Combined platform version: $combined_version";

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

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

- 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-dashboard-ml-commons/target/test-coverage/coverage-summary.json
title: 'Code coverage (Jest)'
Empty file.
44 changes: 44 additions & 0 deletions .github/workflows/5_builderpackage_ml_commons_plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 📝 Based on: `5_builderprecompiled_base-dev-environment.yml`
#
# 📦 Manual Build Workflow for Wazuh Dashboard ML Commons Plugin
#
# ⚡ Overview:
# This workflow builds and tests production-ready packages for Wazuh Dashboard ML Commons plugin,
# either manually or triggered by other workflows.
#
# 🚀 Key Features:
# - 🖇️ Manual or Automated Builds: Supports manual execution or invocation from other workflows,
# specifying any valid code reference (branch, tag, or commit SHA).
# - 🏗️ Production-Ready Package Generation: Builds a production-ready package from the provided code reference.
# - 🌐 Reusable Build Environment: Reuses a preconfigured build environment, ensuring consistency and easier maintenance.
#

name: Build app package (on demand)

on:
workflow_call:
inputs:
reference:
required: true
type: string
description: Git reference (branch, tag, or commit SHA) to build from.
default: 'main'
workflow_dispatch:
inputs:
reference:
required: true
type: string
default: 'main'
description: Git reference (branch, tag, or commit SHA) to build from.

jobs:
# Build an app package from the given source code reference.
build:
name: Build app package
uses: ./.github/workflows/5_builderprecompiled_base-dev-environment.yml
with:
reference: ${{ inputs.reference }}
command: 'yarn build'
artifact_name: 'ml-commons-dashboards'
artifact_path: './wazuh-dashboard-ml-commons/build'
secrets: inherit
114 changes: 114 additions & 0 deletions .github/workflows/5_builderprecompiled_base-dev-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# 📚 Base Workflow - Environment Setup and Command Execution
#
# ⚡ Overview:
# This workflow serves as a reusable base for other workflows, providing a
# standardized environment to execute custom commands (e.g., `yarn build`, `yarn test`)
# on source code fetched from a specified Git reference.
#
# 🚀 Key Features:
# - 💻 Docker-Based Environment Setup: Prepares a Docker environment with OpenSearch Dashboards or Kibana.
# - ⚙️ Custom Command Execution: Runs any specified command on the downloaded source code.
# - 📦 Artifact and Coverage Upload: Uploads build artifacts and test coverage results to GitHub when configured.
#
# 🔗 Designed for: Easy integration and reuse by other workflows.

name: Base workflow - Environment

on:
workflow_call:
inputs:
reference:
required: true
type: string
default: 'main'
description: Git reference (branch, tag, or commit SHA) to build from.
command:
required: true
type: string
default: 'yarn build'
description: Command to run in the environment.
docker_run_extra_args:
type: string
default: ''
description: Additional parameters 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-24.04
steps:
- name: Step 01 - Download the plugin's source code
uses: actions/checkout@v4
with:
repository: wazuh/wazuh-dashboard-ml-commons
ref: ${{ inputs.reference }}
path: wazuh-dashboard-ml-commons

# 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-dashboard-ml-commons;

- 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-dashboard-ml-commons/package.json);
echo "Plugin platform version: $platform_version";

# Get Wazuh version and concatenate with platform version
wazuh_version=$(jq -r '.wazuh.version' wazuh-dashboard-ml-commons/package.json);
echo "Wazuh version: $wazuh_version";

# Concatenate versions in format: <Opensearch version>-<Wazuh version>
combined_version="${platform_version}-${wazuh_version}";
echo "Combined platform version: $combined_version";

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

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

- 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-dashboard-ml-commons/target/test-coverage/coverage-summary.json
title: 'Code coverage (Jest)'
Loading
Loading