diff --git a/.github/actions/install/cmake/action.yml b/.github/actions/install/cmake/action.yml new file mode 100644 index 0000000..8627f7e --- /dev/null +++ b/.github/actions/install/cmake/action.yml @@ -0,0 +1,39 @@ +name: Install CMake +description: Download, Build and Cache CMake +inputs: + version: + description: The desired CMake version to install + required: true + url: + description: "The corresponding URL to download the source code from" + required: true +runs: + using: composite + steps: + - name: Cache CMake + id: cache-cmake + uses: actions/cache@v3 + with: + path: cmake-${{ inputs.version }} + key: ${{ runner.name }}-${{ runner.os }}-${{ runner.arch }}-cmake-${{ inputs.version }} + - name: Build cmake + if: steps.cache-cmake.outputs.cache-hit != 'true' + run: | + wget ${{ inputs.url }} + tar -zxf cmake-${{ inputs.version }}.tar.gz + cd cmake-${{ inputs.version }} + ./bootstrap + make -j $(nproc) + shell: bash + - name: Install cmake + run: | + cd cmake-${{ inputs.version }} + # Depending if we run in on a GitHub Actions or from within a Docker image we have different permissions + if [[ $EUID > 0 ]]; then + # If we are not root then we need to sudo + sudo make install + else + # Default docker image does not have users setup so we are only root and can not sudo + make install + fi + shell: bash diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 973304b..b7b53ed 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -74,31 +74,12 @@ jobs: min-req: runs-on: ubuntu-20.04 - env: - RUN_ON: ubuntu-20.04 - CMAKE_URL: https://cmake.org/files/v3.14/cmake-3.14.7.tar.gz - CMAKE_VERSION: 3.14.7 steps: - uses: actions/checkout@v3 - - name: Cache CMake - id: cache-cmake - uses: actions/cache@v3 + - uses: ./.github/actions/install/cmake with: - path: cmake-${{ env.CMAKE_VERSION }} - key: ubuntu-20.04-${{ github.job }}-cmake-${{ env.CMAKE_VERSION }} - - name: Build cmake - if: steps.cache-cmake.outputs.cache-hit != 'true' - run: | - wget ${{ env.CMAKE_URL }} - tar -zxf cmake-${{ env.CMAKE_VERSION }}.tar.gz - cd cmake-${{ env.CMAKE_VERSION }} - ./bootstrap - make -j $(nproc) - - name: Install cmake - run: | - cd cmake-${{ env.CMAKE_VERSION }} - sudo make install - + version: "3.14.7" + url: "https://cmake.org/files/v3.14/cmake-3.14.7.tar.gz" - uses: ./.github/actions/install/gtest - name: setup diff --git a/.github/workflows/targets.yml b/.github/workflows/targets.yml index 1484ea1..01028d7 100644 --- a/.github/workflows/targets.yml +++ b/.github/workflows/targets.yml @@ -16,18 +16,28 @@ on: jobs: gcc-4-8: name: GCC 4.8 - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest + container: + image: ubuntu:18.04 + env: + CC: /usr/bin/gcc-4.8 + CXX: /usr/bin/g++-4.8 steps: - - run: sudo apt-get install g++-4.8 - - uses: lukka/get-cmake@latest + - run: | + apt-get update + apt-get install -y g++-4.8 wget make libssl-dev - uses: actions/checkout@v3 + - uses: ./.github/actions/install/cmake + with: + version: "3.26.3" + url: "https://cmake.org/files/v3.26/cmake-3.26.3.tar.gz" - name: setup run: | mkdir build cd build - CC=gcc-4.8 CXX=g++-4.8 cmake .. - sudo cmake --install . + cmake .. + cmake --install . - name: test working-directory: tests/cmake run: |