From 7ee9d846824f20251f100072c89a6cbd3db72acd Mon Sep 17 00:00:00 2001 From: Ihar Hubchyk Date: Tue, 24 Dec 2024 18:15:40 +0800 Subject: [PATCH] Speed up GitHub Actions (#9375) --- .github/workflows/android.yml | 2 +- .github/workflows/cmake.yml | 2 +- .github/workflows/codechecker.yml | 4 ++-- .github/workflows/iwyu.yml | 4 ++-- .github/workflows/make.yml | 22 ++++++++++++++-------- .github/workflows/translation_update.yml | 22 +++++++++++----------- sonar-project.properties | 3 --- 7 files changed, 31 insertions(+), 28 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 60e8b9ebce0..e52c0cd8478 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -37,7 +37,7 @@ jobs: sudo apt-get -y install gettext - name: Generate translations run: | - make -C files/lang -j 2 + make -C files/lang -j "$(nproc)" - name: Create keystore if: ${{ github.event_name == 'push' && env.KEYSTORE_BASE64 != '' }} run: | diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index c2124732fb1..b772924aa76 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -70,7 +70,7 @@ jobs: - name: Build run: | cmake.exe -B build -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug -DENABLE_STRICT_COMPILATION=ON -DENABLE_IMAGE=ON \ - -DENABLE_TOOLS=ON -DCMAKE_TOOLCHAIN_FILE="C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" \ + -DENABLE_TOOLS=ON -DCMAKE_TOOLCHAIN_FILE=C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake \ -DVCPKG_TARGET_TRIPLET=x64-windows cmake.exe --build build --config Debug - name: Install diff --git a/.github/workflows/codechecker.yml b/.github/workflows/codechecker.yml index a078b71b7d8..a679c9c6fc7 100644 --- a/.github/workflows/codechecker.yml +++ b/.github/workflows/codechecker.yml @@ -26,9 +26,9 @@ jobs: cmake -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_STRICT_COMPILATION=ON -DENABLE_IMAGE=ON -DENABLE_TOOLS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - name: Analyze run: | - export PATH="$HOME/.python-venv/bin:$PATH" + export PATH=$HOME/.python-venv/bin:$PATH CodeChecker analyze --analyzers clangsa --ctu-all --ctu-ast-mode load-from-pch --output codechecker-output --ignore .codechecker-ignore build/compile_commands.json - name: Display results run: | - export PATH="$HOME/.python-venv/bin:$PATH" + export PATH=$HOME/.python-venv/bin:$PATH CodeChecker parse --print-steps codechecker-output diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 8772e182980..a42bd9d8224 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -24,8 +24,8 @@ jobs: cmake -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_STRICT_COMPILATION=ON -DENABLE_IMAGE=ON -DENABLE_TOOLS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - name: Analyze run: | - iwyu_tool -p build -j 2 -- -Xiwyu --cxx17ns -Xiwyu --error -Xiwyu --mapping_file="$GITHUB_WORKSPACE/iwyu.map" | (grep -E -v "^$|has correct #includes/fwd-decls" || true) \ - | tee iwyu-result.txt + iwyu_tool -p build -j "$(nproc)" -- -Xiwyu --cxx17ns -Xiwyu --error -Xiwyu --mapping_file="$GITHUB_WORKSPACE/iwyu.map" \ + | (grep -E -v "^$|has correct #includes/fwd-decls" || true) | tee iwyu-result.txt - uses: actions/upload-artifact@v4 if: ${{ failure() }} with: diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index c88183ebf99..b61291a4ae7 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -171,9 +171,15 @@ jobs: env: # Do not update outdated dependencies of installed packages HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: ON - - name: Build + - name: Build (Linux) + if: ${{ startsWith( matrix.config.os, 'ubuntu-' ) }} + run: | + make -j "$(nproc)" + env: ${{ matrix.config.env }} + - name: Build (MacOS) + if: ${{ startsWith( matrix.config.os, 'macos-' ) }} run: | - make -j 2 + make -j "$(sysctl -n hw.logicalcpu)" env: ${{ matrix.config.env }} - name: Create package if: ${{ matrix.config.package_name != '' && matrix.config.package_files != '' }} @@ -244,7 +250,7 @@ jobs: run: | git clone --depth 1 https://github.com/vitasdk/vdpm cd vdpm - export PATH="$VITASDK/bin:$PATH" + export PATH=$VITASDK/bin:$PATH ./bootstrap-vitasdk.sh ./install-all.sh rm -rf ~/.vitasdk-cache @@ -258,8 +264,8 @@ jobs: fi - name: Build run: | - export PATH="$VITASDK/bin:$PATH" - make -f Makefile.vita -j 2 + export PATH=$VITASDK/bin:$PATH + make -f Makefile.vita -j "$(nproc)" env: FHEROES2_STRICT_COMPILATION: ON VITASDK: /usr/local/vitasdk @@ -307,14 +313,14 @@ jobs: sudo apt-get -y install gettext p7zip-full - name: Build run: | - export PATH="$DEVKITPRO/tools/bin:$DEVKITPRO/portlibs/switch/bin:$DEVKITPRO/devkitA64/bin:$PATH" - make -f Makefile.switch -j 2 + export PATH=$DEVKITPRO/tools/bin:$DEVKITPRO/portlibs/switch/bin:$DEVKITPRO/devkitA64/bin:$PATH + make -f Makefile.switch -j "$(nproc)" env: FHEROES2_STRICT_COMPILATION: ON DEVKITPRO: /opt/devkitpro - name: Generate translations run: | - make -C files/lang -j 2 + make -C files/lang -j "$(nproc)" - name: Create package run: | 7z a -bb1 -tzip -- fheroes2_switch.zip LICENSE changelog.txt fheroes2.nro ./docs/README.txt ./docs/README_switch.md files/data/*.h2d files/lang/*.mo diff --git a/.github/workflows/translation_update.yml b/.github/workflows/translation_update.yml index 95e871874e6..9351eb5b689 100644 --- a/.github/workflows/translation_update.yml +++ b/.github/workflows/translation_update.yml @@ -28,33 +28,33 @@ jobs: git config user.email "action@github.com" - name: Create PR branch run: | - PR_BRANCH="translation-update-$(uuidgen)" + PR_BRANCH=translation-update-$(uuidgen) git switch -c "$PR_BRANCH" echo "PR_BRANCH=$PR_BRANCH" >> "$GITHUB_ENV" - name: Generate POT run: | - make -C src/dist/fheroes2 -j 2 pot + make -C src/dist/fheroes2 -j "$(nproc)" pot - name: Merge PO with POT run: | - make -C files/lang -j 2 merge + make -C files/lang -j "$(nproc)" merge - name: Generate statistics run: | mkdir -p docs/json for PO_FILE in files/lang/*.po; do - STATISTICS="$(msgfmt --statistics --output-file=/dev/null -- "$PO_FILE" 2>&1)" + STATISTICS=$(msgfmt --statistics --output-file=/dev/null -- "$PO_FILE" 2>&1) echo "$PO_FILE: $STATISTICS" if [[ "$STATISTICS" =~ ([0-9]+)\ translated\ messages? ]]; then - TRANSLATED="${BASH_REMATCH[1]}" + TRANSLATED=${BASH_REMATCH[1]} else TRANSLATED=0 fi if [[ "$STATISTICS" =~ ([0-9]+)\ fuzzy\ translations? ]]; then - FUZZY="${BASH_REMATCH[1]}" + FUZZY=${BASH_REMATCH[1]} else FUZZY=0 fi if [[ "$STATISTICS" =~ ([0-9]+)\ untranslated\ messages? ]]; then - UNTRANSLATED="${BASH_REMATCH[1]}" + UNTRANSLATED=${BASH_REMATCH[1]} else UNTRANSLATED=0 fi @@ -64,11 +64,11 @@ jobs: else PERCENT=$((TRANSLATED * 100 / OVERALL)) fi - LANGUAGE="$(basename "${PO_FILE%.po}")" + LANGUAGE=$(basename "${PO_FILE%.po}") if [[ "$(head -n1 -- "$PO_FILE")" =~ ^\#\ (.+)\ translation ]]; then - LABEL="${BASH_REMATCH[1]}" + LABEL=${BASH_REMATCH[1]} else - LABEL="$LANGUAGE" + LABEL=$LANGUAGE fi if ((PERCENT < 75)); then COLOR="red" @@ -82,7 +82,7 @@ jobs: - name: Commit changes run: | git diff --name-only -z -- files/lang/*.po \ - | xargs -r0 bash -c 'set -e; for NAME in "$@"; do if [[ -n "$(git diff "-I^\"POT-Creation-Date:[^\"]*\"$" -- "$NAME")" ]]; then git add -- "$NAME"; fi; done' dummy + | xargs -r0 bash -c 'set -e; for NAME in "$@"; do if [[ -n "$(git diff "-I^\"POT-Creation-Date:[^\"]*\"$" -- "$NAME")" ]]; then git add -- "$NAME"; fi; done' dummy git add -- docs/json/lang_*.json if git commit -m "Update translation files"; then git push origin HEAD; echo "CREATE_PR=YES" >> "$GITHUB_ENV"; fi - name: Create PR diff --git a/sonar-project.properties b/sonar-project.properties index 61c164ab5b8..25a9829d1fa 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -17,9 +17,6 @@ sonar.sources=. # Encoding of the source code. Default is default system encoding. #sonar.sourceEncoding=UTF-8 -# Properties specific to the C/C++ analyzer. -sonar.cfamily.threads=2 - # List of files completely excluded from the analysis. sonar.exclusions=src/thirdparty/**/*