Skip to content

Commit

Permalink
add venv activation to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvinSchiller authored Feb 1, 2024
1 parent 6219f71 commit 86b210e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
1 change: 1 addition & 0 deletions .githooks/post-merge
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ warn_python_requirements() {
echo "ATTENTION: Python requirements have changed since last pull!"
echo ""
echo "To update python requirements on the RPi run"
echo "$ source .venv/bin/activate"
echo "$ python -m pip install --upgrade -r requirements.txt"
echo "************************************************************"
echo -e "\n"
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/codeql-analysis_v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ jobs:
- name: Install dependencies
run: |
# Install necessary packages
sudo apt-get install libasound2-dev pulseaudio
sudo apt-get install libasound2-dev pulseaudio python3-venv
python3 -m venv .venv
source ".venv/bin/activate"
python -m pip install --upgrade pip
pip install -r requirements.txt
# Set the `CODEQL-PYTHON` environment variable to the Python executable
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pythonpackage_future3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev pulseaudio
sudo apt-get install -y libasound2-dev pulseaudio python3-venv
python3 -m venv .venv
source ".venv/bin/activate"
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
# For operation of the Jukebox, ZMQ must be compiled from sources due to Websocket support
Expand All @@ -51,7 +54,6 @@ jobs:
parallel: true
- name: Lint with flake8
run: |
pip3 install flake8
# Stop the build if linting fails
./run_flake8.sh
Expand Down
10 changes: 7 additions & 3 deletions run_docgeneration.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/usr/bin/env bash

# Runner script for pydoc-markdown to ensure
# Runner script to ensure
# - correct venv activation
# - independent from working directory

# Change working directory to location of script
# Change working directory to project root
SOURCE=${BASH_SOURCE[0]}
SCRIPT_DIR="$(dirname "$SOURCE")"
cd "$SCRIPT_DIR" || { echo "Could not change to top-level project directory"; exit 1; }
PROJECT_ROOT="$SCRIPT_DIR"
cd "$PROJECT_ROOT" || { echo "Could not change directory"; exit 1; }

source .venv/bin/activate || { echo "ERROR: Failed to activate virtual environment for python"; exit 1; }

# Run pydoc-markdown
# make sure, directory exists
Expand Down
11 changes: 7 additions & 4 deletions run_flake8.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/usr/bin/env bash

# Runner script for flak8 to ensure
# - correct config file
# Runner script to ensure
# - correct venv activation
# - independent from working directory

# Change working directory to location of script
# Change working directory to project root
SOURCE=${BASH_SOURCE[0]}
SCRIPT_DIR="$(dirname "$SOURCE")"
cd "$SCRIPT_DIR" || { echo "Could not change to top-level project directory"; exit 1; }
PROJECT_ROOT="$SCRIPT_DIR"
cd "$PROJECT_ROOT" || { echo "Could not change directory"; exit 1; }

source .venv/bin/activate || { echo "ERROR: Failed to activate virtual environment for python"; exit 1; }

# Run flake8
flake8 --config .flake8 "$@"
11 changes: 7 additions & 4 deletions run_pytest.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/usr/bin/env bash

# Runner script for pytest to ensure
# - correct config file
# Runner script to ensure
# - correct venv activation
# - independent from working directory

# Change working directory to location of script
# Change working directory to project root
SOURCE=${BASH_SOURCE[0]}
SCRIPT_DIR="$(dirname "$SOURCE")"
cd "$SCRIPT_DIR" || { echo "Could not change to top-level project directory"; exit 1; }
PROJECT_ROOT="$SCRIPT_DIR"
cd "$PROJECT_ROOT" || { echo "Could not change directory"; exit 1; }

source .venv/bin/activate || { echo "ERROR: Failed to activate virtual environment for python"; exit 1; }

# Run pytest
pytest -c pytest.ini $@

0 comments on commit 86b210e

Please sign in to comment.