Skip to content

Commit

Permalink
fix: Fix conda activate inside the smoke test (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab authored Feb 29, 2024
1 parent 177df05 commit 2831f1e
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 24 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ jobs:
miniforge-version: latest
environment-file: conda/dev.yaml
channels: conda-forge,nodefaults
activate-environment: pypkg
activate-environment: scicookie
auto-update-conda: true
conda-solver: libmamba

- name: Check poetry.lock
run: poetry check

- name: Install dependencies
run: poetry install
run: |
poetry config virtualenvs.create false
poetry install
- name: Run tests
run: makim tests.unittest
Expand Down Expand Up @@ -81,7 +83,7 @@ jobs:
miniforge-version: latest
environment-file: conda/dev.yaml
channels: conda-forge,nodefaults
activate-environment: pypkg
activate-environment: scicookie
auto-update-conda: true
conda-solver: libmamba

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
miniforge-version: latest
environment-file: conda/dev.yaml
channels: conda-forge,nodefaults
activate-environment: pypkg
activate-environment: scicookie
auto-update-conda: true
conda-solver: libmamba

Expand Down
1 change: 1 addition & 0 deletions conda/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ channels:
- nodefaults
- conda-forge
dependencies:
- bash
- git
- python >=3.8.1,<3.12
- poetry >=1.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from importlib import metadata as importlib_metadata


def get_version():
def get_version() -> str:
"""Return the program version."""
try:
return importlib_metadata.version(__name__)
Expand Down
1 change: 1 addition & 0 deletions tests/smoke/auto-format-tools.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e

SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

Expand Down
1 change: 1 addition & 0 deletions tests/smoke/automation.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e

SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

Expand Down
28 changes: 10 additions & 18 deletions tests/smoke/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ set -ex

PATH_ORI=${PATH}
PWD_ORI=$(pwd)
CONDA_PATH=$(cd "$(dirname ${CONDA_PYTHON_EXE})" && cd .. && pwd)
PROJECT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" && cd ../src/scicookie && pwd )" >/dev/null 2>&1 && cd ../.. && pwd )"
PROJECT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd ../.. && pwd )"

if [ "${CONDA_PATH}" == ""]; then
echo "INVALID 'CONDA_PATH' environment variable."
if [ "$(which conda)" == "" ]; then
echo "EE 'conda' not found."
exit 1
fi

export PATH="${CONDA_PATH}/condabin:${CONDA_PATH}/bin:$PATH"
echo "[II] included conda to the PATH"

ENV_NAME=osl-python-package

OUTPUT_DIR="/tmp/osl"
Expand All @@ -28,18 +24,14 @@ cookieninja --no-input \

cd "${OUTPUT_DIR}/${ENV_NAME}"

mamba env create --file conda/dev.yaml --force

CONDA_PREFIX="${CONDA_PATH}/envs/${ENV_NAME}"
set +x
eval "$(conda shell.bash hook)"
mamba env create --file conda/dev.yaml --name "${ENV_NAME}" --force
conda activate "${ENV_NAME}"
set -x

export PATH=$(echo $PATH| sed -E "s/[^:]+\/mambaforge\/[^:]+//g")
export PATH=$(echo $PATH| sed -E "s/[^:]+\/conda\/[^:]+//g")
export PATH=$(echo $PATH| sed -E "s/[^:]+\/miniconda\/[^:]+//g")
export PATH=$(echo $PATH| sed -E "s/[^:]+\/miniconda3\/[^:]+//g")
export PATH=$(echo $PATH| sed -E "s/[^:]+\/micromamba\/[^:]+//g")
export PATH=$(echo $PATH| sed -E "s/[^:]+\/anaconda3\/[^:]+//g")
export PATH="${CONDA_PREFIX}:${CONDA_PREFIX}/bin:$PATH"
echo "[II] included env conda to the PATH"
# remove any path to scicookie environment
export PATH=$(echo $PATH| sed -E "s/[^:]+\/scicookie\/[^:]+//g")

if command -v poetry &> /dev/null; then
poetry install
Expand Down
3 changes: 2 additions & 1 deletion tests/smoke/build-systems.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
set -e

SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

. ${SMOKE_DIR}/base.sh "build_system=poetry"
. ${SMOKE_DIR}/base.sh "build_system=flit"
. ${SMOKE_DIR}/base.sh "build_system=mesonpy"
. ${SMOKE_DIR}/base.sh "build_system=setuptools"
Expand All @@ -11,3 +11,4 @@ SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
. ${SMOKE_DIR}/base.sh "build_system=maturin"
. ${SMOKE_DIR}/base.sh "build_system=scikit-build-core"
. ${SMOKE_DIR}/base.sh "build_system=pybind11"
. ${SMOKE_DIR}/base.sh "build_system=poetry"
1 change: 1 addition & 0 deletions tests/smoke/containers.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e

SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

Expand Down
1 change: 1 addition & 0 deletions tests/smoke/docs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e

SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

Expand Down
1 change: 1 addition & 0 deletions tests/smoke/files.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e

SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

Expand Down
1 change: 1 addition & 0 deletions tests/smoke/linters.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e

SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

Expand Down
3 changes: 3 additions & 0 deletions tests/smoke/tests.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env bash
set -e

SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

. ${SMOKE_DIR}/base.sh "use_pytest=yes"
Expand Down
1 change: 1 addition & 0 deletions tests/smoke/virtual-envs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e

SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

Expand Down

0 comments on commit 2831f1e

Please sign in to comment.