Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Test activate on windows #6

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
22 changes: 18 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,28 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [windows-latest]

steps:
- uses: actions/checkout@v2
- run: |
npm install
npm run all
- uses: ./
- name: Run conda list
run: conda list
- name: init pwsh
run: conda init --system powershell
- name: Install Python
run: mamba install -y -c conda-forge python
shell: powershell
# run: echo "%PATH%" && CALL activate.bat base && conda info && echo "%PATH%"
run: |
conda activate base
conda env list
echo "$env:path"
- name: Install stuff
run: conda activate base && mamba.bat install -y -c conda-forge xtensor
- name: Install Notebook and widgets
run: mamba install -y -c notebook ipywidgets
run: mamba.bat install -y -c conda-forge notebook ipywidgets
- name: List the packages
run: mamba list
run: mamba.bat list
11 changes: 11 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,15 @@ function installMamba() {
yield exec.exec('conda', ['install', '-y', '-c', 'conda-forge', 'mamba']);
});
}
function activate(os) {
return __awaiter(this, void 0, void 0, function* () {
if (os === 'win32') {
const basePath = process.env.CONDA;
const activateFile = path.join(basePath, 'condabin', 'activate.bat');
yield exec.exec('conda', ['shell.powershell', activateFile, 'base']);
}
});
}
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
Expand All @@ -1029,6 +1038,8 @@ function run() {
fixPermissions(os);
core.debug('Add conda to the path');
yield addPath(os);
core.debug('Activate the environment');
activate(os);
core.debug('Installing mamba');
yield installMamba();
}
Expand Down
20 changes: 18 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ async function addPath(os: string): Promise<void> {
const bin = path.join(basePath, 'condabin')
core.addPath(bin)
} else if (os === 'win32') {
const bin = path.join(basePath, 'Scripts')
core.addPath(bin)
core.addPath(path.join(basePath, 'Library', 'bin'))
core.addPath(path.join(basePath, 'condabin'))
core.addPath(path.join(basePath, 'bin'))
core.addPath(path.join(basePath, 'Scripts'))
core.addPath(path.join(basePath, 'Library', 'usr', 'bin'))
core.addPath(path.join(basePath, 'Library', 'mingw-w64', 'bin'))
core.addPath(path.join(basePath))
} else {
const bin = path.join(basePath, 'bin')
core.addPath(bin)
Expand All @@ -34,6 +39,14 @@ async function installMamba(): Promise<void> {
await exec.exec('conda', ['install', '-y', '-c', 'conda-forge', 'mamba'])
}

async function activate(os: string): Promise<void> {
if (os === 'win32') {
const basePath = process.env.CONDA as string
const activateFile = path.join(basePath, 'condabin', 'activate.bat')
await exec.exec('conda', ['shell.powershell', activateFile, 'base'])
}
}

async function run(): Promise<void> {
try {
const os = process.platform
Expand All @@ -44,6 +57,9 @@ async function run(): Promise<void> {
core.debug('Add conda to the path')
await addPath(os)

core.debug('Activate the environment')
activate(os)

core.debug('Installing mamba')
await installMamba()
} catch (error) {
Expand Down