Skip to content

Commit

Permalink
ci(wrappers/python): debug windows .venv path quirk
Browse files Browse the repository at this point in the history
  • Loading branch information
SKalt committed Sep 28, 2024
1 parent 6cdf2d9 commit efb9ec1
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 83 deletions.
157 changes: 77 additions & 80 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,75 +42,75 @@ jobs:
with:
fetch-depth: 1

- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.rustup
target
key: ${{ runner.os }}-${{ matrix.rust }}-min165

- uses: actions/setup-node@v4
with:
node-version: 20

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
default: true
components: rustfmt, clippy

- name: Check versions
run: |
cargo --version
rustc --version
- name: Install wasm-pack
uses: jetli/[email protected]
with:
version: ${{env.WASM_PACK_VERSION}}

- name: Build Coupled JS
working-directory: ./pagefind_web_js
run: npm i && npm run build-coupled

- name: Build WASM
working-directory: ./pagefind_web
run: ./local_build.sh

- name: Build UI
working-directory: ./pagefind_ui/default
run: npm i && npm run build

- name: Build Modular UI
working-directory: ./pagefind_ui/modular
run: npm i && npm run build

- name: Test Web
working-directory: ./pagefind_web
run: cargo test --release

- name: Build Testing Binary
working-directory: ./pagefind
run: cargo build --release --features extended

- name: Upload Testing Binary
uses: actions/upload-artifact@v4
with:
name: pagefind-${{ matrix.target }}
path: target/release/pagefind${{ matrix.build == 'windows' && '.exe' || '' }}

- name: Test Lib
working-directory: ./pagefind
run: cargo test --release --lib --features extended

- name: Test CLI
run: ./test_ci.sh "release"
# - name: Cache
# uses: actions/cache@v4
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# ~/.rustup
# target
# key: ${{ runner.os }}-${{ matrix.rust }}-min165

# - uses: actions/setup-node@v4
# with:
# node-version: 20

# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: ${{ matrix.rust }}
# target: ${{ matrix.target }}
# override: true
# default: true
# components: rustfmt, clippy

# - name: Check versions
# run: |
# cargo --version
# rustc --version

# - name: Install wasm-pack
# uses: jetli/[email protected]
# with:
# version: ${{env.WASM_PACK_VERSION}}

# - name: Build Coupled JS
# working-directory: ./pagefind_web_js
# run: npm i && npm run build-coupled

# - name: Build WASM
# working-directory: ./pagefind_web
# run: ./local_build.sh

# - name: Build UI
# working-directory: ./pagefind_ui/default
# run: npm i && npm run build

# - name: Build Modular UI
# working-directory: ./pagefind_ui/modular
# run: npm i && npm run build

# - name: Test Web
# working-directory: ./pagefind_web
# run: cargo test --release

# - name: Build Testing Binary
# working-directory: ./pagefind
# run: cargo build --release --features extended

# - name: Upload Testing Binary
# uses: actions/upload-artifact@v4
# with:
# name: pagefind-${{ matrix.target }}
# path: target/release/pagefind${{ matrix.build == 'windows' && '.exe' || '' }}

# - name: Test Lib
# working-directory: ./pagefind
# run: cargo test --release --lib --features extended

# - name: Test CLI
# run: ./test_ci.sh "release"

- name: Set up python 3.12
uses: actions/setup-python@v5
Expand All @@ -131,12 +131,9 @@ jobs:
- name: Install dev dependencies
run: ./wrappers/python/scripts/ci/github/install_dev_dependencies.sh

- name: activate venv on windows
if: runner.os == 'Windows'
shell: pwsh
working-directory: ./wrappers/python
run: .\.venv\Scripts\Activate.ps1

- name: activate venv
run: ./wrappers/python/scripts/ci/github/activate_venv.sh

- name: debug python paths
run: ./wrappers/python/scripts/ci/github/debug_python_paths.sh

Expand All @@ -145,18 +142,18 @@ jobs:
working-directory: ./wrappers/python
run: |
export VIRTUAL_ENV="$PWD/.venv"
export PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH="$VIRTUAL_ENV/bin:$VIRTUAL_ENV/Scripts:$PATH"
bash ./scripts/ci/python_lints.sh
- name: ensure cog up-to-date
if: runner.os == 'Linux'
# if: runner.os == 'Linux'
working-directory: ./wrappers/python
run: |
export VIRTUAL_ENV="$PWD/.venv"
export PATH="$VIRTUAL_ENV/bin:$PATH"
./scripts/ci/cog/check.sh
- name: Test python API
timeout-minutes: 1
run: ./wrappers/python/scripts/ci/github/integration_tests.sh
# - name: Test python API
# timeout-minutes: 1
# run: ./wrappers/python/scripts/ci/github/integration_tests.sh

25 changes: 25 additions & 0 deletions wrappers/python/scripts/ci/github/activate_venv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -eu

cd wrappers/python

VIRTUAL_ENV="$PWD/.venv"
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> "$GITHUB_ENV"

if ! [ -d "$VIRTUAL_ENV" ]; then
echo "No virtualenv found at $VIRTUAL_ENV"
exit 127
fi

# Ensure binaries from the virtualenv are available at the start of $PATH
# see https://docs.python.org/3/library/venv.html#creating-virtual-environments
if [ -d "$VIRTUAL_ENV/bin" ]; then
# on unix systems, virtualenv puts executables in .venv/bin
venv_bin_path="$VIRTUAL_ENV/bin"
elif [ -d "$VIRTUAL_ENV/Scripts" ]; then
# on windows, virtualenv places executables in .venv/Scripts
venv_bin_path="$VIRTUAL_ENV/Scripts"
fi

echo "$venv_bin_path" >> "$GITHUB_PATH"
# see https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-system-path
7 changes: 4 additions & 3 deletions wrappers/python/scripts/ci/github/debug_python_paths.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash
set -eu
cd wrappers/python
export VIRTUAL_ENV="$PWD/.venv"
export PATH="$VIRTUAL_ENV/bin:$PATH"

echo "VIRTUAL_ENV=$VIRTUAL_ENV"

# shellcheck disable=SC2016
echo '$PATH:'
echo "$PATH" | tr ':' '\n - '
Expand All @@ -17,5 +18,5 @@ if ! command -v mypy; then
echo "missing mypy{.exe}"
fi
fi
stat ./.venv/bin/python || stat ./.venv/bin/python.exe || echo "missing .venv/bin/python{.exe}"
stat ./.venv/bin/python || stat ./.venv/Scripts/python.exe || echo "missing .venv/bin/python{.exe}"
python --version

0 comments on commit efb9ec1

Please sign in to comment.