From fd18899dc1f5935ae2ca5d5d86f32fa21f896560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Wed, 6 Mar 2024 20:36:10 +0100 Subject: [PATCH 01/11] Attemtp to automate package's testing --- .github/workflows/build.yml | 6 ++++++ .github/workflows/r_test.yml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/r_test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c05d48c4a507..87b4352c5528a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,3 +64,9 @@ jobs: architecture: ${{ matrix.architecture }} distribution: ${{ matrix.distribution }} min: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-${{ matrix.architecture }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.distribution }} + + test: + needs: [version, commit_sha, assemble] + uses: ./.github/workflows/r_test.yml + with: + package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-amd64_${{ needs.commit_sha.outputs.commit_sha }}.deb \ No newline at end of file diff --git a/.github/workflows/r_test.yml b/.github/workflows/r_test.yml new file mode 100644 index 0000000000000..ba28d75130dc5 --- /dev/null +++ b/.github/workflows/r_test.yml @@ -0,0 +1,34 @@ +name: Test (reusable) + +# This workflow runs when any of the following occur: +# - Run from another workflow +on: + workflow_call: + inputs: + package: + description: "The name of the package to download." + required: true + type: string + +jobs: + r_test: + runs-on: ubuntu-latest + # Permissions to upload the package + permissions: + packages: read + contents: read + steps: + - uses: actions/checkout@v4 + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.package }} + path: artifacts/dist + + - name: Run `test.sh` + run: | + dpkg -i "artifacts/dist/${{ inputs.package }}"; + systemctl daemon-reload; + systemctl enable wazuh-indexer.service; + systemctl start wazuh-indexer; + systemctl status wazuh-indexer From bb74237d1ff69e3222b9787917279bd83d9aec68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Wed, 6 Mar 2024 21:01:36 +0100 Subject: [PATCH 02/11] Add workflow file to upload packages to S3 --- .github/workflows/build.yml | 6 ++++++ .github/workflows/r_upload.yml | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/workflows/r_upload.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 87b4352c5528a..dbd4db6e1f0d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,5 +68,11 @@ jobs: test: needs: [version, commit_sha, assemble] uses: ./.github/workflows/r_test.yml + with: + package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-amd64_${{ needs.commit_sha.outputs.commit_sha }}.deb + + upload: + needs: [version, commit_sha, test] + uses: ./.github/workflows/r_upload.yml with: package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-amd64_${{ needs.commit_sha.outputs.commit_sha }}.deb \ No newline at end of file diff --git a/.github/workflows/r_upload.yml b/.github/workflows/r_upload.yml new file mode 100644 index 0000000000000..9adee1c5cb2dd --- /dev/null +++ b/.github/workflows/r_upload.yml @@ -0,0 +1,38 @@ +name: Upload (reusable) + +# This workflow runs when any of the following occur: +# - Run from another workflow +on: + workflow_call: + inputs: + package: + description: "The name of the package to upload to Wazuh's S3 development artifactory bucket." + required: true + type: string + +jobs: + r_test: + runs-on: ubuntu-latest + # Permissions to upload the package + permissions: + packages: read + contents: read + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.package }} + path: artifacts/dist + + - name: Set up AWS CLI + uses: aws-actions/configure-aws-credentials@v1 + if: success() + 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: us-east-1 + + - name: Upload package to S3 + if: success() + run: | + aws s3 cp artifacts/dist/${{ inputs.package }} s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/ From c7baec4c7ff93a8ea442f912a80f74e7efd57ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Thu, 7 Mar 2024 14:42:14 +0100 Subject: [PATCH 03/11] Skip testing to test whether the upload works --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dbd4db6e1f0d3..22e25493a47f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,7 +72,9 @@ jobs: package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-amd64_${{ needs.commit_sha.outputs.commit_sha }}.deb upload: - needs: [version, commit_sha, test] + # Push skipping tests until we got that working + needs: [version, commit_sha, assemble] + # needs: [version, commit_sha, test] uses: ./.github/workflows/r_upload.yml with: package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-amd64_${{ needs.commit_sha.outputs.commit_sha }}.deb \ No newline at end of file From b584cf2322ade409475c8d000476686fba1ac1fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Thu, 7 Mar 2024 18:26:35 +0100 Subject: [PATCH 04/11] Fix package names --- .github/workflows/build.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 22e25493a47f5..c150223879fdc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,16 +65,13 @@ jobs: distribution: ${{ matrix.distribution }} min: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-${{ matrix.architecture }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.distribution }} - test: - needs: [version, commit_sha, assemble] - uses: ./.github/workflows/r_test.yml - with: - package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-amd64_${{ needs.commit_sha.outputs.commit_sha }}.deb - upload: # Push skipping tests until we got that working needs: [version, commit_sha, assemble] + strategy: + matrix: + os: [{ suffix: "amd64", ext: "deb" }, { suffix: "x86_64", ext: "rpm" }] # needs: [version, commit_sha, test] uses: ./.github/workflows/r_upload.yml with: - package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-amd64_${{ needs.commit_sha.outputs.commit_sha }}.deb \ No newline at end of file + package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}_${{ matrix.os.suffix }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.os.ext }} \ No newline at end of file From e46561a5bc41da8305b72980bee72681680f896a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Thu, 7 Mar 2024 18:49:08 +0100 Subject: [PATCH 05/11] Fix upload workflow name --- .github/workflows/build.yml | 1 + .github/workflows/r_upload.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c150223879fdc..b2edf0e210674 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,6 +69,7 @@ jobs: # Push skipping tests until we got that working needs: [version, commit_sha, assemble] strategy: + fail-fast: false matrix: os: [{ suffix: "amd64", ext: "deb" }, { suffix: "x86_64", ext: "rpm" }] # needs: [version, commit_sha, test] diff --git a/.github/workflows/r_upload.yml b/.github/workflows/r_upload.yml index 9adee1c5cb2dd..14f82a3506835 100644 --- a/.github/workflows/r_upload.yml +++ b/.github/workflows/r_upload.yml @@ -11,7 +11,7 @@ on: type: string jobs: - r_test: + r_upload: runs-on: ubuntu-latest # Permissions to upload the package permissions: From 3238c08b1d06dc39791c79c597199640375aaaab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Thu, 7 Mar 2024 18:58:11 +0100 Subject: [PATCH 06/11] Pass secrets to the reusable workflow --- .github/workflows/build.yml | 3 ++- .github/workflows/r_upload.yml | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b2edf0e210674..6fed46230666b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -75,4 +75,5 @@ jobs: # needs: [version, commit_sha, test] uses: ./.github/workflows/r_upload.yml with: - package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}_${{ matrix.os.suffix }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.os.ext }} \ No newline at end of file + package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}_${{ matrix.os.suffix }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.os.ext }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/r_upload.yml b/.github/workflows/r_upload.yml index 14f82a3506835..c1967854c61a4 100644 --- a/.github/workflows/r_upload.yml +++ b/.github/workflows/r_upload.yml @@ -9,6 +9,11 @@ on: description: "The name of the package to upload to Wazuh's S3 development artifactory bucket." required: true type: string + secrets: + CI_INTERNAL_DEVELOPMENT_BUCKET_USER_ACCESS_KEY: + required: true + CI_INTERNAL_DEVELOPMENT_BUCKET_USER_SECRET_KEY: + required: true jobs: r_upload: @@ -26,13 +31,11 @@ jobs: - name: Set up AWS CLI uses: aws-actions/configure-aws-credentials@v1 - if: success() 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: us-east-1 - name: Upload package to S3 - if: success() run: | aws s3 cp artifacts/dist/${{ inputs.package }} s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/ From 823ffa781a19acb338b170e4ec22ce8313c6faa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Thu, 7 Mar 2024 18:59:29 +0100 Subject: [PATCH 07/11] Fix indentation --- .github/workflows/r_upload.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/r_upload.yml b/.github/workflows/r_upload.yml index c1967854c61a4..05a08e40394c4 100644 --- a/.github/workflows/r_upload.yml +++ b/.github/workflows/r_upload.yml @@ -9,11 +9,11 @@ on: description: "The name of the package to upload to Wazuh's S3 development artifactory bucket." required: true type: string - secrets: - CI_INTERNAL_DEVELOPMENT_BUCKET_USER_ACCESS_KEY: - required: true - CI_INTERNAL_DEVELOPMENT_BUCKET_USER_SECRET_KEY: - required: true + secrets: + CI_INTERNAL_DEVELOPMENT_BUCKET_USER_ACCESS_KEY: + required: true + CI_INTERNAL_DEVELOPMENT_BUCKET_USER_SECRET_KEY: + required: true jobs: r_upload: @@ -28,7 +28,7 @@ jobs: with: name: ${{ inputs.package }} path: artifacts/dist - + - name: Set up AWS CLI uses: aws-actions/configure-aws-credentials@v1 with: From 69906c7446d9798c24227adcf99a9483637b659e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Thu, 7 Mar 2024 19:00:22 +0100 Subject: [PATCH 08/11] Fix indentation --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6fed46230666b..26326387c420f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,4 +76,4 @@ jobs: uses: ./.github/workflows/r_upload.yml with: package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}_${{ matrix.os.suffix }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.os.ext }} - secrets: inherit \ No newline at end of file + secrets: inherit \ No newline at end of file From 89a21843802ed2b4d10f0111ca42e3cb0765c985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Thu, 7 Mar 2024 19:43:57 +0100 Subject: [PATCH 09/11] Remove test workflow from this PR --- .github/workflows/r_test.yml | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 .github/workflows/r_test.yml diff --git a/.github/workflows/r_test.yml b/.github/workflows/r_test.yml deleted file mode 100644 index ba28d75130dc5..0000000000000 --- a/.github/workflows/r_test.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Test (reusable) - -# This workflow runs when any of the following occur: -# - Run from another workflow -on: - workflow_call: - inputs: - package: - description: "The name of the package to download." - required: true - type: string - -jobs: - r_test: - runs-on: ubuntu-latest - # Permissions to upload the package - permissions: - packages: read - contents: read - steps: - - uses: actions/checkout@v4 - - name: Download artifact - uses: actions/download-artifact@v4 - with: - name: ${{ inputs.package }} - path: artifacts/dist - - - name: Run `test.sh` - run: | - dpkg -i "artifacts/dist/${{ inputs.package }}"; - systemctl daemon-reload; - systemctl enable wazuh-indexer.service; - systemctl start wazuh-indexer; - systemctl status wazuh-indexer From 51b156dcf1fb441204b94fceb086ba893a0a543b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Thu, 7 Mar 2024 20:03:33 +0100 Subject: [PATCH 10/11] Add boolean input to control when the package is uploaded to the S3 bucket --- .github/workflows/build.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 26326387c420f..51379eedad5d7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,6 +14,10 @@ on: type: string required: true default: "1" + upload: + description: "If set to true, packages that pass testing are uploaded to the Wazuh's S3 development artifactory bucket." + type: bool + default: false # ========================== # Bibliography @@ -66,13 +70,13 @@ jobs: min: wazuh-indexer-min_${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}-${{ matrix.architecture }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.distribution }} upload: - # Push skipping tests until we got that working needs: [version, commit_sha, assemble] + # Upload only on 'workflow_dispatch' event and if 'upload=true' + if: ${{ github.event_name == 'push' && inputs.upload }} strategy: fail-fast: false matrix: os: [{ suffix: "amd64", ext: "deb" }, { suffix: "x86_64", ext: "rpm" }] - # needs: [version, commit_sha, test] uses: ./.github/workflows/r_upload.yml with: package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}_${{ matrix.os.suffix }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.os.ext }} From a85db140ef5240f559dd7daff0ddb3350ced0443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Thu, 7 Mar 2024 20:30:03 +0100 Subject: [PATCH 11/11] [UI/UX] Improve inputs description --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 51379eedad5d7..5aba500a3253e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,12 +10,12 @@ on: workflow_dispatch: inputs: revision: - description: "Any string or number used to extend the package's identifier" + description: "Revision" type: string required: true default: "1" upload: - description: "If set to true, packages that pass testing are uploaded to the Wazuh's S3 development artifactory bucket." + description: "Upload ?" type: bool default: false