name: unit tests on: pull_request: jobs: # Run unit tests with different configurations on linux ubuntu: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest] python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] on_develop: - ${{ github.ref == 'refs/heads/develop' }} include: - python-version: '3.7' os: ubuntu-22.04 on_develop: ${{ github.ref == 'refs/heads/develop' }} exclude: - python-version: '3.8' os: ubuntu-latest on_develop: false - python-version: '3.9' os: ubuntu-latest on_develop: false - python-version: '3.10' os: ubuntu-latest on_develop: false - python-version: '3.11' os: ubuntu-latest on_develop: false steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: fetch-depth: 0 - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b with: python-version: ${{ matrix.python-version }} - name: Install System packages run: | sudo apt-get -y update # Needed for unit tests sudo apt-get -y install \ coreutils cvs gfortran graphviz gnupg2 mercurial ninja-build \ cmake bison libbison-dev subversion # On ubuntu 24.04, kcov was removed. It may come back in some future Ubuntu - name: Set up Homebrew id: set-up-homebrew uses: Homebrew/actions/setup-homebrew@40e9946c182a64b3db1bf51be0dcb915f7802aa9 - name: Install kcov with brew run: "brew install kcov" - name: Install Python packages run: | pip install --upgrade pip setuptools pytest pytest-xdist pytest-cov pip install --upgrade flake8 "isort>=4.3.5" "mypy>=0.900" "click" "black" - name: Setup git configuration run: | # Need this for the git tests to succeed. git --version . .github/workflows/bin/setup_git.sh - name: Bootstrap clingo if: ${{ matrix.concretizer == 'clingo' }} env: SPACK_PYTHON: python run: | . share/spack/setup-env.sh spack bootstrap disable spack-install spack bootstrap now spack -v solve zlib - name: Run unit tests env: SPACK_PYTHON: python SPACK_TEST_PARALLEL: 2 COVERAGE: true COVERAGE_FILE: coverage/.coverage-${{ matrix.os }}-python${{ matrix.python-version }} UNIT_TEST_COVERAGE: ${{ matrix.python-version == '3.11' }} run: | share/spack/qa/run-unit-tests - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b with: name: coverage-${{ matrix.os }}-python${{ matrix.python-version }} path: coverage include-hidden-files: true - name: Setup tmate session if: ${{ failure() }} uses: mxschmitt/action-tmate@v3 windows: defaults: run: shell: powershell Invoke-Expression -Command "./share/spack/qa/windows_test_setup.ps1"; {0} runs-on: windows-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: fetch-depth: 0 - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b with: python-version: 3.9 - name: Install Python packages run: | python -m pip install --upgrade pip pywin32 setuptools pytest-cov clingo - name: Create local develop run: | ./.github/workflows/bin/setup_git.ps1 - name: Unit Test env: COVERAGE_FILE: coverage/.coverage-windows run: | spack unit-test -x --verbose --cov --cov-config=pyproject.toml ./share/spack/qa/validate_last_exit.ps1 - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b with: name: coverage-windows path: coverage include-hidden-files: true - name: Setup tmate session if: ${{ failure() }} uses: mxschmitt/action-tmate@v3