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

Build & Assemble reporting plugin #431

Merged
merged 6 commits into from
Sep 25, 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
80 changes: 64 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ on:
description: "ID used to identify the workflow uniquely."
type: string
required: false
plugins_reference:
description: "Branch, commit or tag for the plugins repository"
wazuh_plugins_ref:
description: "Branch, commit or tag for the wazuh-indexer-plugins repository"
type: string
default: "master"
reporting_plugin_ref:
description: "Branch, commit or tag for the wazuh-indexer-reporting repository"
type: string
default: "master"
workflow_call:
Expand Down Expand Up @@ -68,8 +72,12 @@ on:
id:
type: string
required: false
plugins_reference:
description: "Branch, commit or tag for the plugins repository"
wazuh_plugins_ref:
description: "Branch, commit or tag for the wazuh-indexer-plugins repository"
type: string
default: "master"
reporting_plugin_ref:
description: "Branch, commit or tag for the wazuh-indexer-reporting repository"
type: string
default: "master"
secrets:
Expand Down Expand Up @@ -109,18 +117,21 @@ jobs:
)
echo "matrix=$matrix" >> $GITHUB_OUTPUT

build-plugins:
if: ${{ inputs.plugins_reference != '' }}
build-wazuh-plugins:
if: ${{ inputs.wazuh_plugins_ref != '' }}
strategy:
fail-fast: false
matrix:
plugins: ["setup", "command-manager"]
runs-on: ubuntu-latest
env:
plugin_name: wazuh-indexer-${{ matrix.plugins }}
steps:
- uses: actions/checkout@v4
with:
repository: wazuh/wazuh-indexer-plugins
ref: ${{ inputs.plugins_reference }}
ref: ${{ inputs.wazuh_plugins_ref }}

- uses: actions/setup-java@v4
with:
distribution: temurin
Expand All @@ -135,19 +146,55 @@ jobs:

- name: Build with Gradle
working-directory: ./plugins/${{ matrix.plugins }}
run: |
./gradlew build -Dversion=${{ steps.version.outputs.version }} -Drevision=${{ inputs.revision }}
ls -lR build/distributions/
run: ./gradlew build -Dversion=${{ steps.version.outputs.version }} -Drevision=${{ inputs.revision }}

- run: ls -lR build/distributions
working-directory: ./plugins/${{ matrix.plugins }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.plugin_name }}-${{ steps.version.outputs.version }}.${{ inputs.revision }}.zip
path: "./plugins/${{ matrix.plugins }}/build/distributions/${{ env.plugin_name }}-${{ steps.version.outputs.version }}.${{ inputs.revision }}.zip"
if-no-files-found: error

build-reporting-plugin:
if: ${{ inputs.reporting_plugin_ref != '' }}
runs-on: ubuntu-latest
env:
plugin_name: wazuh-indexer-reports-scheduler
steps:
- uses: actions/checkout@v4
with:
repository: wazuh/wazuh-indexer-reporting
ref: ${{ inputs.reporting_plugin_ref }}

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21

- name: Setup Gradle # Used for caching
uses: gradle/actions/setup-gradle@v4

- name: Get version
id: version
run: echo "version=$(<VERSION)" >> "$GITHUB_OUTPUT"

- name: Build with Gradle
run: ./gradlew build -Dversion=${{ steps.version.outputs.version }} -Drevision=${{ inputs.revision }}

- run: ls -lR build/distributions

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.plugins }}
path: "./plugins/${{ matrix.plugins }}/build/distributions/wazuh-indexer-${{ matrix.plugins }}-${{ steps.version.outputs.version }}.${{ inputs.revision }}.zip"
name: ${{ env.plugin_name }}-${{ steps.version.outputs.version }}.${{ inputs.revision }}.zip
path: build/distributions/${{ env.plugin_name }}-${{ steps.version.outputs.version }}.${{ inputs.revision }}.zip
if-no-files-found: error

build:
needs: [matrix, build-plugins]
needs: [matrix, build-wazuh-plugins, build-reporting-plugin]
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -156,14 +203,15 @@ jobs:
- uses: actions/checkout@v4

# Download plugins
- uses: actions/download-artifact@v4
if: ${{ inputs.plugins_reference != '' }}
- name: Download plugins
uses: actions/download-artifact@v4
if: ${{ inputs.wazuh_plugins_ref != '' || inputs.reporting_plugin_ref != ''}}
with:
path: ./artifacts/plugins
merge-multiple: true

- name: Display structure of downloaded files
if: ${{ inputs.plugins_reference != '' }}
if: ${{ inputs.wazuh_plugins_ref != '' || inputs.reporting_plugin_ref != ''}}
run: ls -lR ./artifacts/plugins

- uses: actions/setup-java@v4
Expand Down
3 changes: 2 additions & 1 deletion build-scripts/assemble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ else
"notifications" # "opensearch-notifications". Requires "opensearch-notifications-core"
"opensearch-observability"
"performance-analyzer" # "opensearch-performance-analyzer"
"opensearch-reports-scheduler"
"opensearch-security"
"opensearch-security-analytics"
"opensearch-sql-plugin" # "opensearch-sql"
)
wazuh_plugins=(
"wazuh-indexer-setup"
"wazuh-indexer-command-manager"
"wazuh-indexer-reports-scheduler"
)
fi

Expand Down
4 changes: 2 additions & 2 deletions distribution/packages/src/deb/debmake_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ if [ -e "${buildroot}/${config_dir}/opensearch-observability/observability.yml"
chmod -c 660 "${buildroot}/${config_dir}/opensearch-observability/observability.yml"
fi

if [ -e "${buildroot}/${config_dir}/opensearch-reports-scheduler/reports-scheduler.yml" ]; then
chmod -c 660 "${buildroot}/${config_dir}/opensearch-reports-scheduler/reports-scheduler.yml"
if [ -e "${buildroot}/${config_dir}/wazuh-indexer-reports-scheduler/reports-scheduler.yml" ]; then
chmod -c 660 "${buildroot}/${config_dir}/wazuh-indexer-reports-scheduler/reports-scheduler.yml"
fi

# Files that need other permissions
Expand Down
18 changes: 9 additions & 9 deletions distribution/packages/src/rpm/wazuh-indexer.rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ For more information, see: https://www.wazuh.com/
%build

%define observability_plugin %( if [ -f %{_topdir}/etc/wazuh-indexer/opensearch-observability/observability.yml ]; then echo "1" ; else echo "0"; fi )
%define reportsscheduler_plugin %( if [ -f %{_topdir}/etc/wazuh-indexer/opensearch-reports-scheduler/reports-scheduler.yml ]; then echo "1" ; else echo "0"; fi )
%define reportsscheduler_plugin %( if [ -f %{_topdir}/etc/wazuh-indexer/wazuh-indexer-reports-scheduler/reports-scheduler.yml ]; then echo "1" ; else echo "0"; fi )

%install
set -e
Expand All @@ -77,7 +77,7 @@ fi

# Pre-populate the folders to ensure rpm build success even without all plugins
mkdir -p %{buildroot}%{config_dir}/opensearch-observability
mkdir -p %{buildroot}%{config_dir}/opensearch-reports-scheduler
mkdir -p %{buildroot}%{config_dir}/wazuh-indexer-reports-scheduler
mkdir -p %{buildroot}%{product_dir}/performance-analyzer-rca

# Pre-populate PA configs if not present
Expand Down Expand Up @@ -144,7 +144,7 @@ if [ %observability_plugin -eq 1 ]; then
fi

if [ %reportsscheduler_plugin -eq 1 ]; then
set -- "$@" "%{config_dir}/opensearch-reports-scheduler/reports-scheduler.yml"
set -- "$@" "%{config_dir}/wazuh-indexer-reports-scheduler/reports-scheduler.yml"
fi

for i in "$@"
Expand Down Expand Up @@ -251,7 +251,7 @@ exit 0
%endif

%if %reportsscheduler_plugin
%config(noreplace) %attr(660, %{name}, %{name}) %{config_dir}/opensearch-reports-scheduler/reports-scheduler.yml
%config(noreplace) %attr(660, %{name}, %{name}) %{config_dir}/wazuh-indexer-reports-scheduler/reports-scheduler.yml
%endif


Expand All @@ -265,13 +265,13 @@ exit 0
%attr(750, %{name}, %{name}) %{product_dir}/performance-analyzer-rca/bin/*

%changelog
* Fri Sep 06 2024 support <[email protected]> - 5.0.0
* Fri Dec 06 2024 support <[email protected]> - 5.0.0
- More info: https://documentation.wazuh.com/current/release-notes/release-5.0.0-0.html
* Tue Aug 20 2024 support <[email protected]> - 4.10.0
* Fri Nov 06 2024 support <[email protected]> - 4.10.1
- More info: https://documentation.wazuh.com/current/release-notes/release-4-10-1.html
* Mon Sep 23 2024 support <[email protected]> - 4.10.0
- More info: https://documentation.wazuh.com/current/release-notes/release-4-10-0.html
* Fri Sep 06 2024 support <[email protected]> - 4.9.2
- More info: https://documentation.wazuh.com/current/release-notes/release-4-9-1.html
* Thu Aug 15 2024 support <[email protected]> - 4.9.1
* Fri Sep 20 2024 support <[email protected]> - 4.9.1
- More info: https://documentation.wazuh.com/current/release-notes/release-4-9-1.html
* Thu Aug 15 2024 support <[email protected]> - 4.9.0
- More info: https://documentation.wazuh.com/current/release-notes/release-4-9-0.html
Expand Down