Skip to content

馃攧 synced file(s) with conda/infrastructure #5751

馃攧 synced file(s) with conda/infrastructure

馃攧 synced file(s) with conda/infrastructure #5751

Workflow file for this run

name: Tests
on:
# https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#push
push:
branches:
- main
- feature/**
- '[0-9].*.x' # e.g., 4.14.x
- '[0-9][0-9].*.x' # e.g., 23.3.x
# https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request
pull_request:
# https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_dispatch
workflow_dispatch:
concurrency:
# Concurrency group that uses the workflow name and PR number if available
# or commit SHA as a fallback. If a new build is triggered under that
# concurrency group while a previous build is running it will be canceled.
# Repeated pushes to a PR will cancel all previous builds, while multiple
# merges to main will not cancel.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
# https://conda.github.io/conda-libmamba-solver/user-guide/configuration/#advanced-options
CONDA_LIBMAMBA_SOLVER_NO_CHANNELS_FROM_INSTALLED: true
jobs:
# detect whether any code changes are included in this PR
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:
- name: Checkout Source
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
# dorny/paths-filter needs git clone for non-PR events
# https://github.com/dorny/paths-filter#supported-workflows
if: github.event_name != 'pull_request'
- name: Filter Changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
id: filter
with:
filters: |
code:
- 'conda/**'
- 'conda_env/**'
- 'tests/**'
- '*.py'
- 'recipe/**'
- '.github/workflows/tests.yml'
# windows test suite
windows:
# only run test suite if there are code changes
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
# test lower version (w/ defaults) and upper version (w/ defaults and conda-forge)
python-version: ['3.8', '3.12']
default-channel: [defaults, conda-forge]
test-type: [unit, integration]
test-group: [1, 2, 3]
exclude:
- default-channel: conda-forge
python-version: '3.8'
- test-type: unit
test-group: 3
env:
ErrorActionPreference: Stop # powershell exit immediately on error
PYTEST_MARKER: ${{ matrix.test-type == 'unit' && 'not integration' || 'integration' }}
PYTEST_SPLITS: ${{ matrix.test-type == 'unit' && '2' || '3' }}
REQUIREMENTS_TRUSTSTORE: ${{ contains('3.10|3.11|3.12', matrix.python-version) && '--file tests\requirements-truststore.txt' || '' }}
CONDA_TEST_SOLVERS: ${{ github.event_name == 'pull_request' && 'libmamba' || 'libmamba,classic' }}
steps:
- name: Checkout Source
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
with:
fetch-depth: 0
- name: Hash + Timestamp
shell: bash # use bash to run date command
run: echo "HASH=${{ runner.os }}-${{ runner.arch }}-Py${{ matrix.python-version }}-${{ matrix.default-channel }}-${{ matrix.test-type }}-${{ matrix.test-group }}-$(date -u "+%Y%m")" >> $GITHUB_ENV
- name: Cache Conda
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: ~/conda_pkgs_dir
key: cache-${{ env.HASH }}
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca
with:
condarc-file: .github\condarc-${{ matrix.default-channel }}
run-post: false # skip post cleanup
- name: Conda Install
run: >
conda install
--yes
--file tests\requirements.txt
--file tests\requirements-${{ runner.os }}.txt
--file tests\requirements-ci.txt
--file tests\requirements-s3.txt
${{ env.REQUIREMENTS_TRUSTSTORE }}
python=${{ matrix.python-version }}
- name: Conda Info
# view test env info (not base)
run: python -m conda info --verbose
- name: Conda Config
run: conda config --show-sources
- name: Conda List
run: conda list --show-channel-urls
- name: Run Tests
# Windows is sensitive to long paths, using `--basetemp=${{ runner.temp }} to
# keep the test directories shorter
run: >
pytest
--cov=conda
--basetemp=${{ runner.temp }}
--durations-path=tools\durations\${{ runner.os }}.json
--group=${{ matrix.test-group }}
--splits=${{ env.PYTEST_SPLITS }}
-m "${{ env.PYTEST_MARKER }}"
- name: Upload Coverage
uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be
with:
flags: ${{ runner.os }},${{ runner.arch }},${{ matrix.python-version }},${{ matrix.test-type }}
token: ${{ secrets.CODECOV_TOKEN }} # required
- name: Upload Test Results
if: '!cancelled()'
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
with:
name: test-results-${{ env.HASH }}
path: |
.coverage
tools\durations\${{ runner.os }}.json
test-report.xml
retention-days: 1 # temporary, combined in aggregate below
# linux test suite
linux:
# only run test suite if there are code changes
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
defaults:
run:
# https://github.com/conda-incubator/setup-miniconda#use-a-default-shell
shell: bash -el {0} # bash exit immediately on error + login shell
strategy:
fail-fast: false
matrix:
# test all lower versions (w/ defaults) and upper version (w/ defaults and conda-forge)
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
default-channel: [defaults, conda-forge]
test-type: [unit, integration]
test-group: [1, 2, 3]
exclude:
- python-version: '3.8'
default-channel: conda-forge
- python-version: '3.9'
default-channel: conda-forge
- python-version: '3.10'
default-channel: conda-forge
- python-version: '3.11'
default-channel: conda-forge
- test-type: unit
test-group: 3
env:
PYTEST_MARKER: ${{ matrix.test-type == 'unit' && 'not integration' || 'integration' }}
PYTEST_SPLITS: ${{ matrix.test-type == 'unit' && '2' || '3' }}
REQUIREMENTS_TRUSTSTORE: ${{ contains('3.10|3.11|3.12', matrix.python-version) && '--file tests/requirements-truststore.txt' || '' }}
CONDA_TEST_SOLVERS: ${{ github.event_name == 'pull_request' && 'libmamba' || 'libmamba,classic' }}
steps:
- name: Checkout Source
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
with:
fetch-depth: 0
- name: Hash + Timestamp
run: echo "HASH=${{ runner.os }}-${{ runner.arch }}-Py${{ matrix.python-version }}-${{ matrix.default-channel }}-${{ matrix.test-type }}-${{ matrix.test-group }}-$(date -u "+%Y%m")" >> $GITHUB_ENV
- name: Cache Conda
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: ~/conda_pkgs_dir
key: cache-${{ env.HASH }}
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca
with:
condarc-file: .github/condarc-${{ matrix.default-channel }}
run-post: false # skip post cleanup
- name: Conda Install
run: >
conda install
--yes
--file tests/requirements.txt
--file tests/requirements-${{ runner.os }}.txt
--file tests/requirements-ci.txt
--file tests/requirements-s3.txt
${{ env.REQUIREMENTS_TRUSTSTORE }}
python=${{ matrix.python-version }}
- name: Conda Info
# view test env info (not base)
run: python -m conda info --verbose
- name: Conda Config
run: conda config --show-sources
- name: Conda List
run: conda list --show-channel-urls
- name: Run Tests
run: >
pytest
--cov=conda
--durations-path=tools/durations/${{ runner.os }}.json
--group=${{ matrix.test-group }}
--splits=${{ env.PYTEST_SPLITS }}
-m "${{ env.PYTEST_MARKER }}"
- name: Upload Coverage
uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be
with:
flags: ${{ runner.os }},${{ runner.arch }},${{ matrix.python-version }},${{ matrix.test-type }}
token: ${{ secrets.CODECOV_TOKEN }} # required
- name: Upload Test Results
if: '!cancelled()'
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
with:
name: test-results-${{ env.HASH }}
path: |
.coverage
tools/durations/${{ runner.os }}.json
test-report.xml
retention-days: 1 # temporary, combined in aggregate below
# linux benchmarks
linux-benchmarks:
# only run test suite if there are code changes
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
defaults:
run:
# https://github.com/conda-incubator/setup-miniconda#use-a-default-shell
shell: bash -el {0} # bash exit immediately on error + login shell
strategy:
fail-fast: false
matrix:
python-version: ['3.12']
env:
REQUIREMENTS_TRUSTSTORE: ${{ contains('3.10|3.11|3.12', matrix.python-version) && '--file tests/requirements-truststore.txt' || '' }}
steps:
- name: Checkout Source
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
with:
fetch-depth: 0
- name: Hash + Timestamp
run: echo "HASH=${{ runner.os }}-${{ runner.arch }}-Py${{ matrix.python-version }}-benchmark-$(date -u "+%Y%m")" >> $GITHUB_ENV
- name: Cache Conda
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: ~/conda_pkgs_dir
key: cache-${{ env.HASH }}
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca
with:
condarc-file: .github/condarc-defaults
run-post: false # skip post cleanup
- name: Conda Install
run: >
conda install
--yes
--file tests/requirements.txt
--file tests/requirements-${{ runner.os }}.txt
--file tests/requirements-ci.txt
--file tests/requirements-s3.txt
${{ env.REQUIREMENTS_TRUSTSTORE }}
python=${{ matrix.python-version }}
- name: Install CodSpeed
run: pip install git+https://github.com/kenodegard/pytest-codspeed.git@fix-outerr-redirects#egg=pytest-codspeed
- name: Conda Info
# view test env info (not base)
run: python -m conda info --verbose
- name: Conda Config
run: conda config --show-sources
- name: Conda List
run: conda list --show-channel-urls
- name: Run Benchmarks
uses: CodSpeedHQ/action@0b631f8998f2389eb5144632b6f9f8fabd33a86e # v2.4.1
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: $CONDA/envs/test/bin/pytest --codspeed
# linux-qemu test suite
linux-qemu:
# only run test suite if there are code changes
needs: changes
if: needs.changes.outputs.code == 'true'
# Run one single fast test per docker+qemu emulated linux platform to test that
# test execution is possible there (container+tools+dependencies work). Can be
# changed / extended to run specific tests in case there are platform related
# things to test. Running more tests is time consuming due to emulation
# (factor 2-10x slower).
runs-on: ubuntu-latest
defaults:
run:
# https://github.com/conda-incubator/setup-miniconda#use-a-default-shell
shell: bash -el {0} # bash exit immediately on error + login shell
strategy:
fail-fast: false
matrix:
python-version: ['3.12']
image:
- continuumio/miniconda3:latest
- condaforge/miniforge3:latest
platform: [arm64, ppc64le, s390x]
exclude:
- image: continuumio/miniconda3:latest
platform: ppc64le
- image: condaforge/miniforge3:latest
platform: s390x
steps:
- name: Checkout Source
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
with:
fetch-depth: 0
- name: Setup QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3
- name: Run Tests
run: >
docker run
--rm
--volume ${PWD}:/opt/conda-src
--workdir /opt/conda-src
--platform linux/${{ matrix.platform }}
${{ matrix.image }}
bash -lc
". /opt/conda/etc/profile.d/conda.sh
&& set -x
&& conda create
--name test
--yes
--file tests/requirements.txt
--file tests/requirements-${{ runner.os }}.txt
--file tests/requirements-ci.txt
python=${{ matrix.python-version }}
&& conda activate test
&& python -m conda info --verbose
&& conda config --show-sources
&& conda list --show-channel-urls
&& python -m pytest tests/test_api.py::test_DepsModifier_contract"
# macos test suite
macos:
# only run test suite if there are code changes
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ${{ (matrix.arch == 'osx-64' && 'macos-13') || 'macos-14' }}
defaults:
run:
# https://github.com/conda-incubator/setup-miniconda#use-a-default-shell
shell: bash -el {0} # bash exit immediately on error + login shell
strategy:
fail-fast: false
matrix:
# test lower version (w/ osx-64 & defaults & unit tests) and upper version (w/ osx-arm64 & conda-forge & integration tests)
arch: [osx-64, osx-arm64]
python-version: ['3.8', '3.12']
default-channel: [defaults, conda-forge]
test-type: [unit, integration]
test-group: [1, 2, 3]
exclude:
- arch: osx-64
python-version: '3.12'
- arch: osx-64
default-channel: conda-forge
- arch: osx-64
test-type: integration
- arch: osx-arm64
python-version: '3.8'
- arch: osx-arm64
default-channel: defaults
- arch: osx-arm64
test-type: unit
- test-type: unit
test-group: 3
env:
PYTEST_MARKER: ${{ matrix.test-type == 'unit' && 'not integration' || 'integration' }}
PYTEST_SPLITS: ${{ matrix.test-type == 'unit' && '2' || '3' }}
REQUIREMENTS_TRUSTSTORE: ${{ contains('3.10|3.11|3.12', matrix.python-version) && '--file tests/requirements-truststore.txt' || '' }}
CONDA_TEST_SOLVERS: ${{ github.event_name == 'pull_request' && 'libmamba' || 'libmamba,classic' }}
steps:
- name: Checkout Source
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
with:
fetch-depth: 0
- name: Hash + Timestamp
run: echo "HASH=${{ runner.os }}-${{ runner.arch }}-Py${{ matrix.python-version }}-${{ matrix.default-channel }}-${{ matrix.test-type }}-${{ matrix.test-group }}-$(date -u "+%Y%m")" >> $GITHUB_ENV
- name: Cache Conda
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: ~/conda_pkgs_dir
key: cache-${{ env.HASH }}
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca
with:
condarc-file: .github/condarc-${{ matrix.default-channel }}
run-post: false # skip post cleanup
# conda not preinstalled in arm64 runners
miniconda-version: ${{ (matrix.default-channel == 'defaults' && matrix.arch == 'osx-arm64') && 'latest' || null }}
miniforge-version: ${{ (matrix.default-channel == 'conda-forge' && matrix.arch == 'osx-arm64') && 'latest' || null }}
architecture: ${{ runner.arch }}
- name: Conda Install
run: >
conda install
--yes
--file tests/requirements.txt
--file tests/requirements-ci.txt
--file tests/requirements-s3.txt
${{ env.REQUIREMENTS_TRUSTSTORE }}
python=${{ matrix.python-version }}
- name: Conda Info
# view test env info (not base)
run: python -m conda info --verbose
- name: Conda Config
run: conda config --show-sources
- name: Conda List
run: conda list --show-channel-urls
- name: Run Tests
run: >
pytest
--cov=conda
--durations-path=tools/durations/${{ runner.os }}.json
--group=${{ matrix.test-group }}
--splits=${{ env.PYTEST_SPLITS }}
-m "${{ env.PYTEST_MARKER }}"
- name: Upload Coverage
uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be
with:
flags: ${{ runner.os }},${{ runner.arch }},${{ matrix.python-version }},${{ matrix.test-type }}
token: ${{ secrets.CODECOV_TOKEN }} # required
- name: Upload Test Results
if: '!cancelled()'
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
with:
name: test-results-${{ env.HASH }}
path: |
.coverage
tools/durations/${{ runner.os }}.json
test-report.xml
retention-days: 1 # temporary, combined in aggregate below
# aggregate and upload
aggregate:
# only aggregate test suite if there are code changes
needs: [changes, windows, linux, linux-benchmarks, linux-qemu, macos]
if: >-
!cancelled()
&& needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
- name: Upload Combined Test Results
# provides one downloadable archive of all matrix run test results for further analysis
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
with:
name: test-results-${{ github.sha }}-all
path: test-results-*
retention-days: 7 # for durations.yml workflow
- name: Test Summary
uses: test-summary/action@032c8a9cec6aaa3c20228112cae6ca10a3b29336
with:
paths: test-results-*/test-report.xml
# required check
analyze:
needs: [windows, linux, linux-qemu, linux-benchmarks, macos, aggregate]
if: '!cancelled()'
runs-on: ubuntu-latest
steps:
- name: Determine Success
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
id: alls-green
with:
# permit jobs to be skipped if there are no code changes (see changes job)
allowed-skips: ${{ toJSON(needs) }}
jobs: ${{ toJSON(needs) }}
# CONDA-LIBMAMBA-SOLVER CHANGE
- name: Checkout our source
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
if: always() && github.event_name != 'pull_request' && steps.alls-green.outputs.result == 'failure'
- name: Report failures
if: always() && github.event_name != 'pull_request' && steps.alls-green.outputs.result == 'failure'
uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5
env:
GITHUB_TOKEN: ${{ secrets.CONDA_ISSUES }}
RUN_ID: ${{ github.run_id }}
TITLE: Tests failed
with:
filename: .github/TEST_FAILURE_REPORT_TEMPLATE.md
update_existing: false
# canary builds
build:
needs: [analyze]
# only build canary build if
# - prior steps succeeded,
# - this is the main repo, and
# - we are on the main, feature, or release branch
if: >-
!cancelled()
&& !github.event.repository.fork
&& (
github.ref_name == 'main'
|| startsWith(github.ref_name, 'feature/')
|| endsWith(github.ref_name, '.x')
)
strategy:
matrix:
include:
- runner: ubuntu-latest
subdir: linux-64
- runner: macos-13
subdir: osx-64
- runner: macos-14 # FUTURE: Use -latest
subdir: osx-arm64
- runner: windows-latest
subdir: win-64
runs-on: ${{ matrix.runner }}
steps:
# Clean checkout of specific git ref needed for package metadata version
# which needs env vars GIT_DESCRIBE_TAG and GIT_BUILD_STR:
- name: Checkout Source
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
with:
ref: ${{ github.ref }}
clean: true
fetch-depth: 0
# Explicitly use Python 3.11 since each of the OSes has a different default Python
- name: Setup Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d
with:
python-version: '3.11'
- name: Detect Label
shell: python
run: |
from pathlib import Path
from re import match
from os import environ
if "${{ github.ref_name }}" == "main":
# main branch commits are uploaded to the dev label
label = "dev"
elif "${{ github.ref_name }}".startswith("feature/"):
# feature branch commits are uploaded to a custom label
label = "${{ github.ref_name }}"
else:
# release branch commits are added to the rc label
# see https://github.com/conda/infrastructure/issues/760
_, name = "${{ github.repository }}".split("/")
label = f"rc-{name}-${{ github.ref_name }}"
Path(environ["GITHUB_ENV"]).write_text(f"ANACONDA_ORG_LABEL={label}")
- name: Create & Upload
uses: conda/actions/canary-release@1e442e090ad28c9b0f85697105703a303320ffd1
env:
# Run conda-build in isolated activation to properly package conda
_CONDA_BUILD_ISOLATED_ACTIVATION: 1
with:
package-name: ${{ github.event.repository.name }}
subdir: ${{ matrix.subdir }}
anaconda-org-channel: conda-canary
anaconda-org-label: ${{ env.ANACONDA_ORG_LABEL }}
anaconda-org-token: ${{ secrets.ANACONDA_ORG_CONDA_CANARY_TOKEN }}