diff --git a/.github/actions/configure-sccache-s3/action.yml b/.github/actions/configure-sccache-s3/action.yml new file mode 100644 index 000000000..4d06560e6 --- /dev/null +++ b/.github/actions/configure-sccache-s3/action.yml @@ -0,0 +1,43 @@ +name: configure-sccache-s3 +description: "Install sccache and configure AWS credentials and S3 cache" +inputs: + vars: + description: "JSON-encoded GitHub Actions vars context" + required: false + default: "{}" + sccache-bucket: + description: "S3 bucket used by sccache" + required: false + default: maplibre-native-sccache + sccache-region: + description: "S3 bucket region used by sccache" + required: false + default: eu-central-1 +runs: + using: "composite" + steps: + - name: Install sccache + shell: bash + run: "$GITHUB_ACTION_PATH/../install-sccache/install-sccache" + + - name: Configure AWS Credentials + if: fromJSON(inputs.vars).OIDC_AWS_ROLE_TO_ASSUME + uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v4 + with: + aws-region: us-west-2 + role-to-assume: ${{ fromJSON(inputs.vars).OIDC_AWS_ROLE_TO_ASSUME }} + role-session-name: ${{ github.run_id }} + + - name: Configure sccache + shell: bash + env: + SCCACHE_BUCKET: ${{ inputs.sccache-bucket }} + SCCACHE_REGION: ${{ inputs.sccache-region }} + run: | + echo "SCCACHE_BUCKET=${SCCACHE_BUCKET}" >> "$GITHUB_ENV" + echo "SCCACHE_REGION=${SCCACHE_REGION}" >> "$GITHUB_ENV" + + if [ -z "${AWS_SECRET_ACCESS_KEY}" ]; then + echo "AWS_SECRET_ACCESS_KEY not set; not uploading sccache cache to S3" + echo SCCACHE_S3_NO_CREDENTIALS=1 >> "$GITHUB_ENV" + fi diff --git a/.github/actions/install-sccache/install-sccache b/.github/actions/install-sccache/install-sccache index 7d9d31091..06d26c6ef 100755 --- a/.github/actions/install-sccache/install-sccache +++ b/.github/actions/install-sccache/install-sccache @@ -1,7 +1,31 @@ #!/bin/bash -curl -LO https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz -tar -xzf sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz -sudo mv sccache-v0.10.0-x86_64-unknown-linux-musl/sccache /usr/bin/sccache -sudo chmod +x /usr/bin/sccache -rm -rf sccache-v0.10.0-x86_64-unknown-linux-musl* +set -euo pipefail + +if command -v sccache >/dev/null 2>&1; then + sccache --version + exit 0 +fi + +case "$(uname -s)" in + Darwin) + HOMEBREW_NO_AUTO_UPDATE=1 brew install sccache + ;; + Linux) + tmpdir="$(mktemp -d)" + trap 'rm -rf "${tmpdir}"' EXIT + + curl --fail --location --retry 3 \ + --output "${tmpdir}/sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz" \ + https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz + tar -xzf "${tmpdir}/sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz" -C "${tmpdir}" + sudo mv "${tmpdir}/sccache-v0.10.0-x86_64-unknown-linux-musl/sccache" /usr/local/bin/sccache + sudo chmod +x /usr/local/bin/sccache + ;; + *) + echo "Unsupported runner OS: $(uname -s)" + exit 1 + ;; +esac + +sccache --version diff --git a/.github/workflows/android-ci.yml b/.github/workflows/android-ci.yml index 0948dfdc2..14c879297 100644 --- a/.github/workflows/android-ci.yml +++ b/.github/workflows/android-ci.yml @@ -105,23 +105,10 @@ jobs: with: check_untracked: true - - name: Configure AWS Credentials - if: vars.OIDC_AWS_ROLE_TO_ASSUME - uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v4 - with: - aws-region: us-west-2 - role-to-assume: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }} - role-session-name: ${{ github.run_id }} - - name: Configure sccache - run: | - echo SCCACHE_BUCKET=maplibre-native-sccache >> "$GITHUB_ENV" - echo SCCACHE_REGION=eu-central-1 >> "$GITHUB_ENV" - - if [ -z "${AWS_SECRET_ACCESS_KEY}" ]; then - echo "AWS_SECRET_ACCESS_KEY not set; not uploading sccache cache to S3" - echo SCCACHE_S3_NO_CREDENTIALS=1 >> "$GITHUB_ENV" - fi + uses: ./.github/actions/configure-sccache-s3 + with: + vars: ${{ toJSON(vars) }} - name: Check code style if: matrix.renderer == 'opengl' @@ -234,23 +221,10 @@ jobs: run: zip -r test/android/app/src/main/assets/data.zip -@ < test/android/app/src/main/assets/to_zip.txt working-directory: . - - name: Configure AWS Credentials - if: vars.OIDC_AWS_ROLE_TO_ASSUME - uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v4 - with: - aws-region: us-west-2 - role-to-assume: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }} - role-session-name: ${{ github.run_id }} - - name: Configure sccache - run: | - echo SCCACHE_BUCKET=maplibre-native-sccache >> "$GITHUB_ENV" - echo SCCACHE_REGION=eu-central-1 >> "$GITHUB_ENV" - - if [ -z "${AWS_SECRET_ACCESS_KEY}" ]; then - echo "AWS_SECRET_ACCESS_KEY not set; not uploading sccache cache to S3" - echo SCCACHE_S3_NO_CREDENTIALS=1 >> "$GITHUB_ENV" - fi + uses: ./.github/actions/configure-sccache-s3 + with: + vars: ${{ toJSON(vars) }} - name: Build C++ Unit Tests App run: | @@ -288,23 +262,10 @@ jobs: - uses: ./.github/actions/setup-android-ci - - name: Configure AWS Credentials - if: vars.OIDC_AWS_ROLE_TO_ASSUME - uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v4 - with: - aws-region: us-west-2 - role-to-assume: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }} - role-session-name: ${{ github.run_id }} - - name: Configure sccache - run: | - echo SCCACHE_BUCKET=maplibre-native-sccache >> "$GITHUB_ENV" - echo SCCACHE_REGION=eu-central-1 >> "$GITHUB_ENV" - - if [ -z "${AWS_SECRET_ACCESS_KEY}" ]; then - echo "AWS_SECRET_ACCESS_KEY not set; not uploading sccache cache to S3" - echo SCCACHE_S3_NO_CREDENTIALS=1 >> "$GITHUB_ENV" - fi + uses: ./.github/actions/configure-sccache-s3 + with: + vars: ${{ toJSON(vars) }} - name: Build and Upload Render Test APKs (${{ matrix.flavor }}) uses: ./.github/actions/android-build-and-upload-render-test @@ -329,23 +290,10 @@ jobs: - uses: ./.github/actions/setup-android-ci - - name: Configure AWS Credentials - if: vars.OIDC_AWS_ROLE_TO_ASSUME - uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v4 - with: - aws-region: us-west-2 - role-to-assume: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }} - role-session-name: ${{ github.run_id }} - - name: Configure sccache - run: | - echo SCCACHE_BUCKET=maplibre-native-sccache >> "$GITHUB_ENV" - echo SCCACHE_REGION=eu-central-1 >> "$GITHUB_ENV" - - if [ -z "${AWS_SECRET_ACCESS_KEY}" ]; then - echo "AWS_SECRET_ACCESS_KEY not set; not uploading sccache cache to S3" - echo SCCACHE_S3_NO_CREDENTIALS=1 >> "$GITHUB_ENV" - fi + uses: ./.github/actions/configure-sccache-s3 + with: + vars: ${{ toJSON(vars) }} - name: Build WebGPU Dawn library for arm64-v8a run: ./gradlew :MapLibreAndroid:assembleWebgpuDawnDebug -Pmaplibre.abis=arm64-v8a @@ -407,23 +355,10 @@ jobs: export "${ENV_VAR}=--sysroot=$NDK_PREBUILT/sysroot --target=${{ env.BINDGEN_TARGET }} -isystem $RESOURCE_DIR/include" cargo build --release --target ${{ env.RUST_TARGET }} --no-default-features --features vulkan,wgsl,spirv,glsl - - name: Configure AWS Credentials - if: vars.OIDC_AWS_ROLE_TO_ASSUME - uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v4 - with: - aws-region: us-west-2 - role-to-assume: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }} - role-session-name: ${{ github.run_id }} - - name: Configure sccache - run: | - echo SCCACHE_BUCKET=maplibre-native-sccache >> "$GITHUB_ENV" - echo SCCACHE_REGION=eu-central-1 >> "$GITHUB_ENV" - - if [ -z "${AWS_SECRET_ACCESS_KEY}" ]; then - echo "AWS_SECRET_ACCESS_KEY not set; not uploading sccache cache to S3" - echo SCCACHE_S3_NO_CREDENTIALS=1 >> "$GITHUB_ENV" - fi + uses: ./.github/actions/configure-sccache-s3 + with: + vars: ${{ toJSON(vars) }} - name: Build WebGPU wgpu-native library for Android run: ./gradlew :MapLibreAndroid:assembleWebgpuWgpuDebug -Pmaplibre.abis=${{ env.ANDROID_ARCH }} diff --git a/.github/workflows/ios-ci.yml b/.github/workflows/ios-ci.yml index f497f603d..db104784a 100644 --- a/.github/workflows/ios-ci.yml +++ b/.github/workflows/ios-ci.yml @@ -240,12 +240,30 @@ jobs: with: submodules: recursive + - name: Configure sccache + uses: ./.github/actions/configure-sccache-s3 + with: + vars: ${{ toJSON(vars) }} + + - name: Initialize sccache + run: | + sccache --start-server + sccache --zero-stats + - name: Configure build with CMake - run: cmake --preset ios-metal + run: | + cmake --preset ios-metal \ + -DCMAKE_C_COMPILER_LAUNCHER=sccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache - name: Build mbgl-core run: cmake --build build-ios --target mbgl-core ios-sdk-static app + - name: Show sccache stats + if: always() + run: | + sccache --show-stats + ios-build-webgpu-dawn: needs: pre_job if: needs.pre_job.outputs.should_skip != 'true' @@ -256,13 +274,31 @@ jobs: submodules: recursive persist-credentials: false + - name: Configure sccache + uses: ./.github/actions/configure-sccache-s3 + with: + vars: ${{ toJSON(vars) }} + + - name: Initialize sccache + run: | + sccache --start-server + sccache --zero-stats + - name: Configure build with CMake - run: cmake --preset ios-webgpu-dawn + run: | + cmake --preset ios-webgpu-dawn \ + -DCMAKE_C_COMPILER_LAUNCHER=sccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache - name: Build mbgl-core and iOS SDK continue-on-error: true run: cmake --build build-ios-webgpu-dawn --target mbgl-core ios-sdk-static + - name: Show sccache stats + if: always() + run: | + sccache --show-stats + ios-build-webgpu-wgpu: needs: pre_job if: needs.pre_job.outputs.should_skip != 'true' @@ -286,12 +322,30 @@ jobs: rustup target add aarch64-apple-ios --toolchain "$ACTIVE_TOOLCHAIN" rustup target list --toolchain "$ACTIVE_TOOLCHAIN" --installed | grep -x 'aarch64-apple-ios' + - name: Configure sccache + uses: ./.github/actions/configure-sccache-s3 + with: + vars: ${{ toJSON(vars) }} + + - name: Initialize sccache + run: | + sccache --start-server + sccache --zero-stats + - name: Configure build with CMake - run: cmake --preset ios-webgpu-wgpu + run: | + RUSTC_WRAPPER=sccache cmake --preset ios-webgpu-wgpu \ + -DCMAKE_C_COMPILER_LAUNCHER=sccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache - name: Build mbgl-core and iOS SDK continue-on-error: true - run: cmake --build build-ios-webgpu-wgpu --target mbgl-core ios-sdk-static + run: RUSTC_WRAPPER=sccache cmake --build build-ios-webgpu-wgpu --target mbgl-core ios-sdk-static + + - name: Show sccache stats + if: always() + run: | + sccache --show-stats ios-ci-result: runs-on: ubuntu-latest diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 854511c63..901717c50 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -86,8 +86,6 @@ jobs: - if: matrix.variant.rust run: cargo install cxxbridge-cmd --version 1.0.157 --locked - - uses: ./.github/actions/install-sccache - - name: Install ctcache run: | # pending open PR https://github.com/matus-chochlik/ctcache/pull/94 @@ -96,13 +94,10 @@ jobs: cd .. mv ctcache /usr/local/bin - - name: Configure AWS Credentials - if: vars.OIDC_AWS_ROLE_TO_ASSUME - uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v4 + - name: Configure sccache + uses: ./.github/actions/configure-sccache-s3 with: - aws-region: us-west-2 - role-to-assume: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }} - role-session-name: ${{ github.run_id }} + vars: ${{ toJSON(vars) }} - name: Build MapLibre Native env: @@ -110,15 +105,6 @@ jobs: run: | cmake --version - # sccache configuration - export SCCACHE_BUCKET=maplibre-native-sccache - export SCCACHE_REGION=eu-central-1 - - if [ -z "${AWS_SECRET_ACCESS_KEY}" ]; then - echo "AWS_SECRET_ACCESS_KEY not set; not uploading sccache cache to S3" - export SCCACHE_S3_NO_CREDENTIALS=1 - fi - # ctcache configuration export CTCACHE_HOST=34.229.50.221 export CTCACHE_PORT=5000