Skip to content

Commit f152f81

Browse files
committed
Automate package's testing (#178)
* Attemtp to automate package's testing * Fix typo * Add sudo * Split test steps and manage errors * Add --no-pager to journalctl * Add certs generator * Improve error handling * Update r_test.yml Fix indentation Signed-off-by: Álex Ruiz <[email protected]> * Fix error handling * Add testing of RPM packages * Improve multi-os testing * Add TEST env var * Add braces to if conditionals * Remove all curly braches from if conditionals * braces again * Install RPM package in Docker * Remove sudo for RPM installation * Bind artifacts/dist to RPM docker test container * Bind artifacts/dist to RPM docker test container * Avoid prompt during yum install * Fix bind volume --------- Signed-off-by: Álex Ruiz <[email protected]>
1 parent 8e4d75b commit f152f81

File tree

3 files changed

+103
-2
lines changed

3 files changed

+103
-2
lines changed

.github/workflows/build.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
push:
77
# Sequence of patterns matched against refs/heads
88
branches:
9-
- 'ci/*'
9+
- "ci/*"
1010
workflow_dispatch:
1111
inputs:
1212
revision:
@@ -36,7 +36,7 @@ jobs:
3636
uses: ./.github/workflows/r_commit_sha.yml
3737

3838
build:
39-
needs: [ version, commit_sha ]
39+
needs: [version, commit_sha]
4040
strategy:
4141
matrix:
4242
distribution: [tar, rpm, deb]
@@ -64,3 +64,13 @@ jobs:
6464
architecture: ${{ matrix.architecture }}
6565
distribution: ${{ matrix.distribution }}
6666
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 }}
67+
68+
test:
69+
needs: [version, commit_sha, assemble]
70+
strategy:
71+
fail-fast: false
72+
matrix:
73+
os: [{ suffix: "amd64", ext: "deb" }, { suffix: "x86_64", ext: "rpm" }]
74+
uses: ./.github/workflows/r_test.yml
75+
with:
76+
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 }}

.github/workflows/r_assemble.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Assemble (reusable)
22

3+
env:
4+
TEST: true
5+
36
# This workflow runs when any of the following occur:
47
# - Run from another workflow
58
on:

.github/workflows/r_test.yml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Test (reusable)
2+
3+
# This workflow runs when any of the following occur:
4+
# - Run from another workflow
5+
on:
6+
workflow_call:
7+
inputs:
8+
package:
9+
description: "The name of the package to download."
10+
required: true
11+
type: string
12+
13+
jobs:
14+
r_test_rpm:
15+
if: ${{ endsWith(inputs.package, 'rpm') }}
16+
runs-on: ubuntu-latest
17+
# Permissions to upload the package
18+
permissions:
19+
packages: read
20+
contents: read
21+
steps:
22+
- name: Download artifact
23+
uses: actions/download-artifact@v4
24+
with:
25+
name: ${{ inputs.package }}
26+
path: artifacts/dist
27+
28+
- name: Install package
29+
uses: addnab/docker-run-action@v3
30+
with:
31+
image: redhat/ubi9:latest
32+
options: -v ${{ github.workspace }}/artifacts/dist:/artifacts/dist
33+
run: |
34+
yum localinstall "/artifacts/dist/${{ inputs.package }}" -y
35+
36+
r_test_deb:
37+
if: ${{ endsWith(inputs.package, 'deb') }}
38+
runs-on: ubuntu-latest
39+
# Permissions to upload the package
40+
permissions:
41+
packages: read
42+
contents: read
43+
steps:
44+
- name: Download artifact
45+
uses: actions/download-artifact@v4
46+
with:
47+
name: ${{ inputs.package }}
48+
path: artifacts/dist
49+
50+
- name: Install package
51+
run: |
52+
sudo dpkg -i "artifacts/dist/${{ inputs.package }}"
53+
54+
- uses: actions/checkout@v4
55+
- name: Generate and deploy certificates
56+
uses: addnab/docker-run-action@v3
57+
with:
58+
image: wazuh/wazuh-certs-generator:0.0.1
59+
options: -v ${{ github.workspace }}/integrations/docker/config/certs.yml:/config/certs.yml -v /etc/wazuh-indexer/certs:/certs
60+
shell: sh
61+
run: |
62+
mkdir -p /certificates /certs
63+
/entrypoint.sh
64+
chown -R 1000:999 /certificates
65+
chmod 740 /certificates
66+
chmod 440 /certificates/*
67+
68+
mv /certificates/wazuh.indexer-key.pem /certs/indexer-key.pem
69+
mv /certificates/wazuh.indexer.pem /certs/indexer.pem
70+
mv /certificates/root-ca.pem /certs/root-ca.pem
71+
ls /certs
72+
73+
- run: sudo systemctl daemon-reload
74+
- run: |
75+
if ! sudo systemctl enable wazuh-indexer.service; then
76+
sudo journalctl --no-pager -u wazuh-indexer.service
77+
exit 1
78+
fi
79+
- run: |
80+
if ! sudo systemctl start wazuh-indexer; then
81+
sudo journalctl --no-pager -u wazuh-indexer.service
82+
exit 1
83+
fi
84+
- run: |
85+
if ! sudo systemctl status --no-pager wazuh-indexer -n 100; then
86+
sudo journalctl --no-pager -u wazuh-indexer.service
87+
exit 1
88+
fi

0 commit comments

Comments
 (0)