From b5e45e749b18bc17de07ba765eb01225a1974e7c Mon Sep 17 00:00:00 2001 From: Steven Kalt Date: Sat, 28 Sep 2024 09:21:17 -0400 Subject: [PATCH] ci(wrappers/python): debug windows .venv path quirk --- .github/workflows/test.yml | 161 +++++++++--------- .../python/scripts/ci/github/activate_venv.sh | 25 +++ .../scripts/ci/github/debug_python_paths.sh | 26 ++- 3 files changed, 125 insertions(+), 87 deletions(-) create mode 100755 wrappers/python/scripts/ci/github/activate_venv.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61baecdd..93de2117 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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/wasm-pack-action@v0.4.0 - 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/wasm-pack-action@v0.4.0 + # 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 @@ -131,32 +131,27 @@ 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 - name: Lint python # if: runner.os == 'Linux' working-directory: ./wrappers/python - run: | - export VIRTUAL_ENV="$PWD/.venv" - export PATH="$VIRTUAL_ENV/bin:$PATH" - bash ./scripts/ci/python_lints.sh + shell: bash + run: ./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 diff --git a/wrappers/python/scripts/ci/github/activate_venv.sh b/wrappers/python/scripts/ci/github/activate_venv.sh new file mode 100755 index 00000000..1b0c681b --- /dev/null +++ b/wrappers/python/scripts/ci/github/activate_venv.sh @@ -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 diff --git a/wrappers/python/scripts/ci/github/debug_python_paths.sh b/wrappers/python/scripts/ci/github/debug_python_paths.sh index 580cb601..ae301b85 100755 --- a/wrappers/python/scripts/ci/github/debug_python_paths.sh +++ b/wrappers/python/scripts/ci/github/debug_python_paths.sh @@ -1,15 +1,34 @@ #!/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 - ' +echo +echo " python ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " +echo + +python --version command -v python command -v python3 +stat ./.venv/bin/python \ + || stat ./.venv/Scripts/python.exe \ + || echo "missing .venv/bin/python{.exe}" + +echo +echo " poetry ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " +echo + command -v poetry || echo "missing poetry" + +echo +echo " mypy ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " +echo + if ! command -v mypy; then if command -v mypy.exe; then echo "missing mypy, but found mypy.exe" @@ -17,5 +36,4 @@ 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}" -python --version +