-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pre-release for Wazuh agent v4.7.2-1 (#97)
* add wazuh agent test matrix * added env for wazuh agent version * check build for building and caching * add re-use agent name
- Loading branch information
Showing
13 changed files
with
260 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: "cleanup caches by a branch" | ||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
cleanup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cleanup | ||
run: | | ||
gh extension install actions/gh-actions-cache | ||
echo "Fetching list of cache key" | ||
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) | ||
set +e | ||
echo "Deleting caches..." | ||
for cacheKey in $cacheKeysForPR | ||
do | ||
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm | ||
done | ||
echo "Done" | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
REPO: ${{ github.repository }} | ||
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Test Wazuh agent dockerfiles | ||
name: Tests | ||
|
||
on: | ||
workflow_run: | ||
|
@@ -20,12 +20,64 @@ permissions: | |
pull-requests: write | ||
|
||
jobs: | ||
pyunit-tests: | ||
test-docker-build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 6 | ||
matrix: | ||
wazuh_agent_version: ['4.3.10-1','4.4.5-1', '4.5.4-1', '4.6.0-1', '4.7.1-1', '4.7.2-1'] | ||
include: | ||
- dockerfile: ./Dockerfile | ||
image: wazuh-agent-minideb | ||
wazuh_cluster_version: '4.7.0' | ||
- dockerfile: ./images/Dockerfile.amazonlinux | ||
image: wazuh-agent-amazonlinux | ||
wazuh_cluster_version: '4.7.0' | ||
- dockerfile: ./images/Dockerfile.ubuntu | ||
image: wazuh-agent-ubuntu | ||
wazuh_cluster_version: '4.7.0' | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Expose GitHub Runtime | ||
uses: crazy-max/ghaction-github-runtime@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Cache Docker images. | ||
uses: ScribeMD/[email protected] | ||
with: | ||
key: docker-${{ matrix.wazuh_agent_version }} | ||
|
||
- name: Build and Save Wazuh Agent base image | ||
run: | | ||
mkdir -p ${{ github.workspace }}/docker-images/ | ||
docker build -t ${{ matrix.image }}:${{ matrix.wazuh_agent_version }} -f ${{ matrix.dockerfile }} --build-arg AGENT_VERSION=${{ matrix.wazuh_agent_version }} . | ||
docker pull wazuh/wazuh-manager:${{ matrix.wazuh_cluster_version }} | ||
docker pull wazuh/wazuh-indexer:${{ matrix.wazuh_cluster_version }} | ||
docker pull wazuh/wazuh-dashboard:${{ matrix.wazuh_cluster_version }} | ||
pyunit-tests: | ||
runs-on: ubuntu-latest | ||
needs: ["test-docker-build"] | ||
strategy: | ||
max-parallel: 6 | ||
matrix: | ||
wazuh_agent_version: ['4.3.10-1','4.4.5-1', '4.5.4-1', '4.6.0-1', '4.7.1-1', '4.7.2-1'] | ||
include: | ||
- image: wazuh-agent-minideb | ||
- image: wazuh-agent-amazonlinux | ||
- image: wazuh-agent-ubuntu | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Expose GitHub Runtime | ||
uses: crazy-max/ghaction-github-runtime@v3 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v3 | ||
with: | ||
|
@@ -40,47 +92,75 @@ jobs: | |
run: | | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Cache Docker images. | ||
uses: ScribeMD/[email protected] | ||
with: | ||
key: docker-${{ runner.os }} | ||
key: docker-${{ matrix.wazuh_agent_version }} | ||
|
||
- name: Test with pytest | ||
run: | | ||
pytest -n auto -v --capture=sys -x --tb=long --junitxml=/tmp/test-results/wazuh-unittests.xml | ||
pytest -n auto -v --capture=sys -x --tb=long --junitxml=/tmp/test-results/wazuh-unittests-${{ matrix.wazuh_agent_version }}.xml | ||
env: | ||
AGENT_VERSION: "${{ matrix.wazuh_agent_version }}" | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: wazuh-unittests | ||
path: /tmp/test-results/wazuh-unittests.xml | ||
docker-compose-tests: | ||
needs: "pyunit-tests" | ||
path: /tmp/test-results/wazuh-unittests-${{ matrix.wazuh_agent_version }}.xml | ||
|
||
integrations-tests: | ||
needs: ["pyunit-tests"] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
wazuh_agent_version: ['4.3.10-1','4.4.5-1', '4.5.4-1','4.6.0-1','4.7.1-1','4.7.2-1'] | ||
wazuh_cluster_version: ['4.7.0'] | ||
include: | ||
- image: wazuh-agent-minideb | ||
- image: wazuh-agent-amazonlinux | ||
- image: wazuh-agent-ubuntu | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.9" | ||
cache: 'pip' | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi | ||
mkdir -p ${{ github.workspace }}/docker-images/ | ||
- name: Cache Docker images. | ||
if: always() | ||
uses: ScribeMD/[email protected] | ||
with: | ||
key: docker-${{ runner.os }} | ||
key: docker-${{ matrix.wazuh_agent_version }} | ||
|
||
- name: Download artifact from build job | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: wazuh-unittests | ||
path: ${{ github.workspace }}/test-results/ | ||
|
||
- name: Create single node certificates | ||
run: docker-compose -f tests/single-node/generate-indexer-certs.yml run --rm generator | ||
|
||
- name: Start single node stack | ||
run: docker-compose -f docker-compose.yml up -d --build | ||
env: | ||
AGENT_VERSION: "${{ matrix.wazuh_agent_version }}" | ||
WAZUH_CLUSTER_VERSION: "${{ matrix.wazuh_cluster_version }}" | ||
|
||
- name: Check Wazuh indexer start | ||
run: | | ||
|
@@ -101,22 +181,26 @@ jobs: | |
exit 1 | ||
fi | ||
- name: Tests agent containers | ||
run: pytest -v --capture=sys -x --tb=long .github/workflows/test_docker_compose.py --disable-warnings --junitxml=/tmp/test-results/wazuh-docker-compose.xml | ||
- name: Integration test for Wazuh agent | ||
run: pytest -v --capture=sys -x --tb=long .github/workflows/test_docker_compose.py --disable-warnings --junitxml=/tmp/test-results/wazuh-docker-compose-${{ matrix.wazuh_agent_version }}.xml | ||
|
||
- name: Copy Test Results | ||
if: always() | ||
run: | | ||
cp -Lpr /tmp/test-results/wazuh-docker-compose.xml ${{ github.workspace }}/test-results/wazuh-docker-compose.xml | ||
cp -Lpr /tmp/test-results/wazuh-docker-compose-${{ matrix.wazuh_agent_version }}.xml ${{ github.workspace }}/test-results/wazuh-docker-compose-${{ matrix.wazuh_agent_version }}.xml | ||
shell: bash | ||
|
||
- name: Check results | ||
run: | | ||
ls -R ${{ github.workspace }}/test-results/ | ||
- name: Publish Test Results | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
with: | ||
files: | | ||
test-results/**/*.xml | ||
- name: Stop containers | ||
- name: Stop containers and destroy | ||
if: always() | ||
run: docker-compose -f docker-compose.yml down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,6 @@ tmp/ | |
wazuh_indexer_ssl_certs | ||
snyk-code.sarif | ||
.dccache | ||
.coverage* | ||
coverage.xml | ||
htmlcov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.