Skip to content

[chore] Fix-release-v0.147.0 #2989

[chore] Fix-release-v0.147.0

[chore] Fix-release-v0.147.0 #2989

Workflow file for this run

name: puppet-test
# Only run tests if there are relevant changes
on:
push:
branches:
- main
paths:
- '.github/workflows/puppet-test.yml'
- 'deployments/puppet/**'
- 'packaging/tests/deployments/puppet/**'
- 'packaging/tests/helpers/**'
- 'packaging/tests/requirements.txt'
- 'packaging/msi/**'
- 'packaging/bundle/**'
- '!**.md'
pull_request:
paths:
- '.github/workflows/puppet-test.yml'
- 'deployments/puppet/**'
- 'packaging/tests/deployments/puppet/**'
- 'packaging/tests/helpers/**'
- 'packaging/tests/requirements.txt'
- 'packaging/msi/**'
- 'packaging/bundle/**'
- '!**.md'
schedule:
- cron: '0 0 * * 3,6' # Every Wednesday and Saturday at midnight UTC
concurrency:
group: puppet-test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: '3.13'
REQUIREMENTS_PATH: "packaging/tests/requirements.txt"
jobs:
puppet-lint:
name: puppet-lint
runs-on: ubuntu-24.04
steps:
- name: Check out the codebase.
uses: actions/checkout@v5
- name: Lint
run: |
make -C deployments/puppet lint
puppet-rake-spec:
name: puppet-rake-spec
runs-on: ubuntu-24.04
steps:
- name: Check out the codebase.
uses: actions/checkout@v5
- name: Lint
run: |
make -C deployments/puppet rake-spec
puppet-test-matrix:
runs-on: ubuntu-24.04
steps:
- name: Check out code
uses: actions/checkout@v5
# EOL REFERENCE: https://endoflife.date/puppet
- name: Get matrix
id: get-matrix
run: |
# create test matrix for distro and arch
dockerfiles=$(find packaging/tests/deployments/puppet/images/ -name "Dockerfile.*" | cut -d '.' -f2- | sort -u)
if [ -z "$dockerfiles" ]; then
echo "Failed to get dockerfiles from packaging/tests/deployments/puppet/images/!" >&2
exit 1
fi
distro=$(for d in $dockerfiles; do echo -n "\"$d\","; done)
puppet_release='"8"'
with_instrumentation='"true","false"'
matrix="{\"DISTRO\": [${distro%,}], \"PUPPET_RELEASE\": [${puppet_release}], \"WITH_INSTRUMENTATION\": [${with_instrumentation}]}"
echo "$matrix" | jq
echo "matrix=${matrix}" >> "$GITHUB_OUTPUT"
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}
# Build Linux binary for package building
puppet-build-linux-binary:
uses: ./.github/workflows/reusable-compile.yml
with:
SYS_BINARY: binaries-linux_amd64
# Build Linux agent bundle for package building
puppet-build-linux-agent-bundle:
uses: ./.github/workflows/reusable-agent-bundle-linux.yml
with:
ARCH: amd64
# Use reusable workflow for DEB package
puppet-build-deb-local-package:
uses: ./.github/workflows/reusable-build-package.yml
needs:
- puppet-build-linux-binary
- puppet-build-linux-agent-bundle
with:
SYS_PACKAGE: deb
ARCH: amd64
# Use reusable workflow for RPM package
puppet-build-rpm-local-package:
uses: ./.github/workflows/reusable-build-package.yml
needs:
- puppet-build-linux-binary
- puppet-build-linux-agent-bundle
with:
SYS_PACKAGE: rpm
ARCH: amd64
puppet-test:
name: puppet-test
runs-on: ubuntu-24.04
timeout-minutes: 60
needs:
- puppet-lint
- puppet-test-matrix
- puppet-build-deb-local-package
- puppet-build-rpm-local-package
strategy:
matrix: ${{ fromJSON(needs.puppet-test-matrix.outputs.matrix) }}
fail-fast: false
steps:
- name: Check out the codebase.
uses: actions/checkout@v5
- name: Download DEB package artifacts
uses: actions/download-artifact@v7
with:
name: deb-amd64-package
path: ./dist
- name: Download RPM package artifacts
uses: actions/download-artifact@v7
with:
name: rpm-amd64-package
path: ./dist
- name: Setup python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: ${{ env.REQUIREMENTS_PATH }}
- name: Install pytest
run: pip install -r "${{ env.REQUIREMENTS_PATH }}"
- name: Test puppet deployment
id: pytest
continue-on-error: true
env:
PUPPET_RELEASE: "${{ matrix.PUPPET_RELEASE }}"
DEB_VERSION: "${{ needs.puppet-build-deb-local-package.outputs.version }}"
RPM_VERSION: "${{ needs.puppet-build-rpm-local-package.outputs.version }}"
run: |
distro="${{ matrix.DISTRO }}"
# Determine VERSION based on distro type
case "$distro" in
debian-*|ubuntu-*)
export VERSION="$DEB_VERSION"
echo "Using DEB version: $VERSION"
;;
amazonlinux-*|centos-*|opensuse-*|oraclelinux-*)
export VERSION="$RPM_VERSION"
echo "Using RPM version: $VERSION"
;;
*)
echo "Unknown distro: $distro"
exit 1
;;
esac
if [[ "${{ matrix.WITH_INSTRUMENTATION }}" = "true" ]]; then
tests="$distro and instrumentation"
else
tests="$distro and not instrumentation"
fi
python3 -u -m pytest -s --verbose -k "$tests" \
packaging/tests/deployments/puppet/puppet_test.py
# networking, running systemd in containers, etc., can be flaky
- name: Re-run failed tests
if: ${{ steps.pytest.outcome == 'failure' }}
env:
PUPPET_RELEASE: "${{ matrix.PUPPET_RELEASE }}"
DEB_VERSION: "${{ needs.puppet-build-deb-local-package.outputs.version }}"
RPM_VERSION: "${{ needs.puppet-build-rpm-local-package.outputs.version }}"
run: |
distro="${{ matrix.DISTRO }}"
# Determine VERSION based on distro type
case "$distro" in
debian-*|ubuntu-*)
export VERSION="$DEB_VERSION"
echo "Using DEB version: $VERSION"
;;
amazonlinux-*|centos-*|opensuse-*|oraclelinux-*)
export VERSION="$RPM_VERSION"
echo "Using RPM version: $VERSION"
;;
*)
echo "Unknown distro: $distro"
exit 1
;;
esac
if [[ "${{ matrix.WITH_INSTRUMENTATION }}" = "true" ]]; then
tests="$distro and instrumentation"
else
tests="$distro and not instrumentation"
fi
python3 -u -m pytest -s --verbose -k "$tests" \
--last-failed \
packaging/tests/deployments/puppet/puppet_test.py
# Use existing reusable workflows for building Windows artifacts
puppet-build-windows-binary:
uses: ./.github/workflows/reusable-compile.yml
with:
SYS_BINARY: binaries-windows_amd64
puppet-build-windows-agent-bundle:
uses: ./.github/workflows/reusable-agent-bundle-windows.yml
with:
ARCH: amd64
puppet-build-windows-msi-custom-actions:
uses: ./.github/workflows/reusable-msi-custom-actions.yml
# Use reusable workflow for MSI build
puppet-build-windows-msi-local-package:
uses: ./.github/workflows/reusable-msi-build.yml
needs:
- puppet-build-windows-binary
- puppet-build-windows-agent-bundle
- puppet-build-windows-msi-custom-actions
with:
ARCH: amd64
puppet-test-windows:
name: puppet-test-windows
runs-on: ${{ matrix.OS }}
timeout-minutes: 60
needs:
- puppet-lint
- puppet-build-windows-msi-local-package
strategy:
matrix:
OS: [ "windows-2022" ]
# EOL REFERENCE: https://endoflife.date/puppet
PUPPET_RELEASE: [ "8.10.0" ]
TEST_CASE: [ "default", "custom_vars" ]
fail-fast: false
steps:
- name: Check out the codebase.
uses: actions/checkout@v5
- name: Download MSI package artifacts
uses: actions/download-artifact@v7
with:
name: msi-build-amd64
path: ./dist
- name: Setup python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: ${{ env.REQUIREMENTS_PATH }}
- name: Install pytest
run: pip install -r "${{ env.REQUIREMENTS_PATH }}"
- name: Start local MSI server
shell: powershell
run: |
# Start Python HTTP server in background to serve MSI files from dist directory
Start-Process python -ArgumentList "-m http.server 8000 --directory dist" -WindowStyle Hidden
# Wait for server to be ready with retry logic
$maxAttempts = 10
$attempt = 1
$serverReady = $false
while ($attempt -le $maxAttempts) {
Write-Host "Checking if server is ready (attempt $attempt/$maxAttempts)..."
try {
$response = Invoke-WebRequest -Uri "http://localhost:8000/" -UseBasicParsing -TimeoutSec 2
if ($response.StatusCode -eq 200) {
Write-Host "Local MSI server started successfully"
$serverReady = $true
break
}
} catch {
Write-Host "Server not ready yet, waiting..."
}
Start-Sleep -Seconds 1
$attempt++
}
if (-not $serverReady) {
Write-Error "Failed to start local MSI server after $maxAttempts attempts"
exit 1
}
- name: Test puppet deployment
id: pytest
continue-on-error: true
env:
PUPPET_RELEASE: "${{ matrix.PUPPET_RELEASE }}"
WIN_COLLECTOR_VERSION: "${{ needs.puppet-build-windows-msi-local-package.outputs.version }}"
LOCAL_MSI_SERVER: "http://localhost:8000"
shell: pwsh
run: |
pytest -s --verbose -m windows `
-k ${{ matrix.TEST_CASE }} `
packaging/tests/deployments/puppet/puppet_test.py
- name: Re-run failed tests
if: ${{ steps.pytest.outcome == 'failure' }}
env:
PUPPET_RELEASE: "${{ matrix.PUPPET_RELEASE }}"
WIN_COLLECTOR_VERSION: "${{ needs.puppet-build-windows-msi-local-package.outputs.version }}"
LOCAL_MSI_SERVER: "http://localhost:8000"
shell: pwsh
run: |
pytest -s --verbose -m windows `
--last-failed `
-k ${{ matrix.TEST_CASE }} `
packaging/tests/deployments/puppet/puppet_test.py