Skip to content
Merged
191 changes: 191 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]
merge_group:

jobs:
default:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
- run: |
pixi info
test -f .pixi/env/bin/python
./.pixi/env/bin/python --version | grep -q 3.11

no-run-install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
run-install: false
- run: |
! test -d .pixi

custom-pixi-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
pixi-version: v0.1.0
- run: pixi --version | grep -q "pixi 0.1.0"

custom-pixi-url:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
pixi-url: https://github.com/prefix-dev/pixi/releases/download/v0.0.8/pixi-x86_64-unknown-linux-musl
- run: pixi --version | grep -q "pixi 0.0.8"

custom-manifest-path:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
manifest-path: test/default/pixi.toml

different-log-level:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
log-level: debug

# run-shell:
# strategy:
# matrix:
# os: [ubuntu-latest, macos-latest]
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v4
# - name: Move pixi.toml
# run: mv test/default/* .
# - uses: ./
# with:
# generate-run-shell: true
# - run: python --version | grep -q "3.11"
# shell: pixi-shell {0}

custom-bin-path:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- name: Create bin directory
run: mkdir bin
- uses: ./
with:
pixi-bin-path: bin/pixi
- run: |
which pixi | grep -q "..."

auth-token:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
auth-host: TODO
auth-token: TODO
# TODO
# - run:

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:
auth-host: TODO
auth-username: TODO
auth-password: TODO

auth-conda-token:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/default/* .
- uses: ./
with:
auth-host: TODO
auth-conda-token: TODO

post-cleanup:
# not implemented yet
if: false
name: post-cleanup ${{ matrix.post-cleanup }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- post-cleanup: 'none'
env-exists: ''
cache-exists: ''
pixi-dir-exists: ''
- post-cleanup: 'environment'
env-exists: '! '
cache-exists: ''
pixi-dir-exists: ''
- post-cleanup: 'all'
env-exists: '! '
cache-exists: '! '
pixi-dir-exists: '! '
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.env-exists }}test -d .pixi
${{ matrix.cache-exists }}test -d ~/.cache/rattler
${{ matrix.pixi-dir-exists }}test -f ~/.pixi
- uses: ./
with:
post-cleanup: ${{ matrix.post-cleanup }}

no-lockfile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Move pixi.toml
run: mv test/no-lockfile/* .
- uses: ./
- run: |
pixi info
test -f .pixi/env/bin/python
./.pixi/env/bin/python --version | grep -q 3.11
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ inputs:
If `none`, no cleanup is done.
If `environment`, the pixi environment is removed.
If `all`, the pixi environment, the pixi CLI are removed and the rattler cache is cleared.
Defaults to `all`.

runs:
using: node20
Expand Down
14 changes: 7 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const postCleanupSchema = z.enum(['none', 'environment', 'all'])
export type PostCleanup = z.infer<typeof postCleanupSchema>

export const PATHS = {
pixiBin: path.join(os.homedir(), '.pixi', 'bin', 'pixi'),
pixiBin: path.join(os.homedir(), '.pixi', 'bin', `pixi${os.platform() === 'win32' ? '.exe' : ''}`),
pixiRunShellScript: path.join(os.homedir(), '.pixi', 'bin', 'pixi-shell'),
bashProfile: path.join(os.homedir(), '.bash_profile'),
bashrc: path.join(os.homedir(), '.bashrc')
Expand All @@ -90,7 +90,7 @@ const parseOrUndefinedJSON = <T>(key: string, schema: z.ZodSchema<T>): T | undef
}

const validateInputs = (inputs: Inputs): void => {
if (!inputs.pixiVersion && !inputs.pixiUrl) {
if (inputs.pixiVersion && inputs.pixiUrl) {
throw new Error('You need to specify either pixi-version or pixi-url')
}
if (inputs.cacheKey !== undefined && inputs.cache === false) {
Expand Down Expand Up @@ -123,8 +123,12 @@ const validateInputs = (inputs: Inputs): void => {

const inferOptions = (inputs: Inputs): Options => {
const runInstall = inputs.runInstall ?? true
const pixiSource = inputs.pixiVersion ? { version: inputs.pixiVersion } : { url: inputs.pixiUrl! }
const logLevel = inputs.logLevel ?? (core.isDebug() ? 'debug' : 'info')
const pixiSource = inputs.pixiVersion
? { version: inputs.pixiVersion }
: inputs.pixiUrl
? { url: inputs.pixiUrl }
: { version: 'latest' }
const logLevel = inputs.logLevel ?? (core.isDebug() ? 'debug' : 'warn')
const manifestPath = inputs.manifestPath ?? 'pixi.toml'
const pixiLockFile = path.basename(manifestPath).replace(/\.toml$/, '.lock')
const generateRunShell = inputs.generateRunShell ?? runInstall
Expand Down Expand Up @@ -165,7 +169,7 @@ const assertOptions = (_options: Options) => {

const getOptions = () => {
const inputs: Inputs = {
pixiVersion: parseOrUndefined('pixi-version', z.union([z.literal('latest'), z.string().regex(/^\d+\.\d+\.\d+$/)])),
pixiVersion: parseOrUndefined('pixi-version', z.union([z.literal('latest'), z.string().regex(/^v\d+\.\d+\.\d+$/)])),
pixiUrl: parseOrUndefined('pixi-url', z.string().url()),
logLevel: parseOrUndefined('log-level', logLevelSchema),
manifestPath: parseOrUndefined('manifest-path', z.string()),
Expand All @@ -174,7 +178,7 @@ const getOptions = () => {
cache: parseOrUndefinedJSON('cache', z.boolean()),
cacheKey: parseOrUndefined('cache-key', z.string()),
pixiBinPath: parseOrUndefined('micromamba-binary-path', z.string()),
authHost: parseOrUndefined('auth-host', z.string().url()),
authHost: parseOrUndefined('auth-host', z.string()),
authToken: parseOrUndefined('auth-token', z.string()),
authUsername: parseOrUndefined('auth-username', z.string()),
authPassword: parseOrUndefined('auth-password', z.string()),
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const getPixiUrlFromVersion = (version: string) => {
if (version === 'latest') {
return `https://github.com/prefix-dev/pixi/releases/latest/download/${pixiFile}`
}
return `https://github.com/mamba-org/micromamba-releases/releases/download/${version}/${pixiFile}`
return `https://github.com/prefix-dev/pixi/releases/download/${version}/${pixiFile}`
}

export const sha256 = (s: BinaryLike) => {
Expand Down
2 changes: 2 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# pixi environments
.pixi
Loading