Skip to content

Improve multi environment example #351

Improve multi environment example

Improve multi environment example #351

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
merge_group:
jobs:
default:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest, macos-14]
cache: [true, false]
runs-on: ${{ matrix.os }}
name: default ${{ matrix.cache == true && 'with' || 'without' }} cache (${{ matrix.os }})
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
# check the action logs to see if the cache was used or not
with:
cache: ${{ matrix.cache }}
- run: |
set -o pipefail
pixi info
test -f .pixi/envs/default/bin/python
./.pixi/envs/default/bin/python --version | grep -q 3.11
shell: bash
if: matrix.os != 'windows-latest'
- run: |
set -o pipefail
pixi info
test -f .pixi/envs/default/python.exe
./.pixi/envs/default/python.exe --version | grep -q 3.11
shell: bash
if: matrix.os == 'windows-latest'
- run: |
pixi run python --version | grep -q 3.11
pixi run test | grep -q "Hello world"
no-run-install:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
run-install: false
cache: false
- run: |
! test -d .pixi
shell: bash
no-pixi-toml:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./
with:
run-install: false
- run: |
! test -d .pixi
shell: bash
- run: pixi info
custom-pixi-version:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest, macos-14]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/old-pixi-lockfiles/* .
- uses: ./
with:
cache: false
pixi-version: v0.1.0
# pixi 0.1.0 doesn't support --locked
locked: false
- run: pixi --version | grep -q "pixi 0.1.0"
old-lockfile:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
locked: [true, false]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/old-pixi-lockfiles/* .
- uses: ./
with:
pixi-version: latest
cache: false
locked: ${{ matrix.locked }}
- if: matrix.os == 'windows-latest'
run: choco install yq
# assert that the lockfile wasn't updated
- run: test "$(yq '.version' pixi.lock)" = 1
install-path:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest, macos-14]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./
with:
run-install: false
- run: test "$(which pixi)" = "$HOME/.pixi/bin/pixi"
shell: bash
global-install:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest, macos-14]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./
with:
run-install: false
- run: pixi global install cowpy
- run: |
pixi global list 2>&1 | grep cowpy
cowpy hello world
test "$(which cowpy)" = "$HOME/.pixi/bin/cowpy"
if: matrix.os != 'windows-latest'
- run: cowpy hello world
if: matrix.os == 'windows-latest'
frozen:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
cache: false
frozen: true
- run: pixi run python --version | grep -q 3.11
locked:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
cache: false
locked: true
- run: pixi run python --version | grep -q 3.11
custom-pixi-url:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/old-pixi-lockfiles/* .
- uses: ./
with:
cache: false
pixi-url: https://github.com/prefix-dev/pixi/releases/download/v0.13.0/pixi-x86_64-unknown-linux-musl
- run: pixi --version | grep -q "pixi 0.13.0"
custom-manifest-path:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./
with:
cache: false
manifest-path: test/default/pixi.toml
different-log-level:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
cache: false
log-level: v
custom-bin-path:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
cache: false
pixi-bin-path: custom-bin/pixi${{ matrix.os == 'windows-latest' && '.exe' || '' }}
- run: |
test -f custom-bin/pixi${{ matrix.os == 'windows-latest' && '.exe' || '' }}
pixi --help
which pixi | grep -q custom-bin/pixi
# which pixi should be absolute
which pixi | grep -q "^/"
auth-token:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
cache: false
auth-host: https://custom-conda-registry.com
auth-token: custom-token
- run: |
cat ~/.rattler/credentials.json
[ $(jq '."*.custom-conda-registry.com".BearerToken' -r ~/.rattler/credentials.json) = "custom-token" ]
# all other platforms have the credentials stored in the keychain
# https://github.com/prefix-dev/pixi/issues/330
if: matrix.os == 'ubuntu-latest'
auth-username-password:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
cache: false
auth-host: https://custom-conda-registry.com
auth-username: custom-username
auth-password: custom-password
- run: |
cat ~/.rattler/credentials.json
[ $(jq '."*.custom-conda-registry.com".BasicHTTP.username' -r ~/.rattler/credentials.json) = "custom-username" ]
[ $(jq '."*.custom-conda-registry.com".BasicHTTP.password' -r ~/.rattler/credentials.json) = "custom-password" ]
# all other platforms have the credentials stored in the keychain
# https://github.com/prefix-dev/pixi/issues/330
if: matrix.os == 'ubuntu-latest'
auth-conda-token:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
cache: false
auth-host: https://custom-conda-registry.com
auth-conda-token: custom-conda-token
- run: |
cat ~/.rattler/credentials.json
[ $(jq '."*.custom-conda-registry.com".CondaToken' -r ~/.rattler/credentials.json) = "custom-conda-token" ]
# all other platforms have the credentials stored in the keychain
# https://github.com/prefix-dev/pixi/issues/330
if: matrix.os == 'ubuntu-latest'
auth-token-install:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/auth/* .
- uses: ./
with:
cache: false
auth-host: https://repo.prefix.dev
auth-token: ${{ secrets.PREFIX_DEV_TOKEN }}
- name: Ensure private-package is installed
run: |
test -f .pixi/envs/default/conda-meta/private-package-0.0.1-0.json
pixi-shell:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
cache: false
- run: |
python --version | grep -q "3.11"
shell: pixi run bash -e {0}
- run: |
import sys
print(sys.version)
print("Hello world")
shell: pixi run python {0}
- run: |
python --version | Select-String "3.11"
shell: pixi run pwsh -Command {0}
post-cleanup-linux:
runs-on: ubuntu-latest
strategy:
matrix:
post-cleanup: ['true', 'false']
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe
with:
run: |
set -euxo pipefail
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d .pixi
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.rattler
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.cache/rattler
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/bin/pixi
- uses: ./
with:
cache: false
post-cleanup: ${{ matrix.post-cleanup }}
# ~/.rattler is only created if the user has logged in
auth-host: https://custom-conda-registry.com
auth-token: custom-token
post-cleanup-linux-no-login:
runs-on: ubuntu-latest
strategy:
matrix:
post-cleanup: ['true', 'false']
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe
with:
run: |
set -euxo pipefail
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d .pixi
! test -d ~/.rattler
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.cache/rattler
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/bin/pixi
- uses: ./
with:
cache: false
post-cleanup: ${{ matrix.post-cleanup }}
post-cleanup-macos:
runs-on: macos-latest
strategy:
matrix:
post-cleanup: ['true', 'false']
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe
with:
run: |
set -euxo pipefail
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d .pixi
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/Library/Caches/rattler
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/bin/pixi
- uses: ./
with:
cache: false
post-cleanup: ${{ matrix.post-cleanup }}
post-cleanup-windows:
runs-on: windows-latest
strategy:
matrix:
post-cleanup: ['true', 'false']
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe
with:
run: |
set -euxo pipefail
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d .pixi
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d "$LOCALAPPDATA/rattler"
${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/bin/pixi
- uses: ./
with:
cache: false
post-cleanup: ${{ matrix.post-cleanup }}
no-lockfile:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/no-lockfile/* .
- uses: ./
with:
cache: false
- run: |
set -o pipefail
pixi info
test -f .pixi/envs/default/bin/python
./.pixi/envs/default/bin/python --version | grep -q 3.11
shell: bash
if: matrix.os != 'windows-latest'
- run: |
set -o pipefail
pixi info
test -f .pixi/envs/default/python.exe
./.pixi/envs/default/python.exe --version | grep -q 3.11
shell: bash
if: matrix.os == 'windows-latest'
- run: |
pixi run python --version | grep -q 3.11
pixi run test | grep -q "Hello world"
multiple-environments:
name: multiple-environments (${{ matrix.os }}, cache=${{ matrix.cache }})
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest, macos-14]
cache: ['true', 'false']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/multiple-environments/* .
- uses: ./
with:
environments: py311 py312
cache: ${{ matrix.cache }}
- run: |
set -o pipefail
pixi info
test -f .pixi/envs/py311/bin/python
test -f .pixi/envs/py312/bin/python
! test -d .pixi/envs/default
./.pixi/envs/py311/bin/python --version | grep -q 3.11
./.pixi/envs/py312/bin/python --version | grep -q 3.12
shell: bash
if: matrix.os != 'windows-latest'
- run: |
set -o pipefail
pixi info
test -f .pixi/envs/py311/python.exe
test -f .pixi/envs/py312/python.exe
! test -d .pixi/envs/default
./.pixi/envs/py311/python.exe --version | grep -q 3.11
./.pixi/envs/py312/python.exe --version | grep -q 3.12
shell: bash
if: matrix.os == 'windows-latest'
cache-write-true:
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest, macos-14]
steps:
- uses: actions/checkout@v4
- name: Move pixi files
run: mv test/default/* .
- uses: ./
with:
cache-write: true
test-cache1:
name: Test cache 1/2
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest, macos-14]
steps:
- uses: actions/checkout@v4
- name: Move pixi files
run: mv test/default/* .
- uses: ./
with:
cache: true
cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}-
# check the action logs to see if the cache was written
- run: |
test -f .pixi/envs/default/bin/python
if: matrix.os != 'windows-latest'
- run: |
test -f .pixi/envs/default/python.exe
if: matrix.os == 'windows-latest'
test-cache2:
name: Test cache 2/2
timeout-minutes: 10
needs: test-cache1
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest, macos-14]
steps:
- uses: actions/checkout@v4
- name: Move pixi files
run: mv test/default/* .
- uses: ./
with:
cache: true
cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}-
# check the action logs to see if the cache was restored
- run: |
test -f .pixi/envs/default/bin/python
if: matrix.os != 'windows-latest'
- run: |
test -f .pixi/envs/default/python.exe
if: matrix.os == 'windows-latest'
test-cache-no-write:
name: Test cache no write
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest, macos-14]
steps:
- uses: actions/checkout@v4
- name: Move pixi files
run: mv test/default/* .
- uses: ./
with:
cache: true
cache-write: false
cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}-
# check the action logs to see if the cache write was skipped
# not properly testable
# https://github.com/actions/runner/issues/2347
# https://github.com/orgs/community/discussions/15452
# test-cache-fail-no-lockfile:
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [windows-latest, ubuntu-latest, macos-latest]
# steps:
# - uses: actions/checkout@v4
# - name: Move pixi files
# run: mv test/no-lockfile/* .
# - uses: ./
# with:
# cache: true
# cache-key: test-cache-no-lockfile-${{ github.sha }}-${{ github.run_attempt }}-
# - run: exit 1
# if: success()
# test-incorrect-version:
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [windows-latest, ubuntu-latest, macos-latest]
# steps:
# - uses: actions/checkout@v4
# - name: Move pixi files
# run: mv test/default/* .
# - uses: ./
# with:
# pixi-version: 0.1.0
# - run: exit 1
# if: success()
# test-frozen-and-locked:
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [windows-latest, ubuntu-latest, macos-latest]
# steps:
# - uses: actions/checkout@v4
# - name: Move pixi files
# run: mv test/default/* .
# - uses: ./
# with:
# pixi-version: v0.5.0
# frozen: true
# locked: true
# - run: exit 1
# if: success()
# test-frozen-no-lockfile:
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [windows-latest, ubuntu-latest, macos-latest]
# steps:
# - uses: actions/checkout@v4
# - name: Move pixi files
# run: mv test/no-lockfile/* .
# - uses: ./
# with:
# frozen: true
# - run: exit 1
# if: success()
# test-locked-no-lockfile:
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [windows-latest, ubuntu-latest, macos-latest]
# steps:
# - uses: actions/checkout@v4
# - name: Move pixi files
# run: mv test/no-lockfile/* .
# - uses: ./
# with:
# locked: true
# - run: exit 1
# if: success()
# test-lockfile-not-up-to-date:
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [windows-latest, ubuntu-latest, macos-latest]
# steps:
# - uses: actions/checkout@v4
# - name: Move pixi files
# run: mv test/lockfile-not-up-to-date/* .
# - uses: ./
# # locked: true is implicit
# - run: exit 1
# if: success()
# cache-write-true-no-lockfile:
# timeout-minutes: 10
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [windows-latest, ubuntu-latest, macos-latest]
# steps:
# - uses: actions/checkout@v4
# - name: Move pixi files
# run: mv test/no-lockfile/* .
# - uses: ./
# with:
# cache-write: true