name: Test Download Packages on: workflow_call: inputs: distro-slug: required: true type: string description: The OS slug to run tests against platform: required: true type: string description: The platform being tested arch: required: true type: string description: The platform arch being tested salt-version: type: string required: true description: The Salt version of the packages to install and test cache-prefix: required: true type: string description: Seed used to invalidate caches environment: required: true type: string description: The environment to run tests against latest-release: required: true type: string description: The latest salt release pkg-type: required: true type: string description: The type of artifact to download 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.11" 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 nox-session: required: false type: string description: The nox session to run default: ci-test-onedir env: COLUMNS: 190 PIP_INDEX_URL: https://pypi-proxy.saltstack.net/root/local/+simple/ PIP_EXTRA_INDEX_URL: https://pypi.org/simple jobs: test: name: Test Pkg Download runs-on: ${{ inputs.distro-slug }} environment: ${{ inputs.environment }} timeout-minutes: 120 # 2 Hours - More than this and something is wrong steps: - name: "Throttle Builds" shell: bash run: | t=$(python3 -c 'import random, sys; sys.stdout.write(str(random.randint(1, 15)))'); echo "Sleeping $t seconds"; sleep "$t" - name: Checkout Source Code uses: actions/checkout@v4 - 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: Install System Dependencies run: | brew install tree - 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: Set up Python ${{ inputs.python-version }} uses: actions/setup-python@v4 with: python-version: "${{ inputs.python-version }}" update-environment: true - name: Install Nox run: | python3 -m pip install 'nox==${{ inputs.nox-version }}' - 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: Decompress .nox Directory run: | nox --force-color -e decompress-dependencies -- ${{ inputs.distro-slug }} - name: Show System Info & Test Plan env: SALT_RELEASE: "${{ inputs.salt-version }}" SKIP_REQUIREMENTS_INSTALL: "1" PRINT_TEST_SELECTION: "1" PRINT_TEST_PLAN_ONLY: "1" PRINT_SYSTEM_INFO: "1" GITHUB_ACTIONS_PIPELINE: "1" SKIP_INITIAL_GH_ACTIONS_FAILURES: "1" SKIP_CODE_COVERAGE: "${{ inputs.skip-code-coverage && '1' || '0' }}" LATEST_SALT_RELEASE: "${{ inputs.latest-release }}" DOWNLOAD_TEST_PACKAGE_TYPE: ${{ inputs.pkg-type }} run: | sudo -E nox --force-color -e ${{ inputs.nox-session }}-pkgs -- download-pkgs - name: Run Package Download Tests env: SKIP_REQUIREMENTS_INSTALL: "1" PRINT_TEST_SELECTION: "0" PRINT_TEST_PLAN_ONLY: "0" PRINT_SYSTEM_INFO: "0" RERUN_FAILURES: "1" GITHUB_ACTIONS_PIPELINE: "1" SKIP_INITIAL_GH_ACTIONS_FAILURES: "1" SKIP_CODE_COVERAGE: "${{ inputs.skip-code-coverage && '1' || '0' }}" COVERAGE_CONTEXT: ${{ inputs.distro-slug }} SALT_RELEASE: "${{ inputs.salt-version }}" SALT_REPO_ARCH: ${{ inputs.arch }} LATEST_SALT_RELEASE: "${{ inputs.latest-release }}" SALT_REPO_TYPE: ${{ inputs.environment }} SALT_REPO_USER: ${{ secrets.SALT_REPO_USER }} SALT_REPO_PASS: ${{ secrets.SALT_REPO_PASS }} SALT_REPO_DOMAIN_RELEASE: ${{ vars.SALT_REPO_DOMAIN_RELEASE || 'repo.saltproject.io' }} SALT_REPO_DOMAIN_STAGING: ${{ vars.SALT_REPO_DOMAIN_STAGING || 'staging.repo.saltproject.io' }} DOWNLOAD_TEST_PACKAGE_TYPE: ${{ inputs.pkg-type }} run: | sudo -E nox --force-color -e ${{ inputs.nox-session }}-pkgs -- download-pkgs - name: Fix file ownership run: | sudo chown -R "$(id -un)" . - name: Combine Coverage Reports if: always() && inputs.skip-code-coverage == false && job.status != 'cancelled' run: | nox --force-color -e combine-coverage - name: Create XML Coverage Reports if: always() && inputs.skip-code-coverage == false && job.status != 'cancelled' run: | tools --timestamps vm create-xml-coverage-reports ${{ inputs.distro-slug }} - name: Prepare Test Run Artifacts id: download-artifacts-from-vm if: always() && job.status != 'cancelled' run: | # 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 - name: Upload Test Run Artifacts if: always() && job.status != 'cancelled' uses: actions/upload-artifact@v3 with: name: pkg-testrun-artifacts-${{ inputs.distro-slug }}-${{ inputs.arch }} path: | artifacts !artifacts/salt/* !artifacts/salt-*.tar.* report: name: Test Pkg Download Reports runs-on: ${{ github.event.repository.private && fromJSON('["self-hosted", "linux", "x86_64"]') || 'ubuntu-latest' }} environment: ${{ inputs.environment }} if: always() && needs.test.result != 'cancelled' && needs.test.result != 'skipped' needs: - test steps: - name: Checkout Source Code uses: actions/checkout@v4 - name: Download Test Run Artifacts id: download-test-run-artifacts uses: actions/download-artifact@v3 with: name: pkg-testrun-artifacts-${{ inputs.distro-slug }}-${{ inputs.arch }} path: artifacts - name: Show Test Run Artifacts if: always() && steps.download-test-run-artifacts.outcome == 'success' run: | tree -a artifacts - name: Set up Python ${{ inputs.python-version }} uses: actions/setup-python@v4 with: python-version: "${{ inputs.python-version }}" - name: Install Nox run: | python3 -m pip install 'nox==${{ inputs.nox-version }}' - name: Publish Test Report uses: mikepenz/action-junit-report@v3 # always run even if the previous steps fails if: always() && github.event_name == 'push' && steps.download-test-run-artifacts.outcome == 'success' with: check_name: Overall Test Results(${{ inputs.distro-slug }} ${{ inputs.arch }}) report_paths: 'artifacts/xml-unittests-output/*.xml' annotate_only: true