From 8b99075a2b383049b5cb693498704f9223254d51 Mon Sep 17 00:00:00 2001 From: Finagolfin Date: Tue, 30 Jul 2024 20:15:00 +0530 Subject: [PATCH] ci(packages): Consolidate a handful of big-pkgs checks into a single docker-build variable --- .github/workflows/packages.yml | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 853eb21256a9fc..cc636d09d1e0f9 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -43,6 +43,7 @@ jobs: with: fetch-depth: 1000 - name: Gather build summary + id: build-info run: | if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then BASE_COMMIT=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH") @@ -155,16 +156,19 @@ jobs: fi done + docker='true' + [ -n "$packages" ] && if grep -qP "(^|\\s)${packages// /($|\\s)|(^|\\s)}($|\\s)" ./scripts/big-pkgs.list; then + docker='false' + fi + echo "docker-build=$docker" >> $GITHUB_OUTPUT if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then # Build local Docker image if setup scripts were changed. # Useful for pull requests submitting changes for both build environment and packages. if grep -qP '^scripts/(Dockerfile|properties\.sh|setup-android-sdk\.sh|setup-ubuntu\.sh)$' <<< "$CHANGED_FILES"; then echo "Detected changes for environment setup scripts. Building custom Docker image now." - if [ -n "$packages" ]; then - if grep -qP "(^|\\s)${packages// /($|\\s)|(^|\\s)}($|\\s)" ./scripts/big-pkgs.list; then - echo "Skipping due to building large packages." - exit 0 - fi + if [ $docker == 'false' ]; then + echo "Skipping due to building large packages." + exit 0 fi cd ./scripts docker build -t ghcr.io/termux/package-builder:latest . @@ -196,16 +200,14 @@ jobs: fi done - if [ -n "$packages" ]; then - if grep -qP "(^|\\s)${packages// /($|\\s)|(^|\\s)}($|\\s)" ./scripts/big-pkgs.list; then - ./scripts/setup-ubuntu.sh - sudo apt install ninja-build - sudo apt purge -yq $(dpkg -l | grep '^ii' | awk '{ print $2 }' | grep -P '(aspnetcore|cabal-|dotnet-|ghc-|libmono|mongodb-|mysql-|php)') \ - firefox google-chrome-stable google-cloud-cli microsoft-edge-stable mono-devel mono-runtime-common monodoc-manual powershell ruby - sudo apt autoremove -yq - sudo apt clean - sudo rm -fr /opt/ghc /opt/hostedtoolcache /usr/lib/node_modules /usr/local/share/boost /usr/share/dotnet /usr/share/swift - fi + if [ ${{ steps.build-info.outputs.docker-build }} == 'false' ]; then + ./scripts/setup-ubuntu.sh + sudo apt install ninja-build + sudo apt purge -yq $(dpkg -l | grep '^ii' | awk '{ print $2 }' | grep -P '(aspnetcore|cabal-|dotnet-|ghc-|libmono|mongodb-|mysql-|php)') \ + firefox google-chrome-stable google-cloud-cli microsoft-edge-stable mono-devel mono-runtime-common monodoc-manual powershell ruby + sudo apt autoremove -yq + sudo apt clean + sudo rm -fr /opt/ghc /opt/hostedtoolcache /usr/lib/node_modules /usr/local/share/boost /usr/share/dotnet /usr/share/swift fi - name: Build packages @@ -218,12 +220,10 @@ jobs: fi done - if [ -n "$packages" ]; then - if grep -qP "(^|\\s)${packages// /($|\\s)|(^|\\s)}($|\\s)" ./scripts/big-pkgs.list; then - NDK=$ANDROID_NDK_LATEST_HOME ANDROID_HOME=$ANDROID_SDK_ROOT ./build-package.sh -I -a ${{ matrix.target_arch }} $packages - else - ./scripts/run-docker.sh ./build-package.sh -I -a ${{ matrix.target_arch }} $packages - fi + if [ ${{ steps.build-info.outputs.docker-build }} == 'false' ]; then + NDK=$ANDROID_NDK ANDROID_HOME=$ANDROID_SDK_ROOT ./build-package.sh -I -a ${{ matrix.target_arch }} $packages + elif [ -n "$packages" ]; then + ./scripts/run-docker.sh ./build-package.sh -I -a ${{ matrix.target_arch }} $packages fi - name: Generate build artifacts