Add MacOS 12 tests

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2022-10-14 12:05:36 +01:00 committed by Megan Wilhite
parent 49447f1c53
commit 45f93ad6a8
2 changed files with 286 additions and 0 deletions

View file

@ -111,6 +111,16 @@ jobs:
nox-session: ci-test-3
changed-files: ${{ needs.get-changed-files.outputs.changed-files }}
macos-12:
name: MacOS 12
needs:
- get-changed-files
uses: ./.github/workflows/test-action-macos.yml
with:
distro-slug: macos-12
nox-session: ci-test-3
changed-files: ${{ needs.get-changed-files.outputs.changed-files }}
set-pipeline-exit-status:
# This step is just so we can make github require this step, to pass checks
@ -126,6 +136,7 @@ jobs:
- debian-11-arm64
- ubuntu-2204
- windows-2019
- macos-12
steps:
- name: Download Exit Status Files
if: always()

275
.github/workflows/test-action-macos.yml vendored Normal file
View file

@ -0,0 +1,275 @@
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
changed-files:
required: true
type: string
description: JSON string containing information about changed files
python-version:
required: false
type: string
description: The python version to run tests with
default: 3.9
env:
NOX_VERSION: "2022.8.7"
COLUMNS: 160
PIP_INDEX_URL: "https://pypi-proxy.saltstack.net/root/local/+simple/"
PIP_EXTRA_INDEX_URL: "https://pypi.org/simple"
jobs:
dependencies:
name: Setup Test Dependencies
runs-on: ${{ inputs.distro-slug }}
timeout-minutes: 90
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
- name: Cache nox.${{ inputs.distro-slug }}.tar.* for session ${{ inputs.nox-session }}
id: nox-dependencies-cache
uses: actions/cache@v3
with:
path: nox.${{ inputs.distro-slug }}.tar.*
key: testrun-deps|${{ inputs.distro-slug }}|${{ inputs.nox-session }}|${{ inputs.python-version }}|${{ hashFiles('requirements/**/*.txt') }}
# Skip jobs if nox.*.tar.* is already cached
- name: Set up Python ${{ inputs.python-version }}
if: steps.nox-dependencies-cache.outputs.cache-hit != 'true'
uses: actions/setup-python@v4
with:
python-version: "${{ inputs.python-version }}"
- name: Install System Dependencies
if: steps.nox-dependencies-cache.outputs.cache-hit != 'true'
run: |
brew install openssl@3
- name: Install Nox
if: steps.nox-dependencies-cache.outputs.cache-hit != 'true'
run: |
python3 -m pip install 'nox==${{ env.NOX_VERSION }}'
- name: Install Dependencies
if: steps.nox-dependencies-cache.outputs.cache-hit != 'true'
env:
PRINT_TEST_SELECTION: "0"
PRINT_SYSTEM_INFO: "0"
run: |
export PYCURL_SSL_LIBRARY=openssl
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
nox --install-only -e ${{ inputs.nox-session }}
- name: Compress .nox Directory
if: steps.nox-dependencies-cache.outputs.cache-hit != 'true'
run: |
nox -e compress-dependencies -- ${{ inputs.distro-slug }}
- name: Set Exit Status
if: always()
run: |
mkdir exitstatus
echo "${{ job.status }}" > exitstatus/${{ github.job }}-${{ inputs.distro-slug }}-deps
- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v3
with:
name: exitstatus
path: exitstatus
if-no-files-found: error
test:
name: Test
runs-on: ${{ inputs.distro-slug }}
timeout-minutes: 600 # 10 Hours
needs:
- dependencies
strategy:
fail-fast: false
matrix:
tests-chunk:
- unit
- functional
- integration
- scenarios
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
- name: Install System Dependencies
if: steps.nox-dependencies-cache.outputs.cache-hit != 'true'
run: |
brew install tree
- 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: testrun-deps|${{ inputs.distro-slug }}|${{ inputs.nox-session }}|${{ inputs.python-version }}|${{ hashFiles('requirements/**/*.txt') }}
- 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==${{ env.NOX_VERSION }}'
- name: Decompress .nox Directory
run: |
nox -e decompress-dependencies -- ${{ inputs.distro-slug }}
- name: Run Tests
id: run-tests
env:
SKIP_REQUIREMENTS_INSTALL: "1"
PRINT_TEST_SELECTION: "0"
PRINT_SYSTEM_INFO: "0"
RERUN_FAILURES: "1"
run: |
nox -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }}
- name: Combine Coverage Reports
if: always() && steps.run-tests.conclusion != 'skipped'
run: |
nox -e combine-coverage
- name: Prepare Test Run Artifacts
id: download-artifacts-from-vm
if: always() && steps.run-tests.conclusion != 'skipped'
run: |
tree -a artifacts
mv artifacts/coverage/.coverage artifacts/coverage/.coverage.${{ inputs.distro-slug }}.${{ inputs.nox-session }}.${{ matrix.tests-chunk }}
echo "COVERAGE_FILE=artifacts/coverage/.coverage.${{ inputs.distro-slug }}.${{ inputs.nox-session }}.${{ matrix.tests-chunk }}" >> GITHUB_ENV
- name: Upload Test Run Artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: testrun-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }}
path: artifacts
# - name: Publish Test Report
# uses: mikepenz/action-junit-report@v3
# if: always() && steps.download-artifacts-from-vm.conclusion == 'success'
# with:
# check_name: Test Results(${{ inputs.distro-slug }} ${{ matrix.tests-chunk }})
# report_paths: 'artifacts/xml-unittests-output/*.xml'
- name: Report Salt Code Coverage(${{ matrix.tests-chunk }})
if: always()
run: |
nox --force-color -e report-coverage -- salt
- name: Report Tests Code Coverage(${{ matrix.tests-chunk }})
if: always()
run: |
nox --force-color -e report-coverage -- tests
- name: Report Combined Code Coverage(${{ matrix.tests-chunk }})
if: always()
run: |
nox --force-color -e report-coverage
- name: Set Exit Status
if: always()
run: |
mkdir exitstatus
echo "${{ job.status }}" > exitstatus/${{ github.job }}-${{ inputs.distro-slug }}-${{ inputs.nox-session }}-${{ matrix.tests-chunk }}-tests
- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v3
with:
name: exitstatus
path: exitstatus
if-no-files-found: error
report:
name: Reports for ${{ inputs.distro-slug }}
runs-on: ubuntu-latest
needs: test
if: always() && needs.test.result != 'cancelled' && needs.test.result != 'skipped'
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
- name: Download Test Run Artifacts
id: download-test-run-artifacts
uses: actions/download-artifact@v3
with:
name: testrun-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }}
path: artifacts
- name: Show Test Run Artifacts
if: always() && steps.download-test-run-artifacts.conclusion == 'success'
run: |
tree -a artifacts
- name: Upload Code Coverage DB
if: always() && steps.download-test-run-artifacts.conclusion == 'success'
uses: actions/upload-artifact@v3
with:
name: code-coverage
path: artifacts/coverage
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Nox
run: |
python3 -m pip install 'nox==${{ env.NOX_VERSION }}'
- name: Report Salt Code Coverage
run: |
nox --force-color -e report-coverage -- salt
- name: Report Tests Code Coverage
run: |
nox --force-color -e report-coverage -- tests
- name: Report Combined Code Coverage
run: |
nox --force-color -e report-coverage
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
# always run even if the previous steps fails
if: always() && steps.download-test-run-artifacts.conclusion == 'success'
with:
check_name: Overall Test Results(${{ inputs.distro-slug }})
report_paths: 'artifacts/xml-unittests-output/*.xml'
- name: Set Exit Status
if: always()
run: |
mkdir exitstatus
echo "${{ job.status }}" > exitstatus/${{ github.job }}-${{ inputs.distro-slug }}-${{ inputs.nox-session }}-report
- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v3
with:
name: exitstatus
path: exitstatus
if-no-files-found: error