From d254d704f469b0e7d784e383597bfbd94b6d63de Mon Sep 17 00:00:00 2001 From: Boris Dalstein Date: Wed, 1 Jan 2025 18:34:06 +0100 Subject: [PATCH] Fix Ubuntu 18.04 containers fail since Node16 removal in GitHub-hosted runners (#27) --- .../ubuntu-18.04-docker-custom-image.yml | 113 +++-------- ...untu-18.04-docker-minimal-custom-image.yml | 39 ++-- .../workflows/ubuntu-18.04-docker-minimal.yml | 39 ++-- .github/workflows/ubuntu-18.04-docker.yml | 189 +++++++----------- 4 files changed, 156 insertions(+), 224 deletions(-) diff --git a/.github/workflows/ubuntu-18.04-docker-custom-image.yml b/.github/workflows/ubuntu-18.04-docker-custom-image.yml index a3b97c0..4e61f21 100644 --- a/.github/workflows/ubuntu-18.04-docker-custom-image.yml +++ b/.github/workflows/ubuntu-18.04-docker-custom-image.yml @@ -1,35 +1,24 @@ name: Ubuntu 18.04 (Docker Custom Image) - on: [push, pull_request] - env: + CONTAINER: dalboris/test-cpp-github-actions-docker-ubuntu-18.04 BUILD_TYPE: Release QT_VERSION: 5.12.5 PARALLEL_JOBS: 5 - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true - # https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/ jobs: build: name: Build runs-on: ubuntu-latest - container: dalboris/test-cpp-github-actions-docker-ubuntu-18.04 - outputs: - artifacts-cache-key: ${{steps.artifacts.outputs.cache-key}} - steps: - # Fix "fatal: detected dubious ownership in repository at '/__w//'"" - - name: Add GitHub workspace to Git safe directories - run: git config --global --add safe.directory `pwd` - # By default, actions/checkout will only check out the last commit. For # pull requests, this is a temporary merge commit used to test integration # against the master branch. Therefore, in order to get the actual commit # message we are interested in, we need to fetch more than one commit. # Getting more commits can also be helpful for computing human-readable # commit ID, such as 2020-12-16.3 for the 4th commit of the day. - - uses: actions/checkout@v3 # Cannot use v4 (requires Node20/GLIBC_2.28 not available on Ubuntu 18.04) + - uses: actions/checkout@v4 with: fetch-depth: 100 @@ -89,83 +78,41 @@ jobs: echo "COMMIT_BRANCH: $COMMIT_BRANCH" echo "COMMIT_MESSAGE: $COMMIT_MESSAGE" - - name: Install Dependencies + # We manually start a container and execute scripts in it instead of using `jobs.build.container`, + # otherwise we couldn't use GitHub-provided actions (checkout, cache, etc.) as they rely on Node20 + # which would not necessarily be available on some containers (e.g., Ubuntu 18.04). + # + # See: https://github.com/actions/checkout/issues/1590 + # + - name: Start Docker Container run: | - apt-get update - apt-get install -y libharfbuzz-dev + docker pull $CONTAINER + docker run --name build-container -d -v ${{ github.workspace }}:/workspace $CONTAINER tail -f /dev/null + + - name: Install Dependencies + env: + SCRIPT: | + apt-get update + apt-get install -y libharfbuzz-dev + run: docker exec build-container bash -c "$SCRIPT" - name: Configure - working-directory: ${{github.workspace}} - run: | - mkdir build - cd build - cmake --version - cmake .. -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DQt5_DIR="/opt/qt/$QT_VERSION/gcc_64/lib/cmake/Qt5" + env: + SCRIPT: | + cd /workspace && mkdir build && cd build + cmake --version + cmake .. -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DQt5_DIR="/opt/qt/${{env.QT_VERSION}}/gcc_64/lib/cmake/Qt5" + run: docker exec build-container bash -c "$SCRIPT" - name: Build - working-directory: ${{github.workspace}}/build - run: | - cmake --build . --parallel $PARALLEL_JOBS - - - name: Prepare Artifacts - id: artifacts - working-directory: ${{github.workspace}} - run: | - mkdir artifacts - cp build/*.so artifacts - cackeKey=`date -u +"%Y-%m-%d"`-$GITHUB_RUN_ID - echo "cache-key=$cackeKey" >> "$GITHUB_OUTPUT" - - # We cannot use upload-artifact@v4 on Ubuntu 18.04 as it requires Node 20. - # - # We cannot use upload-artifact@v3 as it is deprecated and will be removed on Nov 30, 2024: - # - # https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/ - # - # Therefore with use GitHub cache instead of GitHub artifacts, and in a subsequent job - # using ubuntu-latest, we retrieve the cache and upload it using upload-artifact@v4. - # - # We cannot use cache@v4 on Ubuntu 18.04 as it requires Node 20. - # - # We cannot use the latest cache@v3 (as of 3.3.3) as it is buggy and does not - # properly support enableCrossOsArchive and fail-on-cache-miss anymore. - # - # Therefore, we use cache@v3.2.4, which is the first version supporting both - # enableCrossOsArchive and fail-on-cache-miss. - # - # Note that we do need `enableCrossOsArchive` otherwise the ubuntu:18.04 - # Docker image and the ubuntu-latest image are considered different and - # do not share cache, that is, theyhave a different "cache version", see: - # - # - https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cross-os-cache - # - https://github.com/marketplace/actions/cache#cache-version - # - - name: Save Artifacts - uses: actions/cache/save@v3.2.4 - if: always() # If we re-run the job, we want to override the cache - with: - path: artifacts - key: ${{steps.artifacts.outputs.cache-key}} - enableCrossOsArchive: true - - # This is a separate job running on ubuntu-latest to be able to use upload-artifact@v4 - # - upload-artifacts: - name: Upload Artifacts - runs-on: ubuntu-latest - needs: build - steps: - - - name: Restore Artifacts - uses: actions/cache/restore@v3.2.4 - with: - path: artifacts - key: ${{needs.build.outputs.artifacts-cache-key}} - enableCrossOsArchive: true - fail-on-cache-miss: true + env: + SCRIPT: | + cd /workspace/build + cmake --build . --parallel ${{env.PARALLEL_JOBS}} + run: docker exec build-container bash -c "$SCRIPT" - name: Upload Artifacts uses: actions/upload-artifact@v4 with: name: artifacts - path: artifacts + path: ${{github.workspace}}/build/*.so diff --git a/.github/workflows/ubuntu-18.04-docker-minimal-custom-image.yml b/.github/workflows/ubuntu-18.04-docker-minimal-custom-image.yml index 5727086..f9cd656 100644 --- a/.github/workflows/ubuntu-18.04-docker-minimal-custom-image.yml +++ b/.github/workflows/ubuntu-18.04-docker-minimal-custom-image.yml @@ -1,27 +1,38 @@ name: Ubuntu 18.04 (Docker Minimal Custom Image) on: [push, pull_request] env: - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true - # https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/ + CONTAINER: dalboris/test-cpp-github-actions-docker-ubuntu-18.04-minimal jobs: build: runs-on: ubuntu-latest - container: dalboris/test-cpp-github-actions-docker-ubuntu-18.04-minimal steps: - - uses: actions/checkout@v3 # Cannot use v4 (requires Node20/GLIBC_2.28 not available on Ubuntu 18.04) + - uses: actions/checkout@v4 - - name: Install Dependencies + # We manually start a container and execute scripts in it instead of using `jobs.build.container`, + # otherwise we couldn't use GitHub-provided actions (checkout, cache, etc.) as they rely on Node20 + # which would not necessarily be available on some containers (e.g., Ubuntu 18.04). + # + # See: https://github.com/actions/checkout/issues/1590 + # + - name: Start Docker Container run: | - apt-get update - apt-get install -y libharfbuzz-dev + docker pull $CONTAINER + docker run --name build-container -d -v ${{ github.workspace }}:/workspace $CONTAINER tail -f /dev/null + + - name: Install Dependencies + env: + SCRIPT: | + apt-get update + apt-get install -y libharfbuzz-dev + run: docker exec build-container bash -c "$SCRIPT" - name: Build - working-directory: ${{github.workspace}} - run: | - mkdir build - cd build - cmake --version - cmake .. -DCMAKE_BUILD_TYPE=Release - cmake --build . + env: + SCRIPT: | + cd /workspace && mkdir build && cd build + cmake --version + cmake .. -DCMAKE_BUILD_TYPE=Release + cmake --build . + run: docker exec build-container bash -c "$SCRIPT" diff --git a/.github/workflows/ubuntu-18.04-docker-minimal.yml b/.github/workflows/ubuntu-18.04-docker-minimal.yml index d0e054d..961913a 100644 --- a/.github/workflows/ubuntu-18.04-docker-minimal.yml +++ b/.github/workflows/ubuntu-18.04-docker-minimal.yml @@ -1,27 +1,38 @@ name: Ubuntu 18.04 (Docker Minimal) on: [push, pull_request] env: - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true - # https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/ + CONTAINER: ubuntu:18.04 jobs: build: runs-on: ubuntu-latest - container: ubuntu:18.04 steps: - - uses: actions/checkout@v3 # Cannot use v4 (requires Node20/GLIBC_2.28 not available on Ubuntu 18.04) + - uses: actions/checkout@v4 - - name: Install Dependencies + # We manually start a container and execute scripts in it instead of using `jobs.build.container`, + # otherwise we couldn't use GitHub-provided actions (checkout, cache, etc.) as they rely on Node20 + # which would not necessarily be available on some containers (e.g., Ubuntu 18.04). + # + # See: https://github.com/actions/checkout/issues/1590 + # + - name: Start Docker Container run: | - apt-get update - apt-get install -y cmake build-essential libfreetype6-dev libharfbuzz-dev + docker pull $CONTAINER + docker run --name build-container -d -v ${{ github.workspace }}:/workspace $CONTAINER tail -f /dev/null + + - name: Install Dependencies + env: + SCRIPT: | + apt-get update + apt-get install -y cmake build-essential libfreetype6-dev libharfbuzz-dev + run: docker exec build-container bash -c "$SCRIPT" - name: Build - working-directory: ${{github.workspace}} - run: | - mkdir build - cd build - cmake --version - cmake .. -DCMAKE_BUILD_TYPE=Release - cmake --build . + env: + SCRIPT: | + cd /workspace && mkdir build && cd build + cmake --version + cmake .. -DCMAKE_BUILD_TYPE=Release + cmake --build . + run: docker exec build-container bash -c "$SCRIPT" diff --git a/.github/workflows/ubuntu-18.04-docker.yml b/.github/workflows/ubuntu-18.04-docker.yml index ba82006..fd8a5ce 100644 --- a/.github/workflows/ubuntu-18.04-docker.yml +++ b/.github/workflows/ubuntu-18.04-docker.yml @@ -1,59 +1,25 @@ name: Ubuntu 18.04 (Docker) - on: [push, pull_request] - env: + CONTAINER: ubuntu:18.04 BUILD_TYPE: Release QT_VERSION: 5.12.5 PYTHON_VERSION: 3.7 PARALLEL_JOBS: 5 - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true - # https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/ - jobs: build: name: Build runs-on: ubuntu-latest - container: ubuntu:18.04 - outputs: - artifacts-cache-key: ${{steps.artifacts.outputs.cache-key}} - steps: - - name: Install and Configure Recent Git - run: | - apt-get update - apt-get install -y software-properties-common - add-apt-repository ppa:git-core/ppa - apt-get update - apt-get install -y git - git config --global --add safe.directory `pwd` # Fix "fatal: detected dubious ownership in repository at '/__w//'"" - - # See documentation at: - # - https://apt.kitware.com/ - # - https://askubuntu.com/questions/355565/how-do-i-install-the-latest-version-of-cmake-from-the-command-line - - name: Install Recent CMake - run: | - apt-get install -y gpg wget - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4 - apt-add-repository "deb https://apt.kitware.com/ubuntu/ bionic main" - apt-get update - apt-get install -y cmake - - - name: Install Other Dependencies - run: | - apt-get update - apt-get install -y build-essential libfreetype6-dev libharfbuzz-dev - # By default, actions/checkout will only check out the last commit. For # pull requests, this is a temporary merge commit used to test integration # against the master branch. Therefore, in order to get the actual commit # message we are interested in, we need to fetch more than one commit. # Getting more commits can also be helpful for computing human-readable # commit ID, such as 2020-12-16.3 for the 4th commit of the day. - - uses: actions/checkout@v3 # Cannot use v4 (requires Node20/GLIBC_2.28 not available on Ubuntu 18.04) + - uses: actions/checkout@v4 with: fetch-depth: 100 @@ -113,96 +79,93 @@ jobs: echo "COMMIT_BRANCH: $COMMIT_BRANCH" echo "COMMIT_MESSAGE: $COMMIT_MESSAGE" - - name: Setup Python + # We manually start a container and execute scripts in it instead of using `jobs.build.container`, + # otherwise we couldn't use GitHub-provided actions (checkout, cache, etc.) as they rely on Node20 + # which would not necessarily be available on some containers (e.g., Ubuntu 18.04). + # + # See: https://github.com/actions/checkout/issues/1590 + # + - name: Start Docker Container run: | - add-apt-repository ppa:deadsnakes/ppa && \ - apt install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python${PYTHON_VERSION}-distutils && \ - update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 && \ - update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 2 + docker pull $CONTAINER + docker run --name build-container -d -v ${{ github.workspace }}:/workspace $CONTAINER tail -f /dev/null + + - name: Install add-apt-repository + env: + SCRIPT: | + apt-get update + apt-get install -y software-properties-common + run: docker exec build-container bash -c "$SCRIPT" + + - name: Install Recent git version + env: + SCRIPT: | + add-apt-repository ppa:git-core/ppa + apt-get update + apt-get install -y git + git config --global --add safe.directory `pwd` # Fix "fatal: detected dubious ownership in repository at '/__w//'"" + run: docker exec build-container bash -c "$SCRIPT" + + # See documentation at: + # - https://apt.kitware.com/ + # - https://askubuntu.com/questions/355565/how-do-i-install-the-latest-version-of-cmake-from-the-command-line + - name: Install Recent CMake + env: + SCRIPT: | + apt-get install -y gpg wget + wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4 + apt-add-repository "deb https://apt.kitware.com/ubuntu/ bionic main" + apt-get update + apt-get install -y cmake + run: docker exec build-container bash -c "$SCRIPT" + + - name: Install Other Dependencies + env: + SCRIPT: | + apt-get update + apt-get install -y build-essential libfreetype6-dev libharfbuzz-dev + run: docker exec build-container bash -c "$SCRIPT" + + - name: Setup Python + env: + SCRIPT: | + add-apt-repository ppa:deadsnakes/ppa + apt install -y python${{env.PYTHON_VERSION}} python${{env.PYTHON_VERSION}}-dev python${{env.PYTHON_VERSION}}-distutils + update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 + update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${{env.PYTHON_VERSION}} 2 + run: docker exec build-container bash -c "$SCRIPT" # Note: we need libgl1-mesa-dev for QtGui, otherwise CMake configure step would fail with: # CMake Error at qt/5.12.5/gcc_64/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:9 (message): # Failed to find "GL/gl.h" in "/usr/include/libdrm". # - name: Install Qt - run: | - apt-get install -y libgl1-mesa-dev # We need this for QtGui - apt-get install -y libxkbcommon-x11-0 # We need this for Qt plugins/platforms/libqxcb.so - wget --progress=dot:giga https://www.vgc.io/releases/qt/opt-qt-$QT_VERSION-gcc_64.tar.gz - tar -xzf opt-qt-$QT_VERSION-gcc_64.tar.gz -C "$GITHUB_WORKSPACE" + env: + SCRIPT: | + apt-get install -y libgl1-mesa-dev # We need this for QtGui + apt-get install -y libxkbcommon-x11-0 # We need this for Qt plugins/platforms/libqxcb.so + wget --progress=dot:giga https://www.vgc.io/releases/qt/opt-qt-${{env.QT_VERSION}}-gcc_64.tar.gz + tar -xzf opt-qt-${{env.QT_VERSION}}-gcc_64.tar.gz -C /workspace + run: docker exec build-container bash -c "$SCRIPT" - name: Configure - working-directory: ${{github.workspace}} - run: | - mkdir build - cd build - cmake --version - cmake .. -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DQt5_DIR="$GITHUB_WORKSPACE/qt/$QT_VERSION/gcc_64/lib/cmake/Qt5" + env: + SCRIPT: | + cd /workspace && mkdir build && cd build + cmake --version + cmake .. -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DQt5_DIR="/workspace/qt/${{env.QT_VERSION}}/gcc_64/lib/cmake/Qt5" + run: docker exec build-container bash -c "$SCRIPT" - name: Build - working-directory: ${{github.workspace}}/build - run: | - cmake --build . --parallel $PARALLEL_JOBS - - - name: Prepare Artifacts - id: artifacts - working-directory: ${{github.workspace}} - run: | - mkdir artifacts - cp build/*.so artifacts - cackeKey=`date -u +"%Y-%m-%d"`-$GITHUB_RUN_ID - echo "cache-key=$cackeKey" >> "$GITHUB_OUTPUT" - - # We cannot use upload-artifact@v4 on Ubuntu 18.04 as it requires Node 20. - # - # We cannot use upload-artifact@v3 as it is deprecated and will be removed on Nov 30, 2024: - # - # https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/ - # - # Therefore with use GitHub cache instead of GitHub artifacts, and in a subsequent job - # using ubuntu-latest, we retrieve the cache and upload it using upload-artifact@v4. - # - # We cannot use cache@v4 on Ubuntu 18.04 as it requires Node 20. - # - # We cannot use the latest cache@v3 (as of 3.3.3) as it is buggy and does not - # properly support enableCrossOsArchive and fail-on-cache-miss anymore. - # - # Therefore, we use cache@v3.2.4, which is the first version supporting both - # enableCrossOsArchive and fail-on-cache-miss. - # - # Note that we do need `enableCrossOsArchive` otherwise the ubuntu:18.04 - # Docker image and the ubuntu-latest image are considered different and - # do not share cache, that is, theyhave a different "cache version", see: - # - # - https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cross-os-cache - # - https://github.com/marketplace/actions/cache#cache-version - # - - name: Save Artifacts - uses: actions/cache/save@v3.2.4 - if: always() # If we re-run the job, we want to override the cache - with: - path: artifacts - key: ${{steps.artifacts.outputs.cache-key}} - enableCrossOsArchive: true - - # This is a separate job running on ubuntu-latest to be able to use upload-artifact@v4 - # - upload-artifacts: - name: Upload Artifacts - runs-on: ubuntu-latest - needs: build - steps: - - - name: Restore Artifacts - uses: actions/cache/restore@v3.2.4 - with: - path: artifacts - key: ${{needs.build.outputs.artifacts-cache-key}} - enableCrossOsArchive: true - fail-on-cache-miss: true + env: + SCRIPT: | + cd /workspace/build + cmake --build . --parallel ${{env.PARALLEL_JOBS}} + run: docker exec build-container bash -c "$SCRIPT" - name: Upload Artifacts uses: actions/upload-artifact@v4 with: name: artifacts - path: artifacts + path: ${{github.workspace}}/build/*.so