Skip to content
Draft
Show file tree
Hide file tree
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
93 changes: 80 additions & 13 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,99 @@
name: Docs

on:
push:
branches:
- main
tags:
- "*"
pull_request:
paths:
- ".github/workflows/docs.yml"
- "docs/**"
branches:
- main
merge_group:
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

jobs:
# detect whether any doc changes are included in this PR
changes:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
docs: ${{ steps.filter.outputs.docs }}
steps:
- name: Checkout Source
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
if: github.event_name != 'pull_request'

- name: Filter Changes
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
docs:
- 'docs/**'
- 'conda_self/**'
- '*.py'
- 'environment-docs.yml'
- 'pyproject.toml'
- '.github/workflows/docs.yml'

docs:
# only run docs build if there are relevant changes
needs: changes
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') || needs.changes.outputs.docs == 'true'
runs-on: ubuntu-latest
env:
CONDA_PKGS_DIR: ~/conda_pkgs_dir
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Checkout Source
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- uses: prefix-dev/setup-pixi@fef5c9568ca6c4ff7707bf840ab0692ba3f08293 # v0.9.0

- name: Hash + Timestamp
run: echo "HASH=${{ runner.os }}-${{ runner.arch }}-docs-$(date -u "+%Y%m")" >> $GITHUB_ENV

- name: Cache Conda
uses: actions/cache@v4
with:
environments: docs
enableCrossOsArchive: true
path: ${{ env.CONDA_PKGS_DIR }}
key: cache-docs-${{ env.HASH }}

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
environment-file: environment-docs.yml
activate-environment: conda-self-docs
pkgs-dirs: ${{ env.CONDA_PKGS_DIR }}

- name: Display conda info
run: |
conda info
conda list
python -c "import conda_self; print(f'conda-self version: {conda_self.__version__}')"

- name: Build docs
run: pixi run docs
run: |
cd docs
python -m sphinx.cmd.build -M dirhtml . _build
- name: Upload artifact
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
with:
path: 'docs/_build/dirhtml'

pages:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
needs: [docs]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
Expand All @@ -56,3 +110,16 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5

# required check for docs
analyze:
needs: [docs, pages]
if: '!cancelled()'
runs-on: ubuntu-latest
steps:
- name: Determine Success
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
# permit jobs to be skipped if there are no relevant changes or deployment conditions aren't met
allowed-skips: ${{ toJSON(needs) }}
jobs: ${{ toJSON(needs) }}
232 changes: 188 additions & 44 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,210 @@
name: conda-self tests
name: Tests

on:
push:
branches:
- main
branches: [ main ]
pull_request:
branches:
- main
branches: [ main ]
merge_group:
schedule:
# Run tests daily at 8:24 AM UTC to catch regressions
- cron: '24 08 * * *'

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

jobs:
tests:
name: ${{ matrix.os }}, py${{ matrix.python-version }}
# detect whether any code changes are included in this PR
changes:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- name: Checkout Source
uses: actions/checkout@v4
if: github.event_name != 'pull_request'

- name: Filter Changes
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code:
- 'conda_self/**'
- 'tests/**'
- '*.py'
- 'environment-*.yml'
- 'recipe/**'
- '.github/workflows/tests.yml'

test:
# only run test suite if there are code changes or it's a scheduled run
needs: changes
if: github.event_name == 'schedule' || needs.changes.outputs.code == 'true'
runs-on: ${{ matrix.os }}
env:
CONDA_PKGS_DIR: ${{ matrix.os == 'windows-latest' && 'D:\conda_pkgs_dir' || '~/conda_pkgs_dir' }}
CONDA_INSTALL_DIR: ${{ matrix.os == 'windows-latest' && 'D:\conda' || '' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["39", "310", "311", "312"]
include:
- os: macos-13
python-version: "39"
- os: macos-14
python-version: "312"
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
conda-version: ["24.11", "25.1", "25.3", "25.5", "25.7"]
channel: ["conda-forge", "defaults"]
exclude:
# Windows: only test lowest and highest Python versions
- os: windows-latest
python-version: "3.10"
- os: windows-latest
python-version: "3.11"
- os: windows-latest
python-version: "3.12"
# macOS: reduce matrix for faster CI
- os: macos-latest
python-version: "3.10"
- os: macos-latest
python-version: "3.11"
- os: macos-latest
python-version: "3.12"
# Older conda versions may not support Python 3.13
- conda-version: "24.11"
python-version: "3.13"
- conda-version: "25.1"
python-version: "3.13"
# Older conda versions: only test with conda-forge
- conda-version: "24.11"
channel: "defaults"
- conda-version: "25.1"
channel: "defaults"

defaults:
run:
shell: bash -el {0}

steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: prefix-dev/setup-pixi@fef5c9568ca6c4ff7707bf840ab0692ba3f08293 # v0.9.0
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
environments: test-py${{ matrix.python-version }}
- name: Ensure package is installed
run: pixi reinstall --environment test-py${{ matrix.python-version }} conda-self
- name: Setup project
run: |
echo "channels: [conda-forge]" > .pixi/envs/test-py${{ matrix.python-version }}/.condarc
pixi run --environment test-py${{ matrix.python-version }} conda info
fetch-depth: 0

- name: Hash + Timestamp
run: echo "HASH=${{ runner.os }}-${{ runner.arch }}-Py${{ matrix.python-version }}-$(date -u "+%Y%m")" >> $GITHUB_ENV

- name: Cache Conda
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
enableCrossOsArchive: true
path: ${{ env.CONDA_PKGS_DIR }}
key: cache-${{ env.HASH }}

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0
with:
run-post: false # skip post cleanup
# conda not preinstalled in arm64 runners
miniconda-version: ${{ runner.arch == 'ARM64' && 'latest' || null }}
architecture: ${{ runner.arch }}
channels: ${{ matrix.channel }}
pkgs-dirs: ${{ env.CONDA_PKGS_DIR }}
installation-dir: ${{ env.CONDA_INSTALL_DIR }}

- name: Install conda-self dependencies
run: >
conda install
--channel ${{ matrix.channel }}
--override-channels
python=${{ matrix.python-version }}
${{ matrix.conda-version != 'latest' && format('conda={0}', matrix.conda-version) || ''}}
pip
pytest
pytest-mock
pytest-cov
pre-commit

- name: Install self
run: pip install -e .

- 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: Test conda-self plugin registration
run: python -m conda self --help

- name: Run tests
run: pixi run --environment test-py${{ matrix.python-version }} test --basetemp=${{ runner.os == 'Windows' && 'D:\temp' || runner.temp }}
# Windows is sensitive to long paths, using `--basetemp=${{ runner.temp }} to
# keep the test directories shorter
run: >
pytest
-xvs
--cov=conda_self
--cov-report=xml
--basetemp=${{ runner.temp }}
tests/

build-conda:
name: Build conda package (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
env:
PYTHONUNBUFFERED: "1"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
fail_ci_if_error: false

lint:
name: Lint
needs: changes
if: github.event_name == 'schedule' || needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0
with:
fetch-depth: 0
- uses: prefix-dev/setup-pixi@fef5c9568ca6c4ff7707bf840ab0692ba3f08293 # v0.9.0
# conda not preinstalled in arm64 runners
miniconda-version: ${{ runner.arch == 'ARM64' && 'latest' || null }}
architecture: ${{ runner.arch }}
python-version: "3.10"
conda-version: "25.7"
channels: conda-forge

- name: Install linting dependencies
run: >
conda install
--channel conda-forge
--override-channels
python=3.10
conda=25.7
pre-commit
shell: bash -l {0}

- name: Run pip
run: pip install -e .
shell: bash -l {0}

- name: Run pre-commit
run: pre-commit run --all-files
shell: bash -l {0}

# required check
analyze:
needs: [test, lint]
if: '!cancelled()'
runs-on: ubuntu-latest
steps:
- name: Determine Success
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
environments: build
- name: Build recipe
run: pixi run --environment build build
# permit jobs to be skipped if there are no code changes
allowed-skips: ${{ toJSON(needs) }}
jobs: ${{ toJSON(needs) }}
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# disable autofixing PRs, commenting "pre-commit.ci autofix" on a pull request triggers a autofix
ci:
autofix_prs: false
# generally speaking we ignore all vendored code as well as tests data
# TODO: Restore index and solver exclude lines before merge
exclude: |
(?x)^(
tests/data/ |
conda_self/_version.py |
pixi.lock
)$
repos:
# generic verification and formatting
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
Loading
Loading