Skip to content

Commit

Permalink
Update build workflow to build indexer plugins (#360)
Browse files Browse the repository at this point in the history
* Update build workflow to include Wazuh plugins

* Try new approach to build wazuh-indexer with plugins

* Remove old code

* Remove ADMINS.md
artifacts
benchmarks
build
build.gradle
buildSrc
CHANGELOG.md
client
codecov.yml
CODE_OF_CONDUCT.md
CONTRIBUTING.md
DEVELOPER_GUIDE.md
dev-tools
distribution
docker
docs
doc-tools
ecs
gradle
gradle.properties
gradlew
gradlew.bat
integrations
libs
licenses
LICENSE.txt
MAINTAINERS.md
modules
NOTICE.txt
packaging_scripts
plugins
protobuf-java-NOTICE.txt
qa
README.md
release-notes
RELEASING.md
rest-api-spec
sandbox
SECURITY.md
server
settings.gradle
test
TESTING.md
Vagrantfile
VERSION
whitesource.config step

* Sync mavel local path across jobs

* Fix versioning of wazuh-indexer-plugins

* Fix versioning of wazuh-indexer-plugins

* Pass version and revision to publishToMavenLocal

* Add version check test

* Format files

* Use upload-artifact and download-artifact to share the plugins' zips between jobs

* Add repo path

* Fix plugin name

* Roll back

* Remove exit 1

* Fix relative path to the plugins

* List plugins folder

* Fix relative path

* again

* Change relative path to absolute

* Clean code

* Update README.ms

* Apply naming convention

* Add breif steps to build wazuh-indexer with plugins

* Skip job to build plugins on no input

* Improve conditional

* Remove build-plugins job from build's job dependencies

* Roll back
  • Loading branch information
AlexRuiz7 committed Sep 9, 2024
1 parent 13398c9 commit 745ff18
Show file tree
Hide file tree
Showing 13 changed files with 417 additions and 298 deletions.
93 changes: 75 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ on:
description: "ID used to identify the workflow uniquely."
type: string
required: false
plugins_reference:
description: "Branch, commit or tag for the plugins repository"
type: string
default: "master"
workflow_call:
inputs:
revision:
Expand Down Expand Up @@ -64,6 +68,10 @@ on:
id:
type: string
required: false
plugins_reference:
description: "Branch, commit or tag for the plugins repository"
type: string
default: "master"
secrets:
CI_INTERNAL_DEVELOPMENT_BUCKET_USER_ACCESS_KEY:
required: true
Expand Down Expand Up @@ -95,68 +103,117 @@ jobs:
- id: setup
run: |
matrix=$(jq -cn \
--argjson distribution '${{ inputs.distribution }}' \
--argjson architecture '${{ inputs.architecture }}' \
--argjson distribution '${{ github.event.inputs.distribution }}' \
--argjson architecture '${{ github.event.inputs.architecture }}' \
'{distribution: $distribution, architecture: $architecture}'
)
echo "matrix=$matrix" >> $GITHUB_OUTPUT
build-plugins:
if: ${{ github.event.inputs.plugins_reference != '' }}
strategy:
fail-fast: false
matrix:
plugins: ["wazuh-indexer-setup"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: wazuh/wazuh-indexer-plugins
ref: ${{ github.event.inputs.plugins_reference }}
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

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

- name: Build with Gradle
working-directory: .//plugins/${{ matrix.plugins }}
run: |
./gradlew build -Dversion=${{ steps.version.outputs.version }} -Drevision=${{ github.event.inputs.revision }}
ls -lR build/distributions/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.plugins }}
path: "./plugins/${{ matrix.plugins }}/build/distributions/${{ matrix.plugins }}-${{ steps.version.outputs.version }}.${{ github.event.inputs.revision }}.zip"
if-no-files-found: error

build:
needs: [matrix]
needs: [matrix, build-plugins]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4

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

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

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

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
uses: gradle/actions/setup-gradle@v4

- name: Provision
if: ${{ matrix.distribution == 'deb' }}
run: |
sudo bash packaging_scripts/provision.sh
sudo bash build-scripts/provision.sh
- name: Run `baptizer.sh` (min)
run: |
name=$(bash packaging_scripts/baptizer.sh -m \
name=$(bash build-scripts/baptizer.sh -m \
-a ${{ matrix.architecture }} \
-d ${{ matrix.distribution }} \
-r ${{ inputs.revision }} \
${{ inputs.is_stage && '-x' || '' }} \
-r ${{ github.event.inputs.revision }} \
${{ github.event.inputs.is_stage && '-x' || '' }} \
)
echo "name=$name" >> $GITHUB_OUTPUT
id: min_package

- name: Run `baptizer.sh`
run: |
name=$(bash packaging_scripts/baptizer.sh \
name=$(bash build-scripts/baptizer.sh \
-a ${{ matrix.architecture }} \
-d ${{ matrix.distribution }} \
-r ${{ inputs.revision }} \
${{ inputs.is_stage && '-x' || '' }} \
-r ${{ github.event.inputs.revision }} \
${{ github.event.inputs.is_stage && '-x' || '' }} \
)
echo "name=$name" >> $GITHUB_OUTPUT
id: package

- name: Run `build.sh`
run: |
bash packaging_scripts/build.sh \
bash build-scripts/build.sh \
-a ${{ matrix.architecture }} \
-d ${{ matrix.distribution }} \
-n ${{ steps.min_package.outputs.name }}
- name: Run `assemble.sh`
run: |
bash packaging_scripts/assemble.sh \
bash build-scripts/assemble.sh \
-a ${{ matrix.architecture }} \
-d ${{ matrix.distribution }} \
-r ${{ inputs.revision }}
-r ${{ github.event.inputs.revision }}
- name: Test RPM package
if: ${{ matrix.distribution == 'rpm' }}
Expand All @@ -180,15 +237,15 @@ jobs:
if-no-files-found: error

- name: Set up AWS CLI
if: ${{ inputs.upload }}
if: ${{ github.event.inputs.upload }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.CI_INTERNAL_DEVELOPMENT_BUCKET_USER_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.CI_INTERNAL_DEVELOPMENT_BUCKET_USER_SECRET_KEY }}
aws-region: ${{ secrets.CI_AWS_REGION }}

- name: Upload package to S3
if: ${{ inputs.upload }}
if: ${{ github.event.inputs.upload }}
run: |
src="artifacts/dist/${{ steps.package.outputs.name }}"
dest="s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/"
Expand All @@ -197,7 +254,7 @@ jobs:
echo "S3 URI: ${s3uri}"
- name: Upload checksum to S3
if: ${{ inputs.upload && inputs.checksum }}
if: ${{ github.event.inputs.upload && github.event.inputs.checksum }}
run: |
src="artifacts/dist/${{ steps.package.outputs.name }}.sha512"
dest="s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/"
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/version_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Version check

on:
push:
paths:
- "VERSION"

jobs:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check version
run: bash build-scripts/check-version.sh
Loading

0 comments on commit 745ff18

Please sign in to comment.