From dcf63cd5ab091de26a7af0288b6d570de7c73c59 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Wed, 13 Mar 2024 11:41:43 -0400 Subject: [PATCH] Add package test --- .github/workflows/manual-build.yml | 32 +++++++++++++++++++ scripts/test-packages/install-plugins.sh | 6 ++++ .../osd-test-packages.Dockerfile | 21 ++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 scripts/test-packages/install-plugins.sh create mode 100644 scripts/test-packages/osd-test-packages.Dockerfile diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index 859c9e105a..4452e637dd 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -31,3 +31,35 @@ jobs: command: 'yarn build' artifact_name: 'wazuh-dashboard-plugins' secrets: inherit + + test-packages: + needs: build + name: Test packages + runs-on: ubuntu-latest + + steps: + - name: Step 01 - Download the plugin's source code + uses: actions/checkout@v3 + with: + repository: wazuh/wazuh-dashboard-plugins + ref: ${{ inputs.reference }} + path: wazuh + + - name: Step 02 - Get version and revision + run: | + echo "currentDir=$(pwd -P)" >> $GITHUB_ENV + echo "version=$(jq -r '.version' $(pwd)/wazuh/plugins/main/package.json)" >> $GITHUB_ENV + echo "revision=$(jq -r '.revision' $(pwd)/wazuh/plugins/main/package.json)" >> $GITHUB_ENV + echo "versionPlatform=$(jq -r '.pluginPlatform.version' $(pwd)/wazuh/plugins/main/package.json)" >> $GITHUB_ENV + + - name: Step 03 - Download the plugin's source code + uses: actions/download-artifact@v3 + with: + name: wazuh-dashboard-plugins_${{ env.version }}-${{ env.revision }}_${{ inputs.reference }}.zip + path: ${{ env.currentDir }}/wazuh/scripts/test-packages/wazuh-dashboard-plugins_${{ env.version }}-${{ env.revision }}_${{ inputs.reference }}.zip + + - name: Step 04 - Build the Docker image + run: | + echo "current=${{ env.currentDir }}" + cd ./wazuh/scripts/test-packages + docker build --build-arg OSD_VERSION=${{ env.versionPlatform }} --build-arg PACKAGE_NAME=wazuh-dashboard-plugins_${{ env.version }}-${{ env.revision }}_${{ inputs.reference }}.zip -f osd-test-packages.Dockerfile ./ diff --git a/scripts/test-packages/install-plugins.sh b/scripts/test-packages/install-plugins.sh new file mode 100644 index 0000000000..6e9bc5505d --- /dev/null +++ b/scripts/test-packages/install-plugins.sh @@ -0,0 +1,6 @@ + plugins=$(ls /tmp) +echo $plugins +for plugin in $plugins; do + echo $plugin + /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin install file:///tmp/$plugin +done diff --git a/scripts/test-packages/osd-test-packages.Dockerfile b/scripts/test-packages/osd-test-packages.Dockerfile new file mode 100644 index 0000000000..0cdac62f74 --- /dev/null +++ b/scripts/test-packages/osd-test-packages.Dockerfile @@ -0,0 +1,21 @@ +# docker build --build-arg OSD_VERSION=2.12.0 --build-arg PACKAGE_NAME=wazuh-2.12.0.zip -t test-packages -f osd-test-packages.Dockerfile ./ + +ARG OSD_VERSION + +FROM opensearchproject/opensearch-dashboards:${OSD_VERSION} + +ARG PACKAGE_NAME + +ADD ./${PACKAGE_NAME} /tmp/ +# This is needed to run it local +# +# USER root +# RUN yum update -y && yum install -y unzip +# RUN unzip /tmp/${PACKAGE_NAME} -d /tmp/ +# RUN rm /tmp/${PACKAGE_NAME} +# USER opensearch-dashboards +# +COPY --chown=opensearch-dashboards ./install-plugins.sh / +RUN chmod +x /install-plugins.sh +RUN /install-plugins.sh +