From 22d3ab06f7af39419817c6a404208011e8ef5a5d Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Sat, 27 Jul 2024 14:12:05 -0700 Subject: [PATCH] [CI] Add new runner: Ubuntu 2404 (#1115) ## Description Add Ubuntu 24.04 as new runner. Also fixed many mistakes in `tests.yml`, cache failure, and old use of deprecated actions --- .github/workflows/run-tests.yml | 69 ------------------------- .github/workflows/tests.yml | 92 +++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 69 deletions(-) delete mode 100644 .github/workflows/run-tests.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml deleted file mode 100644 index 25630363f..000000000 --- a/.github/workflows/run-tests.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: CI Test for GEF - -on: - push: - branches: - - main - - pull_request: - branches: - - main - -jobs: - build: - strategy: - fail-fast: false - matrix: - os: - - ubuntu-22.04 - - ubuntu-20.04 - name: "Run Unit tests on ${{ matrix.os }}" - runs-on: ${{ matrix.os }} - defaults: - run: - shell: bash - - steps: - - uses: actions/checkout@v3 - - - name: Install python and toolchain - run: | - sudo apt-get update - sudo apt-get install -y gdb-multiarch python3-dev python3-pip python3-wheel python3-setuptools git cmake gcc g++ pkg-config libglib2.0-dev gdbserver qemu-user - sudo python3 -m pip install --upgrade pip - - - name: Set runtime environment variables - run: | - echo PY_VER=`gdb -q -nx -ex "pi print('.'.join(map(str, sys.version_info[:2])))" -ex quit` >> $GITHUB_ENV - echo GEF_CI_NB_CPU=`grep -c ^processor /proc/cpuinfo` >> $GITHUB_ENV - echo GEF_CI_ARCH=`uname --processor` >> $GITHUB_ENV - echo GEF_CI_CACHE_DIR=`python3 -m pip cache dir` >> $GITHUB_ENV - - - name: Cache dependencies - uses: actions/cache@v3 - id: cache-deps - env: - cache-name: cache-deps - with: - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - path: ${{ env.GEF_CI_CACHE_DIR }} - restore-keys: - ${{ runner.os }}-pip-${{ env.cache-name }}- - ${{ runner.os }}-pip- - ${{ runner.os }}-${{ env.cache-name }}- - ${{ runner.os }}- - - - name: Install Python Requirements - run: | - mkdir -p ${{ env.GEF_CI_CACHE_DIR }} - python${{ env.PY_VER }} -m pip install --user --upgrade -r tests/requirements.txt - - - name: Setup GEF - run: | - echo "source $(pwd)/gef.py" > ~/.gdbinit - gdb -q -ex 'gef missing' -ex 'gef help' -ex 'gef config' -ex start -ex continue -ex quit /bin/pwd - - - name: Run Tests - run: | - make -C tests/binaries -j ${{ env.GEF_CI_NB_CPU }} - python${{ env.PY_VER }} -m pytest --forked -n ${{ env.GEF_CI_NB_CPU }} -v -m "not benchmark" tests/ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..34286663e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,92 @@ +name: Tests + +env: + GEF_CI_CACHE_DIR: /tmp + PY_VER: 0 + GEF_CI_NB_CPU: 1 + +on: + push: + branches: + - main + + pull_request: + branches: + - main + +jobs: + build: + strategy: + fail-fast: false + matrix: + runner: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04] + + name: "Run Unit tests on ${{ matrix.runner }}" + runs-on: ${{ matrix.runner }} + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v4 + + - name: Install python and toolchain + run: | + export NEEDRESTART_MODE=n + sudo apt-get update + sudo apt-get install -y gdb-multiarch python3-dev python3-pip python3-wheel python3-setuptools git cmake gcc g++ pkg-config libglib2.0-dev gdbserver qemu-user + + - name: Install python and toolchain + if: matrix.runner == 'ubuntu-24.04' + run: | + sudo apt-get install -y python3-full + + - name: Install python and toolchain + if: matrix.runner != 'ubuntu-24.04' + run: | + python3 -m pip install pip -U + + - name: Set runtime environment variables + run: | + echo PY_VER=`gdb -q -nx -ex "pi print('.'.join(map(str, sys.version_info[:2])))" -ex quit` >> $GITHUB_ENV + echo GEF_CI_NB_CPU="`grep -c ^processor /proc/cpuinfo`" >> $GITHUB_ENV + echo GEF_CI_ARCH="`uname --processor`" >> $GITHUB_ENV + echo GEF_CI_CACHE_DIR="`python3 -m pip cache dir`" >> $GITHUB_ENV + + - name: Cache dependencies + uses: actions/cache@v4 + id: cache-deps + env: + cache-name: cache-deps + with: + key: ${{ matrix.runner }}-pip-${{ hashFiles('**/requirements.txt') }} + path: ${{ env.GEF_CI_CACHE_DIR }} + restore-keys: + ${{ matrix.runner }}-pip-${{ env.cache-name }}- + ${{ matrix.runner }}-pip- + ${{ matrix.runner }}-${{ env.cache-name }}- + ${{ matrix.runner }}- + + - name: Install python and toolchain + if: matrix.runner != 'ubuntu-24.04' + run: | + test "${{ env.PY_VER }}" == "0" && exit 1 + mkdir -p ${{ env.GEF_CI_CACHE_DIR }} + python${{ env.PY_VER }} -m pip install --user --upgrade -r tests/requirements.txt + + - name: Install Python Requirements + if: matrix.runner == 'ubuntu-24.04' + run: | + test "${{ env.PY_VER }}" == "0" && exit 1 + mkdir -p ${{ env.GEF_CI_CACHE_DIR }} + python${{ env.PY_VER }} -m pip install --break-system-packages --user --upgrade -r tests/requirements.txt + + - name: Setup GEF + run: | + echo "source $(pwd)/gef.py" > ~/.gdbinit + gdb -q -ex 'gef missing' -ex 'gef help' -ex 'gef config' -ex start -ex continue -ex quit /bin/pwd + + - name: Run Tests + run: | + make -C tests/binaries -j ${{ env.GEF_CI_NB_CPU }} + python${{ env.PY_VER }} -m pytest --forked -n ${{ env.GEF_CI_NB_CPU }} -v -m "not benchmark" tests/