From 1709ece94a88f24569c04e78912431b5094d9869 Mon Sep 17 00:00:00 2001 From: Stephanie Eng Date: Fri, 26 Jul 2024 09:04:08 -0400 Subject: [PATCH] Use venv in CI (#916) * Use venv in CI * Update htmlproofer instructions * Add a comment about venv * Reference which script "the script" means * Format --- .github/workflows/deploy.yml | 12 ++++++++++-- .../how_to_contribute_to_site.rst | 15 ++++++++++++++- htmlproofer.sh | 3 ++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index aee6089dbc..ac180e8207 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,9 +22,12 @@ jobs: - uses: actions/checkout@v4 - name: Install Python dependencies + shell: bash run: | sudo apt-get update -y - sudo apt-get install -y python3-pip + sudo apt-get install -y python3-pip python3-venv + python3 -m venv .venv + source .venv/bin/activate pip3 install --upgrade --requirement requirements.txt - name: Install doxygen and graphviz @@ -39,6 +42,7 @@ jobs: run: | source /opt/ros/rolling/setup.bash source /root/ws_moveit/install/setup.bash + source .venv/bin/activate ./htmlproofer.sh upload_site_artifacts: @@ -58,9 +62,12 @@ jobs: - uses: actions/checkout@v4 - name: Install Python dependencies + shell: bash run: | sudo apt-get update -y - sudo apt-get install -y python3-pip + sudo apt-get install -y python3-pip python3-venv + python3 -m venv .venv + source .venv/bin/activate pip3 install --upgrade --requirement requirements.txt - name: Install doxygen and graphviz @@ -71,6 +78,7 @@ jobs: run: | source /opt/ros/${{ matrix.rosdistro }}/setup.bash source /root/ws_moveit/install/setup.bash + source .venv/bin/activate make generate_api_artifacts BRANCH=${{ matrix.branch }} - name: Compress Artifact diff --git a/doc/how_to_contribute/how_to_contribute_to_site.rst b/doc/how_to_contribute/how_to_contribute_to_site.rst index 46c995f8e3..4addc1e57a 100644 --- a/doc/how_to_contribute/how_to_contribute_to_site.rst +++ b/doc/how_to_contribute/how_to_contribute_to_site.rst @@ -40,7 +40,20 @@ Steps 2. Test for broken links - To test for broken links run this command: + To test for broken links, run the ``htmlproofer`` script. Note that running this script may require you to install some Python dependencies. If using ``pip`` to install these dependencies, you may want to create a virtual environment. + + .. code-block:: bash + + python3 -m venv .venv + source .venv/bin/activate + + You can then install requirements using ``pip``: + + .. code-block:: bash + + pip3 install --upgrade --requirement requirements.txt + + You can run the ``htmlproofer`` script with this command: .. code-block:: bash diff --git a/htmlproofer.sh b/htmlproofer.sh index a01ca9bef3..77c547a6e8 100755 --- a/htmlproofer.sh +++ b/htmlproofer.sh @@ -1,4 +1,5 @@ #!/bin/bash +# Note that a virtual environment is required when running this script in CI set -e # Define some config vars @@ -12,7 +13,7 @@ gem install --user-install html-proofer -v 3.19.4 # newer 4.x requires different PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin:$PATH" # Install python dependencies -pip3 install --user --upgrade -r requirements.txt +pip3 install --upgrade -r requirements.txt # Clear out any previous builds rm -rf build