Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync tests.yml with conda #5119

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 81 additions & 82 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# this is the sibling workflow to tests-skip.yml, it is required to work around
# the skipped but required checks issue:
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
name: Tests

on:
Expand Down Expand Up @@ -36,15 +33,17 @@ jobs:
changes:
runs-on: ubuntu-latest
permissions:
# necessary to detect changes
# https://github.com/dorny/paths-filter#supported-workflows
pull-requests: read
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: actions/checkout@v3
# dorny/paths-filter needs git clone for non-PR events
# https://github.com/marketplace/actions/paths-changes-filter#supported-workflows
# https://github.com/dorny/paths-filter#supported-workflows
if: github.event_name != 'pull_request'
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50
- uses: dorny/paths-filter@v2.11.1
id: filter
with:
filters: |
Expand All @@ -55,32 +54,21 @@ jobs:
- 'recipe/**'
- '.github/workflows/tests.yml'

# linux test suite
linux:
# windows test suite
windows:
# only run test suite if there are code changes
needs: changes
if: github.event_name == 'schedule' || needs.changes.outputs.code == 'true'

runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
# test all lower versions (w/ stable conda) and upper version (w/ canary conda)
python-version: ['3.9', '3.10']
# test lower version (w/ stable conda) and upper version (w/ canary conda)
python-version: ['3.8']
conda-version: [release]
test-type: [serial, parallel]
include:
# minimum Python/conda combo
- python-version: '3.8'
conda-version: 22.11.0
test-type: serial
- python-version: '3.8'
conda-version: 22.11.0
test-type: parallel
# maximum Python/conda combo
- python-version: '3.11'
conda-version: canary
test-type: serial
Expand All @@ -89,10 +77,9 @@ jobs:
test-type: parallel
env:
CONDA_CHANNEL_LABEL: ${{ matrix.conda-version == 'canary' && 'conda-canary/label/dev' || 'defaults' }}
CONDA_VERSION: ${{ contains('canary,release', matrix.conda-version) && 'conda' || format('conda={0}', matrix.conda-version) }}
REPLAY_NAME: Linux-${{ matrix.conda-version }}-Py${{ matrix.python-version }}
REPLAY_DIR: ${{ github.workspace }}/pytest-replay
PYTEST_MARKER: ${{ matrix.test-type == 'serial' && 'serial' || 'not serial' }}
REPLAY_NAME: Win-${{ matrix.conda-version }}-Py${{ matrix.python-version }}
REPLAY_DIR: ${{ github.workspace }}\pytest-replay
PYTEST_MARKER: ${{ matrix.test-type == 'serial' && 'serial' || 'not serial and not slow' }}
PYTEST_NUMPROCESSES: ${{ matrix.test-type == 'serial' && 0 || 'auto' }}

steps:
Expand All @@ -114,17 +101,20 @@ jobs:
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v2
with:
condarc-file: ./ci/github/.condarc
condarc-file: .\ci\github\.condarc
python-version: ${{ matrix.python-version }}
run-post: false # skip post cleanup

- name: Setup environment
shell: cmd /C CALL {0}
run: |
conda install -q -y -c defaults \
--file ./tests/requirements.txt \
--file ./tests/requirements-linux.txt \
${{ env.CONDA_CHANNEL_LABEL }}::${{ env.CONDA_VERSION }}
pip install -e . --no-deps
@echo on
CALL choco install visualstudio2017-workload-vctools || exit 1
CALL conda install -q -y -c defaults ^
--file .\tests\requirements.txt ^
--file .\tests\requirements-windows.txt ^
${{ env.CONDA_CHANNEL_LABEL }}::conda || exit 1
CALL pip install -e . --no-deps || exit 1

- name: Show info
run: |
Expand All @@ -133,46 +123,57 @@ jobs:

- name: Run tests
run: |
pytest \
--color=yes \
-v \
-n "${{ env.PYTEST_NUMPROCESSES }}" \
--basetemp "${{ runner.temp }}/${{ matrix.test-type }}" \
--cov conda_build \
--cov-append \
--cov-branch \
--cov-report xml \
--replay-record-dir="${{ env.REPLAY_DIR }}" \
--replay-base-name="${{ env.REPLAY_NAME }}" \
-m "${{ env.PYTEST_MARKER }}" \
./tests
pytest `
--color=yes `
-v `
-n "${{ env.PYTEST_NUMPROCESSES }}" `
--basetemp "${{ runner.temp }}\${{ matrix.test-type}}" `
--cov conda_build `
--cov-append `
--cov-branch `
--cov-report xml `
--replay-record-dir="${{ env.REPLAY_DIR }}" `
--replay-base-name="${{ env.REPLAY_NAME }}" `
-m "${{ env.PYTEST_MARKER }}" `
.\tests

- uses: codecov/codecov-action@v3
with:
flags: ${{ matrix.test-type }},${{ matrix.python-version }},linux-64
flags: ${{ matrix.test-type }},${{ matrix.python-version }},win-64

- name: Upload Pytest Replay
if: '!cancelled()'
uses: actions/upload-artifact@v3
with:
name: ${{ env.REPLAY_NAME }}-${{ matrix.test-type }}
path: ${{ env.REPLAY_DIR }}
name: ${{ env.REPLAY_NAME }}-${{ matrix.test-type }}

# windows test suite
windows:
# linux test suite
linux:
# only run test suite if there are code changes
needs: changes
if: github.event_name == 'schedule' || needs.changes.outputs.code == 'true'

runs-on: windows-2019
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
# test lower version (w/ stable conda) and upper version (w/ canary conda)
python-version: ['3.8']
# test all lower versions (w/ stable conda) and upper version (w/ canary conda)
python-version: ['3.9', '3.10']
conda-version: [release]
test-type: [serial, parallel]
include:
# minimum Python/conda combo
- python-version: '3.8'
conda-version: 22.11.0
test-type: serial
- python-version: '3.8'
conda-version: 22.11.0
test-type: parallel
# maximum Python/conda combo
- python-version: '3.11'
conda-version: canary
test-type: serial
Expand All @@ -181,9 +182,10 @@ jobs:
test-type: parallel
env:
CONDA_CHANNEL_LABEL: ${{ matrix.conda-version == 'canary' && 'conda-canary/label/dev' || 'defaults' }}
REPLAY_NAME: Win-${{ matrix.conda-version }}-Py${{ matrix.python-version }}
REPLAY_DIR: ${{ github.workspace }}\pytest-replay
PYTEST_MARKER: ${{ matrix.test-type == 'serial' && 'serial' || 'not serial and not slow' }}
CONDA_VERSION: ${{ contains('canary,release', matrix.conda-version) && 'conda' || format('conda={0}', matrix.conda-version) }}
REPLAY_NAME: Linux-${{ matrix.conda-version }}-Py${{ matrix.python-version }}
REPLAY_DIR: ${{ github.workspace }}/pytest-replay
PYTEST_MARKER: ${{ matrix.test-type == 'serial' && 'serial' || 'not serial' }}
PYTEST_NUMPROCESSES: ${{ matrix.test-type == 'serial' && 0 || 'auto' }}

steps:
Expand All @@ -205,20 +207,17 @@ jobs:
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v2
with:
condarc-file: .\ci\github\.condarc
condarc-file: ./ci/github/.condarc
python-version: ${{ matrix.python-version }}
run-post: false # skip post cleanup

- name: Setup environment
shell: cmd /C CALL {0}
run: |
@echo on
CALL choco install visualstudio2017-workload-vctools || exit 1
CALL conda install -q -y -c defaults ^
--file .\tests\requirements.txt ^
--file .\tests\requirements-windows.txt ^
${{ env.CONDA_CHANNEL_LABEL }}::conda || exit 1
CALL pip install -e . --no-deps || exit 1
conda install -q -y -c defaults \
--file ./tests/requirements.txt \
--file ./tests/requirements-linux.txt \
${{ env.CONDA_CHANNEL_LABEL }}::${{ env.CONDA_VERSION }}
pip install -e . --no-deps

- name: Show info
run: |
Expand All @@ -227,30 +226,30 @@ jobs:

- name: Run tests
run: |
pytest `
--color=yes `
-v `
-n "${{ env.PYTEST_NUMPROCESSES }}" `
--basetemp "${{ runner.temp }}\${{ matrix.test-type}}" `
--cov conda_build `
--cov-append `
--cov-branch `
--cov-report xml `
--replay-record-dir="${{ env.REPLAY_DIR }}" `
--replay-base-name="${{ env.REPLAY_NAME }}" `
-m "${{ env.PYTEST_MARKER }}" `
.\tests
pytest \
--color=yes \
-v \
-n "${{ env.PYTEST_NUMPROCESSES }}" \
--basetemp "${{ runner.temp }}/${{ matrix.test-type }}" \
--cov conda_build \
--cov-append \
--cov-branch \
--cov-report xml \
--replay-record-dir="${{ env.REPLAY_DIR }}" \
--replay-base-name="${{ env.REPLAY_NAME }}" \
-m "${{ env.PYTEST_MARKER }}" \
./tests

- uses: codecov/codecov-action@v3
with:
flags: ${{ matrix.test-type }},${{ matrix.python-version }},win-64
flags: ${{ matrix.test-type }},${{ matrix.python-version }},linux-64

- name: Upload Pytest Replay
if: '!cancelled()'
uses: actions/upload-artifact@v3
with:
path: ${{ env.REPLAY_DIR }}
name: ${{ env.REPLAY_NAME }}-${{ matrix.test-type }}
path: ${{ env.REPLAY_DIR }}

# macos test suite
macos:
Expand Down Expand Up @@ -350,7 +349,7 @@ jobs:
# aggregate and upload
aggregate:
# only aggregate test suite if there are code changes
needs: [changes, linux, windows, macos]
needs: [changes, windows, linux, macos]
if: >-
!cancelled()
&& (
Expand All @@ -365,7 +364,7 @@ jobs:

- name: Upload combined test results
# provides one downloadable archive of all .coverage/test-report.xml files
# of all matrix runs for further analysis.
# of all matrix runs for further analysis
uses: actions/upload-artifact@v3
with:
name: test-results-${{ github.sha }}-all
Expand All @@ -380,13 +379,13 @@ jobs:
# required check
analyze:
name: Analyze results
needs: [linux, windows, macos, aggregate]
needs: [windows, linux, macos, aggregate]
if: '!cancelled()'

runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
uses: re-actors/alls-green@v1.2.2
with:
allowed-skips: ${{ toJSON(needs) }}
jobs: ${{ toJSON(needs) }}
Expand Down