From ed8f069a775a066d19fd53ad2971fb1808b2b10a Mon Sep 17 00:00:00 2001 From: "Satadru Pramanik, DO, MPH, MEng" Date: Tue, 14 Oct 2025 05:04:20 -0400 Subject: [PATCH] Sync workflow changes from #13001 (#13124) * Sync workflow changes from #13001 Signed-off-by: Satadru Pramanik * Attempt to work around disk space issues on GitHub Runners. Signed-off-by: Satadru Pramanik * Add changes to Generate PR workflow. Signed-off-by: Satadru Pramanik * sync up again. Signed-off-by: Satadru Pramanik --------- Signed-off-by: Satadru Pramanik --- .github/workflows/Build.yml | 35 ++++++++++++++++++++++++------- .github/workflows/Generate-PR.yml | 30 +++++++++++++++++++++----- 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index d2f66d3cf..8bfd88356 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -1,6 +1,6 @@ --- name: Build -run-name: Build ${{ inputs.branch || github.ref_name }} by @${{ github.actor }} +run-name: Build ${{ inputs.branch || github.ref_name }} for ${{ ( inputs.build-on-i686 ) && ' i686 ' || '' }}${{ ( inputs.build-on-x86_64 ) && ' x86_64 ' || '' }}${{ ( inputs.build-on-armv7l ) && ' armv7l ' || '' }} by @${{ github.actor }} on: workflow_dispatch: inputs: @@ -32,6 +32,11 @@ on: pr_label: description: "PR Label" required: false + max_build_time: + description: "Maximum Build Time (hours)" + required: false + type: number + default: 5.5 build-on-i686: description: "Build on i686" default: true @@ -175,7 +180,7 @@ jobs: echo "i686_PACKAGES=${i686_PACKAGES}" >> "$GITHUB_OUTPUT" echo "Branch ${{ inputs.branch || github.ref_name }} has these i686 compatible packages: ${i686_PACKAGES}" fi - - name: Create Generate Matrix + - name: Generate Creation Matrix id: set-generate-matrix env: i686_PACKAGES: ${{ steps.get-compatibility.outputs.i686_PACKAGES }} @@ -289,19 +294,26 @@ jobs: - name: Run Updater in container id: run-updater if: ${{ !cancelled() }} + env: + CREW_MAX_BUILD_TIME_INPUT: ${{ inputs.max_build_time }} run: | + if [[ -n ${CREW_MAX_BUILD_TIME_INPUT} ]]; then + # Convert CREW_MAX_BUILD_TIME_INPUT to seconds. + CREW_MAX_BUILD_TIME="$(bc <<<"scale=0;$CREW_MAX_BUILD_TIME_INPUT*3600/1")" + echo "Maximum build time is $(bc <<<"scale=0;$CREW_MAX_BUILD_TIME_INPUT*60/1") minutes." + fi [[ -n ${CI} ]] && echo 'CI variable is set.' if [ "$PLATFORM" == 'linux/arm/v7' ] && [ -z "${armv7l_PACKAGES}" ]; then # Exit the arm container if there are not armv7l compatible packages. - echo "Skipping armv7l container builds &/or package file updates" + echo "Skipping armv7l container builds &/or package file updates." exit 0 elif [ "$PLATFORM" == 'linux/amd64' ] && [ -z "${x86_64_PACKAGES}" ]; then # Exit the x86_64 container if there are not x86_64 compatible packages. - echo "Skipping x86_64 container builds &/or package file updates" + echo "Skipping x86_64 container builds &/or package file updates." exit 0 elif [ "$PLATFORM" == 'linux/386' ] && [ -z "${i686_PACKAGES}" ]; then # Exit the i686 container if there are not i686 compatible packages. - echo "Skipping i686 container builds &/or package file updates" + echo "Skipping i686 container builds &/or package file updates." exit 0 fi @@ -313,8 +325,9 @@ jobs: # Detection of /output/pkg_cache dir triggers setting # CREW_CACHE_DIR=1 and CREW_CACHE_ENABLED=1 in the build # container. Without these, upload fails. - mkdir pkg_cache + mkdir /tmp/pkg_cache sudo setfacl -R -m u:1000:rwx . + sudo setfacl -R -m u:1000:rwx /tmp/pkg_cache # See https://github.com/containerd/containerd/pull/7566#issuecomment-1461134737 for why we set ulimit. if [ -z ${CI+x} ]; then echo "CI is not set." @@ -323,6 +336,13 @@ jobs: CI_PASSTHROUGH+=" " CI_PASSTHROUGH+=NESTED_CI=${CI} fi + if [ -z ${CREW_MAX_BUILD_TIME+x} ]; then + echo "CREW_MAX_BUILD_TIME is not set." + else + CREW_MAX_BUILD_TIME_PASSTHROUGH=-e + CREW_MAX_BUILD_TIME_PASSTHROUGH+=" " + CREW_MAX_BUILD_TIME_PASSTHROUGH+=CREW_MAX_BUILD_TIME=${CREW_MAX_BUILD_TIME} + fi docker run \ --rm \ --platform "${PLATFORM}" \ @@ -336,7 +356,8 @@ jobs: -e GITLAB_TOKEN="${{ secrets.GITLAB_TOKEN }}" \ -e GITLAB_TOKEN_USERNAME="${{ secrets.GITLAB_TOKEN_USERNAME }}" \ ${CI_PASSTHROUGH} \ - -v "$(pwd)"/pkg_cache:/usr/local/tmp/packages:rshared \ + ${CREW_MAX_BUILD_TIME_PASSTHROUGH} \ + -v /tmp/pkg_cache:/usr/local/tmp/packages:rshared \ -v "$(pwd)":/output:rshared \ --tmpfs /tmp \ --ulimit "nofile=$(ulimit -Sn):$(ulimit -Hn)" \ diff --git a/.github/workflows/Generate-PR.yml b/.github/workflows/Generate-PR.yml index ade10c96e..ba569dbee 100644 --- a/.github/workflows/Generate-PR.yml +++ b/.github/workflows/Generate-PR.yml @@ -28,6 +28,11 @@ on: pr_label: description: "PR Label" required: false + max_build_time: + description: "Maximum Build Time (hours)" + required: false + type: number + default: 5.5 env: BRANCH: ${{ inputs.branch || github.ref_name }} permissions: @@ -159,7 +164,7 @@ jobs: echo "i686_PACKAGES=${i686_PACKAGES}" >> "$GITHUB_OUTPUT" echo "Branch ${{ inputs.branch || github.ref_name }} has these i686 compatible packages: ${i686_PACKAGES}" fi - - name: Create Generate Matrix + - name: Generate Creation Matrix id: set-generate-matrix env: i686_PACKAGES: ${{ steps.get-compatibility.outputs.i686_PACKAGES }} @@ -275,9 +280,15 @@ jobs: id: run-updater if: ${{ ( inputs.update_package_files ) && ( contains(needs.*.result, 'failure') || !cancelled() ) }} env: + CREW_MAX_BUILD_TIME_INPUT: ${{ inputs.max_build_time }} UPDATE_PACKAGE_FILES: ${{ github.event.inputs.update_package_files }} run: | [[ "$UPDATE_PACKAGE_FILES" == 'false' ]] && exit 0 + if [[ -n ${CREW_MAX_BUILD_TIME_INPUT} ]]; then + # Convert CREW_MAX_BUILD_TIME_INPUT to seconds. + CREW_MAX_BUILD_TIME="$(bc <<<"scale=0;$CREW_MAX_BUILD_TIME_INPUT*3600/1")" + echo "Maximum build time is $(bc <<<"scale=0;$CREW_MAX_BUILD_TIME_INPUT*60/1") minutes." + fi [[ -n ${CI} ]] && echo 'CI variable is set.' if [ "$PLATFORM" == 'linux/arm/v7' ] && [ -z "${armv7l_PACKAGES}" ]; then # Exit the arm container if there are not armv7l compatible packages. @@ -285,11 +296,11 @@ jobs: exit 0 elif [ "$PLATFORM" == 'linux/amd64' ] && [ -z "${x86_64_PACKAGES}" ]; then # Exit the x86_64 container if there are not x86_64 compatible packages. - echo "Skipping x86_64 container builds &/or package file updates" + echo "Skipping x86_64 container builds &/or package file updates." exit 0 elif [ "$PLATFORM" == 'linux/386' ] && [ -z "${i686_PACKAGES}" ]; then # Exit the i686 container if there are not i686 compatible packages. - echo "Skipping i686 container builds &/or package file updates" + echo "Skipping i686 container builds &/or package file updates." exit 0 fi @@ -301,8 +312,9 @@ jobs: # Detection of /output/pkg_cache dir triggers setting # CREW_CACHE_DIR=1 and CREW_CACHE_ENABLED=1 in the build # container. Without these, upload fails. - mkdir pkg_cache + mkdir /tmp/pkg_cache sudo setfacl -R -m u:1000:rwx . + sudo setfacl -R -m u:1000:rwx /tmp/pkg_cache # See https://github.com/containerd/containerd/pull/7566#issuecomment-1461134737 for why we set ulimit. if [ -z ${CI+x} ]; then echo "CI is not set." @@ -311,6 +323,13 @@ jobs: CI_PASSTHROUGH+=" " CI_PASSTHROUGH+=NESTED_CI=${CI} fi + if [ -z ${CREW_MAX_BUILD_TIME+x} ]; then + echo "CREW_MAX_BUILD_TIME is not set." + else + CREW_MAX_BUILD_TIME_PASSTHROUGH=-e + CREW_MAX_BUILD_TIME_PASSTHROUGH+=" " + CREW_MAX_BUILD_TIME_PASSTHROUGH+=CREW_MAX_BUILD_TIME=${CREW_MAX_BUILD_TIME} + fi docker run \ --rm \ --platform "${PLATFORM}" \ @@ -324,7 +343,8 @@ jobs: -e GITLAB_TOKEN="${{ secrets.GITLAB_TOKEN }}" \ -e GITLAB_TOKEN_USERNAME="${{ secrets.GITLAB_TOKEN_USERNAME }}" \ ${CI_PASSTHROUGH} \ - -v "$(pwd)"/pkg_cache:/usr/local/tmp/packages:rshared \ + ${CREW_MAX_BUILD_TIME_PASSTHROUGH} \ + -v /tmp/pkg_cache:/usr/local/tmp/packages:rshared \ -v "$(pwd)":/output:rshared \ --tmpfs /tmp \ --ulimit "nofile=$(ulimit -Sn):$(ulimit -Hn)" \