Blob Blame History Raw
From 365836e811cfaf4d844cdcbcb889865a8e0d3beb Mon Sep 17 00:00:00 2001
From: Ilya Maximets <i.maximets@ovn.org>
Date: Fri, 12 Mar 2021 19:25:25 +0100
Subject: [PATCH 01/16] ci: Fix handling of python packages.

GitHub Actions doesn't have python locations in PATH and different
runners might have different configuration for default python
location and versions.  For example, on some runners python2 might
be installed or not.

Missing PATH causes weird situations where during one run our scripts
can locate just installed flake8 and can't do that on a different run.

Also, we're mistakenly installing python2 version of flake8.
On runners that able to locate installed flake8 this causes breakage
of a flake8-check build target because our python scripts written for
python3.  And runners that can't locate flake8 works just fine and
job succeeds.

It's required to use actions/setup-python@v2 in order to have
predictable version of python installed and paths correctly configured.
Due to some bugs in GHA itself it doesn't set $HOME/.local/bin into
PATH, so we have to do that manually for now in order to use '--user'.

Unfortunately actions/setup-python@v2 also makes invisible python
packages installed from Ubuntu repositories.  Switching them to
'pip3 install'.

'six' package is not needed, so it's dropped.

Fixes: ecdd790ecbff ("CI: Add github actions workflow.")
Reported-by: Numan Siddique <numans@ovn.org>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
(cherry picked from commit 338a6ddb5ea1c89b48c484b0448a216a82225adc)
---
 .ci/linux-prepare.sh       |  4 ++--
 .github/workflows/test.yml | 23 ++++++++++++++++++++---
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/.ci/linux-prepare.sh b/.ci/linux-prepare.sh
index 0bb0ff096..83ad3958b 100755
--- a/.ci/linux-prepare.sh
+++ b/.ci/linux-prepare.sh
@@ -12,5 +12,5 @@ set -ev
 git clone git://git.kernel.org/pub/scm/devel/sparse/sparse.git
 cd sparse && make -j4 HAVE_LLVM= HAVE_SQLITE= install && cd ..
 
-pip install --disable-pip-version-check --user six flake8 hacking
-pip install --user --upgrade docutils
+pip3 install --disable-pip-version-check --user flake8 hacking sphinx pyOpenSSL
+pip3 install --upgrade --user docutils
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index f3a53a8b6..91bd1e538 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -13,7 +13,6 @@ jobs:
       dependencies: |
         automake libtool gcc bc libjemalloc1 libjemalloc-dev    \
         libssl-dev llvm-dev libelf-dev libnuma-dev libpcap-dev  \
-        python3-openssl python3-pip python3-sphinx              \
         selinux-policy-dev
       m32_dependecies: gcc-multilib
       CC:          ${{ matrix.compiler }}
@@ -88,11 +87,21 @@ jobs:
       if:   matrix.m32 != ''
       run:  sudo apt install -y ${{ env.m32_dependecies }}
 
+    - name: update PATH
+      run:  |
+        echo "$HOME/bin"        >> $GITHUB_PATH
+        echo "$HOME/.local/bin" >> $GITHUB_PATH
+
+    - name: set up python
+      uses: actions/setup-python@v2
+      with:
+        python-version: '3.x'
+
     - name: prepare
       run:  ./.ci/linux-prepare.sh
 
     - name: build
-      run:  PATH="$PATH:$HOME/bin" ./.ci/linux-build.sh
+      run:  ./.ci/linux-build.sh
 
     - name: copy logs on failure
       if: failure() || cancelled()
@@ -145,10 +154,18 @@ jobs:
         ref: 'master'
     - name: install dependencies
       run:  brew install automake libtool
+    - name: update PATH
+      run:  |
+        echo "$HOME/bin"        >> $GITHUB_PATH
+        echo "$HOME/.local/bin" >> $GITHUB_PATH
+    - name: set up python
+      uses: actions/setup-python@v2
+      with:
+        python-version: '3.x'
     - name: prepare
       run:  ./.ci/osx-prepare.sh
     - name: build
-      run:  PATH="$PATH:$HOME/bin" ./.ci/osx-build.sh
+      run:  ./.ci/osx-build.sh
     - name: upload logs on failure
       if: failure()
       uses: actions/upload-artifact@v2
-- 
2.29.2