mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
380 lines
16 KiB
YAML
380 lines
16 KiB
YAML
---
|
|
name: Test Artifact
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
distro-slug:
|
|
required: true
|
|
type: string
|
|
description: The OS slug to run tests against
|
|
nox-session:
|
|
required: true
|
|
type: string
|
|
description: The nox session to run
|
|
testrun:
|
|
required: true
|
|
type: string
|
|
description: JSON string containing information about what and how to run the test suite
|
|
salt-version:
|
|
type: string
|
|
required: true
|
|
description: The Salt version to set prior to running tests.
|
|
cache-prefix:
|
|
required: true
|
|
type: string
|
|
description: Seed used to invalidate caches
|
|
platform:
|
|
required: true
|
|
type: string
|
|
description: The platform being tested
|
|
arch:
|
|
required: true
|
|
type: string
|
|
description: The platform arch being tested
|
|
nox-version:
|
|
required: true
|
|
type: string
|
|
description: The nox version to install
|
|
python-version:
|
|
required: false
|
|
type: string
|
|
description: The python version to run tests with
|
|
default: "3.10"
|
|
package-name:
|
|
required: false
|
|
type: string
|
|
description: The onedir package name to use
|
|
default: salt
|
|
skip-code-coverage:
|
|
required: false
|
|
type: boolean
|
|
description: Skip code coverage
|
|
default: false
|
|
skip-junit-reports:
|
|
required: false
|
|
type: boolean
|
|
description: Skip Publishing JUnit Reports
|
|
default: false
|
|
|
|
|
|
env:
|
|
COLUMNS: 190
|
|
AWS_MAX_ATTEMPTS: "10"
|
|
AWS_RETRY_MODE: "adaptive"
|
|
PIP_INDEX_URL: https://pypi-proxy.saltstack.net/root/local/+simple/
|
|
PIP_EXTRA_INDEX_URL: https://pypi.org/simple
|
|
|
|
jobs:
|
|
|
|
generate-matrix:
|
|
name: Test Matrix
|
|
runs-on:
|
|
- self-hosted
|
|
- linux
|
|
- x86_64
|
|
outputs:
|
|
matrix-include: ${{ steps.generate-matrix.outputs.matrix }}
|
|
steps:
|
|
- name: Checkout Source Code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Python Tools Scripts
|
|
uses: ./.github/actions/setup-python-tools-scripts
|
|
|
|
- name: Generate Test Matrix
|
|
id: generate-matrix
|
|
run: |
|
|
TEST_MATRIX=$(tools ci matrix ${{ inputs.distro-slug }})
|
|
echo "$TEST_MATRIX"
|
|
echo "matrix=$TEST_MATRIX" >> "$GITHUB_OUTPUT"
|
|
|
|
test:
|
|
name: Test
|
|
runs-on:
|
|
- self-hosted
|
|
- linux
|
|
- bastion
|
|
timeout-minutes: 300 # 5 Hours - More than this and something is wrong
|
|
needs:
|
|
- generate-matrix
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include: ${{ fromJSON(needs.generate-matrix.outputs.matrix-include) }}
|
|
env:
|
|
SALT_TRANSPORT: ${{ matrix.transport }}
|
|
|
|
steps:
|
|
- name: Checkout Source Code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Salt Version
|
|
run: |
|
|
echo "${{ inputs.salt-version }}" > salt/_version.txt
|
|
|
|
- name: Download Onedir Tarball as an Artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: ${{ inputs.package-name }}-${{ inputs.salt-version }}-onedir-${{ inputs.platform }}-${{ inputs.arch }}.tar.xz
|
|
path: artifacts/
|
|
|
|
- name: Decompress Onedir Tarball
|
|
shell: bash
|
|
run: |
|
|
python3 -c "import os; os.makedirs('artifacts', exist_ok=True)"
|
|
cd artifacts
|
|
tar xvf ${{ inputs.package-name }}-${{ inputs.salt-version }}-onedir-${{ inputs.platform }}-${{ inputs.arch }}.tar.xz
|
|
|
|
- name: Download cached nox.${{ inputs.distro-slug }}.tar.* for session ${{ inputs.nox-session }}
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: nox.${{ inputs.distro-slug }}.tar.*
|
|
key: ${{ inputs.cache-prefix }}|testrun-deps|${{ inputs.arch }}|${{ inputs.distro-slug }}|${{ inputs.nox-session }}|${{ inputs.python-version }}|${{
|
|
hashFiles('requirements/**/*.txt', 'cicd/golden-images.json', 'noxfile.py')
|
|
}}
|
|
# If we get a cache miss here it means the dependencies step failed to save the cache
|
|
fail-on-cache-miss: true
|
|
|
|
- name: PyPi Proxy
|
|
run: |
|
|
sed -i '7s;^;--index-url=https://pypi-proxy.saltstack.net/root/local/+simple/ --extra-index-url=https://pypi.org/simple\n;' requirements/static/ci/*/*.txt
|
|
|
|
- name: Setup Python Tools Scripts
|
|
uses: ./.github/actions/setup-python-tools-scripts
|
|
|
|
- name: Download testrun-changed-files.txt
|
|
if: ${{ fromJSON(inputs.testrun)['type'] != 'full' }}
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: testrun-changed-files.txt
|
|
|
|
- name: Get Salt Project GitHub Actions Bot Environment
|
|
run: |
|
|
TOKEN=$(curl -sS -f -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 30")
|
|
SPB_ENVIRONMENT=$(curl -sS -f -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/tags/instance/spb:environment)
|
|
echo "SPB_ENVIRONMENT=$SPB_ENVIRONMENT" >> "$GITHUB_ENV"
|
|
|
|
- name: Start VM
|
|
id: spin-up-vm
|
|
env:
|
|
TESTS_CHUNK: ${{ matrix.tests-chunk }}
|
|
run: |
|
|
tools --timestamps vm create --environment "${SPB_ENVIRONMENT}" --retries=2 ${{ inputs.distro-slug }}
|
|
|
|
- name: List Free Space
|
|
run: |
|
|
tools --timestamps vm ssh ${{ inputs.distro-slug }} -- df -h || true
|
|
|
|
- name: Upload Checkout To VM
|
|
run: |
|
|
tools --timestamps vm rsync ${{ inputs.distro-slug }}
|
|
|
|
- name: Decompress .nox Directory
|
|
run: |
|
|
tools --timestamps vm decompress-dependencies ${{ inputs.distro-slug }}
|
|
|
|
- name: Show System Info & Test Plan
|
|
run: |
|
|
tools --timestamps --timeout-secs=1800 vm testplan --skip-requirements-install \
|
|
--nox-session=${{ inputs.nox-session }} ${{ inputs.distro-slug }} \
|
|
${{ matrix.tests-chunk }}
|
|
|
|
- name: Run Fast/Changed Tests
|
|
id: run-fast-changed-tests
|
|
if: ${{ fromJSON(inputs.testrun)['type'] != 'full' && fromJSON(inputs.testrun)['selected_tests']['fast'] == false }}
|
|
run: |
|
|
tools --timestamps --no-output-timeout-secs=1800 --timeout-secs=14400 vm test --skip-requirements-install \
|
|
--nox-session=${{ inputs.nox-session }} --rerun-failures -E SALT_TRANSPORT ${{ inputs.distro-slug }} \
|
|
${{ matrix.tests-chunk }} -- --suppress-no-test-exit-code \
|
|
--from-filenames=testrun-changed-files.txt
|
|
|
|
- name: Run Slow/Changed Tests
|
|
id: run-slow-changed-tests
|
|
if: ${{ fromJSON(inputs.testrun)['type'] != 'full' && fromJSON(inputs.testrun)['selected_tests']['slow'] == false }}
|
|
run: |
|
|
tools --timestamps --no-output-timeout-secs=1800 --timeout-secs=14400 vm test --skip-requirements-install \
|
|
--nox-session=${{ inputs.nox-session }} --rerun-failures -E SALT_TRANSPORT ${{ inputs.distro-slug }} \
|
|
${{ matrix.tests-chunk }} -- --no-fast-tests --slow-tests --suppress-no-test-exit-code \
|
|
--from-filenames=testrun-changed-files.txt
|
|
|
|
- name: Run Core/Changed Tests
|
|
id: run-core-changed-tests
|
|
if: ${{ fromJSON(inputs.testrun)['type'] != 'full' && fromJSON(inputs.testrun)['selected_tests']['core'] == false }}
|
|
run: |
|
|
tools --timestamps --no-output-timeout-secs=1800 --timeout-secs=14400 vm test --skip-requirements-install \
|
|
--nox-session=${{ inputs.nox-session }} --rerun-failures -E SALT_TRANSPORT ${{ inputs.distro-slug }} \
|
|
${{ matrix.tests-chunk }} -- --no-fast-tests --core-tests --suppress-no-test-exit-code \
|
|
--from-filenames=testrun-changed-files.txt
|
|
|
|
- name: Run Fast Tests
|
|
id: run-fast-tests
|
|
if: ${{ fromJSON(inputs.testrun)['type'] != 'full' && fromJSON(inputs.testrun)['selected_tests']['fast'] }}
|
|
run: |
|
|
tools --timestamps --no-output-timeout-secs=1800 --timeout-secs=14400 vm test --skip-requirements-install \
|
|
--nox-session=${{ inputs.nox-session }} --rerun-failures -E SALT_TRANSPORT ${{ (inputs.skip-code-coverage && matrix.tests-chunk != 'unit') && '--skip-code-coverage' || '' }} \
|
|
${{ inputs.distro-slug }} ${{ matrix.tests-chunk }}
|
|
|
|
- name: Run Slow Tests
|
|
id: run-slow-tests
|
|
if: ${{ fromJSON(inputs.testrun)['type'] != 'full' && fromJSON(inputs.testrun)['selected_tests']['slow'] }}
|
|
run: |
|
|
tools --timestamps --no-output-timeout-secs=1800 --timeout-secs=14400 vm test --skip-requirements-install \
|
|
--nox-session=${{ inputs.nox-session }} --rerun-failures -E SALT_TRANSPORT ${{ inputs.distro-slug }} \
|
|
${{ matrix.tests-chunk }} -- --no-fast-tests --slow-tests
|
|
|
|
- name: Run Core Tests
|
|
id: run-core-tests
|
|
if: ${{ fromJSON(inputs.testrun)['type'] != 'full' && fromJSON(inputs.testrun)['selected_tests']['core'] }}
|
|
run: |
|
|
tools --timestamps --no-output-timeout-secs=1800 --timeout-secs=14400 vm test --skip-requirements-install \
|
|
--nox-session=${{ inputs.nox-session }} --rerun-failures -E SALT_TRANSPORT ${{ inputs.distro-slug }} \
|
|
${{ matrix.tests-chunk }} -- --no-fast-tests --core-tests
|
|
|
|
- name: Run Flaky Tests
|
|
id: run-flaky-tests
|
|
if: ${{ fromJSON(inputs.testrun)['selected_tests']['flaky'] }}
|
|
run: |
|
|
tools --timestamps --no-output-timeout-secs=1800 --timeout-secs=14400 vm test --skip-requirements-install \
|
|
--nox-session=${{ inputs.nox-session }} --rerun-failures -E SALT_TRANSPORT ${{ inputs.distro-slug }} \
|
|
${{ matrix.tests-chunk }} -- --no-fast-tests --flaky-jail
|
|
|
|
- name: Run Full Tests
|
|
id: run-full-tests
|
|
if: ${{ fromJSON(inputs.testrun)['type'] == 'full' }}
|
|
run: |
|
|
tools --timestamps --no-output-timeout-secs=1800 --timeout-secs=14400 vm test --skip-requirements-install \
|
|
--nox-session=${{ inputs.nox-session }} --rerun-failures -E SALT_TRANSPORT ${{ (inputs.skip-code-coverage && matrix.tests-chunk != 'unit') && '--skip-code-coverage' || '' }} \
|
|
${{ inputs.distro-slug }} ${{ matrix.tests-chunk }} -- --slow-tests --core-tests
|
|
|
|
- name: Combine Coverage Reports
|
|
if: always() && inputs.skip-code-coverage == false && steps.spin-up-vm.outcome == 'success' && job.status != 'cancelled'
|
|
run: |
|
|
tools --timestamps vm combine-coverage ${{ inputs.distro-slug }}
|
|
|
|
- name: Create XML Coverage Reports
|
|
if: always() && inputs.skip-code-coverage == false && steps.spin-up-vm.outcome == 'success' && job.status != 'cancelled'
|
|
run: |
|
|
tools --timestamps vm create-xml-coverage-reports ${{ inputs.distro-slug }}
|
|
|
|
- name: Download Test Run Artifacts
|
|
id: download-artifacts-from-vm
|
|
if: always() && steps.spin-up-vm.outcome == 'success' && job.status != 'cancelled'
|
|
run: |
|
|
tools --timestamps vm download-artifacts ${{ inputs.distro-slug }}
|
|
# Delete the salt onedir, we won't need it anymore and it will prevent
|
|
# from it showing in the tree command below
|
|
rm -rf artifacts/salt*
|
|
tree -a artifacts
|
|
if [ "${{ inputs.skip-code-coverage }}" != "true" ]; then
|
|
mv artifacts/coverage/.coverage artifacts/coverage/.coverage.${{ inputs.distro-slug }}.${{ inputs.nox-session }}.${{ matrix.transport }}.${{ matrix.tests-chunk }}
|
|
echo "COVERAGE_FILE=artifacts/coverage/.coverage.${{ inputs.distro-slug }}.${{ inputs.nox-session }}.${{ matrix.transport }}.${{ matrix.tests-chunk }}" >> GITHUB_ENV
|
|
fi
|
|
|
|
- name: Destroy VM
|
|
if: always()
|
|
run: |
|
|
tools --timestamps vm destroy --no-wait ${{ inputs.distro-slug }} || true
|
|
|
|
- name: Upload Code Coverage Test Run Artifacts
|
|
if: always() && inputs.skip-code-coverage == false && steps.download-artifacts-from-vm.outcome == 'success' && job.status != 'cancelled'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: testrun-coverage-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }}
|
|
path: |
|
|
artifacts/coverage/
|
|
|
|
- name: Upload All Code Coverage Test Run Artifacts
|
|
if: always() && inputs.skip-code-coverage == false && steps.download-artifacts-from-vm.outcome == 'success' && job.status != 'cancelled'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: all-testrun-coverage-artifacts
|
|
path: |
|
|
artifacts/coverage/
|
|
|
|
- name: Upload JUnit XML Test Run Artifacts
|
|
if: always() && steps.download-artifacts-from-vm.outcome == 'success' && job.status != 'cancelled'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: testrun-junit-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }}-${{ matrix.transport }}
|
|
path: |
|
|
artifacts/xml-unittests-output/
|
|
|
|
- name: Upload Test Run Log Artifacts
|
|
if: always() && steps.download-artifacts-from-vm.outcome == 'success' && job.status != 'cancelled'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: testrun-log-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }}-${{ matrix.transport }}
|
|
path: |
|
|
artifacts/logs
|
|
|
|
- name: Publish Test Report
|
|
uses: mikepenz/action-junit-report@v3
|
|
# always run even if the previous steps fails
|
|
if: always() && inputs.skip-junit-reports == false
|
|
with:
|
|
check_name: Test Results(${{ inputs.distro-slug }}, transport=${{ matrix.transport }}, tests-chunk=${{ matrix.tests-chunk }})
|
|
report_paths: 'artifacts/xml-unittests-output/*.xml'
|
|
annotate_only: true
|
|
|
|
|
|
report:
|
|
name: Test Reports
|
|
if: always() && inputs.skip-code-coverage == false && needs.test.result != 'cancelled' && needs.test.result != 'skipped'
|
|
runs-on:
|
|
- self-hosted
|
|
- linux
|
|
- x86_64
|
|
needs:
|
|
- test
|
|
|
|
steps:
|
|
- name: Checkout Source Code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Download Code Coverage Test Run Artifacts
|
|
uses: actions/download-artifact@v3
|
|
if: ${{ inputs.skip-code-coverage == false }}
|
|
id: download-coverage-artifacts
|
|
with:
|
|
name: testrun-coverage-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }}
|
|
path: artifacts/coverage/
|
|
|
|
- name: Show Downloaded Test Run Artifacts
|
|
run: |
|
|
tree -a artifacts
|
|
|
|
- name: Install Nox
|
|
run: |
|
|
python3 -m pip install 'nox==${{ inputs.nox-version }}'
|
|
|
|
- name: Combine Code Coverage
|
|
if: ${{ inputs.skip-code-coverage == false }}
|
|
continue-on-error: true
|
|
run: |
|
|
nox --force-color -e combine-coverage
|
|
|
|
- name: Upload Code Coverage DB
|
|
if: always() && inputs.skip-code-coverage == false && steps.download-coverage-artifacts.outcome == 'success'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: code-coverage
|
|
path: artifacts/coverage
|
|
|
|
- name: Report Salt Code Coverage
|
|
if: always() && inputs.skip-code-coverage == false && steps.download-coverage-artifacts.outcome == 'success'
|
|
continue-on-error: true
|
|
run: |
|
|
nox --force-color -e report-coverage -- salt
|
|
|
|
- name: Report Tests Code Coverage
|
|
if: always() && inputs.skip-code-coverage == false && steps.download-coverage-artifacts.outcome == 'success'
|
|
continue-on-error: true
|
|
run: |
|
|
nox --force-color -e report-coverage -- tests
|
|
|
|
- name: Report Combined Code Coverage
|
|
if: always() && inputs.skip-code-coverage == false && steps.download-coverage-artifacts.outcome == 'success'
|
|
continue-on-error: true
|
|
run: |
|
|
nox --force-color -e report-coverage
|