Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

perf(ci): bulk-restore sccache cache to speed up CI builds (#14253)

Hrithikesh3fda2a6785fa
diff --git a/.github/scripts/download-hyperswitch-binary-s3.sh b/.github/scripts/download-hyperswitch-binary-s3.sh
new file mode 100755
index 0000000000..4f9a0b95ff
--- /dev/null
+++ b/.github/scripts/download-hyperswitch-binary-s3.sh
@@ -0,0 +1,16 @@
+#! /usr/bin/env bash
+
+set -euo pipefail
+
+if [[ "${CI:-false}" != "true" && "${GITHUB_ACTIONS:-false}" != "true" ]]; then
+ echo "This script is to be run in a GitHub Actions runner only. Exiting."
+ exit 1
+fi
+
+# Keyed by run id: build-hyperswitch uploads its compiled router binary
+# under this same path for every job in this run to download.
+mkdir -p target/debug
+aws s3 cp \
+ "s3://${CACHE_S3_BUCKET}/${CACHE_S3_KEY_PREFIX}build-artifacts/${GITHUB_RUN_ID}/router" \
+ target/debug/router \
+ --region "${CACHE_S3_REGION}" --no-progress --only-show-errors
diff --git a/.github/scripts/sccache-mask-s3-env.sh b/.github/scripts/sccache-mask-s3-env.sh
new file mode 100755
index 0000000000..e0b48398ae
--- /dev/null
+++ b/.github/scripts/sccache-mask-s3-env.sh
@@ -0,0 +1,14 @@
+#! /usr/bin/env bash
+
+set -euo pipefail
+
+if [[ "${CI:-false}" != "true" && "${GITHUB_ACTIONS:-false}" != "true" ]]; then
+ echo "This script is to be run in a GitHub Actions runner only. Exiting."
+ exit 1
+fi
+
+# Not secret, but no reason to publish the bucket layout in public PR logs
+# (e.g. if a failed aws s3 cp ever echoes the URI back in an error).
+[ -n "${CACHE_S3_BUCKET:-}" ] && echo "::add-mask::${CACHE_S3_BUCKET}"
+[ -n "${CACHE_S3_REGION:-}" ] && echo "::add-mask::${CACHE_S3_REGION}"
+[ -n "${CACHE_S3_KEY_PREFIX:-}" ] && echo "::add-mask::${CACHE_S3_KEY_PREFIX}"
diff --git a/.github/scripts/sccache-restore-s3.sh b/.github/scripts/sccache-restore-s3.sh
new file mode 100755
index 0000000000..5b4a7ea5fb
--- /dev/null
+++ b/.github/scripts/sccache-restore-s3.sh
@@ -0,0 +1,47 @@
+#! /usr/bin/env bash
+
+set -euo pipefail
+
+if [[ "${CI:-false}" != "true" && "${GITHUB_ACTIONS:-false}" != "true" ]]; then
+ echo "This script is to be run in a GitHub Actions runner only. Exiting."
+ exit 1
+fi
+
+if [ -z "${1:-}" ]; then
+ echo "::error::Usage: $(basename "$0") <cache-name> [pr-number]"
+ exit 1
+fi
+cache_name="$1"
+pr_number="${2:-}"
+
+shared_key="sccache-cache/${cache_name}-${RUNNER_OS}-${RUNNER_ARCH}.tar.gz"
+
+mkdir -p "$SCCACHE_DIR"
+
+if [ -z "${CACHE_S3_BUCKET:-}" ]; then
+ echo "::warning::S3 cache bucket not configured on this runner; sccache starts cold"
+ exit 0
+fi
+
+# Streamed, not written to disk first — avoids doubling disk usage.
+restore() {
+ local key="$1"
+ echo "Restoring sccache cache, key: ${key}"
+ aws s3 cp \
+ "s3://${CACHE_S3_BUCKET}/${CACHE_S3_KEY_PREFIX}${key}" \
+ - \
+ --region "${CACHE_S3_REGION}" --no-progress --only-show-errors \
+ | tar xzf - -C "$SCCACHE_DIR"
+}
+
+# PR-scoped first (isolates concurrent PRs from each other), falling back to
+# the shared merge_group/main cache — mainly so a PR's first push isn't cold.
+if [ -n "$pr_number" ]; then
+ pr_key="sccache-cache/${cache_name}-${RUNNER_OS}-${RUNNER_ARCH}-pr${pr_number}.tar.gz"
+ if restore "$pr_key"; then
+ exit 0
+ fi
+ echo "No PR-scoped cache found, falling back to shared cache"
+fi
+
+restore "$shared_key" || echo "::warning::No sccache cache found; starting cold"
diff --git a/.github/scripts/sccache-save-s3.sh b/.github/scripts/sccache-save-s3.sh
new file mode 100755
index 0000000000..152fa5e22f
--- /dev/null
+++ b/.github/scripts/sccache-save-s3.sh
@@ -0,0 +1,26 @@
+#! /usr/bin/env bash
+
+set -euo pipefail
+
+if [[ "${CI:-false}" != "true" && "${GITHUB_ACTIONS:-false}" != "true" ]]; then
+ echo "This script is to be run in a GitHub Actions runner only. Exiting."
+ exit 1
+fi
+
+if [ -z "${1:-}" ]; then
+ echo "::error::Usage: $(basename "$0") <cache-name> [pr-number]"
+ exit 1
+fi
+cache_name="$1"
+pr_number="${2:-}"
+
+# PR-scoped when a PR number is given, so concurrent PRs don't clobber each
+# other's — or the shared merge_group/main — cache.
+key="sccache-cache/${cache_name}-${RUNNER_OS}-${RUNNER_ARCH}${pr_number:+-pr${pr_number}}.tar.gz"
+echo "Saving sccache cache, key: ${key}"
+
+# Streamed, not written to disk first — avoids doubling disk usage.
+tar czf - -C "$SCCACHE_DIR" . \
+ | aws s3 cp - \
+ "s3://${CACHE_S3_BUCKET}/${CACHE_S3_KEY_PREFIX}${key}" \
+ --region "${CACHE_S3_REGION}" --no-progress --only-show-errors
diff --git a/.github/workflows/CI-pr.yml b/.github/workflows/CI-pr.yml
index 57c8304bdb..0848797209 100644
--- a/.github/workflows/CI-pr.yml
+++ b/.github/workflows/CI-pr.yml
@@ -87,6 +87,12 @@ jobs:
if: ${{ ! startsWith(github.event.pull_request.base.ref, 'hotfix-') }}
env:
+ # sccache on local disk via actions/cache, not SCCACHE_GHA_ENABLED
+ # (proven slower here before — see git log for check-msrv).
+ RUSTC_WRAPPER: sccache
+ SCCACHE_DIR: ${{ github.workspace }}/.sccache
+ SCCACHE_CACHE_SIZE: "2G"
+ SCCACHE_IDLE_TIMEOUT: "0"
RUSTFLAGS: "-D warnings"
strategy:
@@ -121,22 +127,38 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- - name: Install rust cache
- uses: Swatinem/[email protected]
+ - name: Install sccache
+ uses: taiki-e/install-action@v2
with:
- save-if: false
+ tool: sccache
+ checksum: true
+
+ - name: Restore sccache cache
+ uses: actions/cache/restore@v6
+ with:
+ path: ${{ env.SCCACHE_DIR }}
+ key: sccache-local-check-msrv-${{ runner.os }}-${{ runner.arch }}
- name: Run cargo check
shell: bash
run: cargo check --features "release"
+ - name: Show sccache stats
+ if: always()
+ shell: bash
+ run: sccache --show-stats
+
test:
name: Run tests on stable toolchain
runs-on: hyperswitch-runners
env:
- # Use `sccache` for caching compilation artifacts
+ # sccache on local disk, restored as one archive instead of its native
+ # S3 backend — avoids per-object request round trips under load.
RUSTC_WRAPPER: sccache
+ SCCACHE_DIR: ${{ github.workspace }}/.sccache
+ SCCACHE_CACHE_SIZE: "4G"
+ SCCACHE_IDLE_TIMEOUT: "0"
RUSTFLAGS: "-D warnings"
steps:
@@ -177,12 +199,21 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
+ - name: Mask S3 cache location in job logs
+ shell: bash
+ run: .github/scripts/sccache-mask-s3-env.sh
+
- name: Install sccache
uses: taiki-e/install-action@v2
with:
tool: sccache
checksum: true
+ - name: Restore sccache cache from S3
+ continue-on-error: true
+ shell: bash
+ run: .github/scripts/sccache-restore-s3.sh test
+
- name: Install just
uses: taiki-e/install-action@v2
with:
@@ -191,14 +222,15 @@ jobs:
- name: Run clippy (redis-rs backend)
shell: bash
+ # Capped: uncapped + cold cache OOM'd a runner pod (git log).
env:
- CARGO_BUILD_JOBS: 3
+ CARGO_BUILD_JOBS: 9
run: just clippy
- name: Run clippy (fred backend)
shell: bash
env:
- CARGO_BUILD_JOBS: 3
+ CARGO_BUILD_JOBS: 9
run: just clippy fred
- name: Check Cargo.lock changed
@@ -215,8 +247,15 @@ jobs:
- name: Run cargo check
shell: bash
+ env:
+ CARGO_BUILD_JOBS: 9
run: cargo check --features "release"
+ - name: Show sccache stats
+ if: always()
+ shell: bash
+ run: sccache --show-stats
+
typos:
name: Spell check
runs-on: ubuntu-latest
@@ -254,8 +293,12 @@ jobs:
runs-on: hyperswitch-runners
env:
- # Use `sccache` for caching compilation artifacts
+ # sccache on local disk, restored as a single compressed archive —
+ # see `test` for why.
RUSTC_WRAPPER: sccache
+ SCCACHE_DIR: ${{ github.workspace }}/.sccache
+ SCCACHE_CACHE_SIZE: "4G"
+ SCCACHE_IDLE_TIMEOUT: "0"
steps:
- name: Checkout repository
@@ -278,12 +321,21 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
+ - name: Mask S3 cache location in job logs
+ shell: bash
+ run: .github/scripts/sccache-mask-s3-env.sh
+
- name: Install sccache
uses: taiki-e/install-action@v2
with:
tool: sccache
checksum: true
+ - name: Restore sccache cache from S3
+ continue-on-error: true
+ shell: bash
+ run: .github/scripts/sccache-restore-s3.sh check-v2
+
- name: Install just
uses: taiki-e/install-action@v2
with:
@@ -293,23 +345,30 @@ jobs:
- name: Run cargo clippy with v2 features enabled (redis-rs backend)
shell: bash
env:
- CARGO_BUILD_JOBS: 3
+ CARGO_BUILD_JOBS: 9
run: just clippy_v2
- name: Run cargo clippy with v2 features enabled (fred backend)
shell: bash
env:
- CARGO_BUILD_JOBS: 3
+ CARGO_BUILD_JOBS: 9
run: just clippy_v2 fred
- name: Run cargo check enabling only the release and v2 features (redis-rs backend)
shell: bash
env:
RUSTFLAGS: "-A warnings"
+ CARGO_BUILD_JOBS: 9
run: cargo check --no-default-features --features "release,v2,redis-rs"
- name: Run cargo check enabling only the release and v2 features (fred backend)
shell: bash
env:
RUSTFLAGS: "-A warnings"
+ CARGO_BUILD_JOBS: 9
run: cargo check --no-default-features --features "release,v2,fred"
+
+ - name: Show sccache stats
+ if: always()
+ shell: bash
+ run: sccache --show-stats
diff --git a/.github/workflows/CI-push.yml b/.github/workflows/CI-push.yml
index be6fd2318a..f2453d7eb8 100644
--- a/.github/workflows/CI-push.yml
+++ b/.github/workflows/CI-push.yml
@@ -56,7 +56,18 @@ jobs:
name: Check compilation on MSRV toolchain
runs-on: ${{ matrix.runner }}
+ permissions:
+ contents: read
+ # actions/cache keys are immutable; needed for `gh cache delete`.
+ actions: write
+
env:
+ # sccache on local disk via actions/cache, not SCCACHE_GHA_ENABLED
+ # (proven slower here before — see git log for check-msrv).
+ RUSTC_WRAPPER: sccache
+ SCCACHE_DIR: ${{ github.workspace }}/.sccache
+ SCCACHE_CACHE_SIZE: "2G"
+ SCCACHE_IDLE_TIMEOUT: "0"
RUSTFLAGS: "-D warnings"
strategy:
@@ -91,10 +102,17 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- - name: Install rust cache
- uses: Swatinem/[email protected]
+ - name: Install sccache
+ uses: taiki-e/install-action@v2
+ with:
+ tool: sccache
+ checksum: true
+
+ - name: Restore sccache cache
+ uses: actions/cache/restore@v6
with:
- save-if: ${{ github.event_name == 'push' }}
+ path: ${{ env.SCCACHE_DIR }}
+ key: sccache-local-check-msrv-${{ runner.os }}-${{ runner.arch }}
- name: Install cargo-hack
uses: taiki-e/install-action@v2
@@ -122,6 +140,27 @@ jobs:
shell: bash
run: cargo check --features "release"
+ - name: Show sccache stats
+ if: always()
+ shell: bash
+ run: sccache --show-stats
+
+ # !cancelled(), not always() — cache-on-failure, but skip on cancel.
+ - name: Delete stale sccache cache entry
+ if: ${{ !cancelled() && github.event_name == 'push' }}
+ continue-on-error: true
+ shell: bash
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: gh cache delete "sccache-local-check-msrv-${{ runner.os }}-${{ runner.arch }}" --repo "${{ github.repository }}"
+
+ - name: Save sccache cache
+ if: ${{ !cancelled() && github.event_name == 'push' }}
+ uses: actions/cache/save@v6
+ with:
+ path: ${{ env.SCCACHE_DIR }}
+ key: sccache-local-check-msrv-${{ runner.os }}-${{ runner.arch }}
+
# cargo-deny:
# name: Run cargo-deny
# runs-on: ubuntu-latest
@@ -148,10 +187,14 @@ jobs:
runs-on: hyperswitch-runners-merge
env:
- # Use `sccache` for caching compilation artifacts
+ # sccache on local disk, restored/saved as one archive instead of its
+ # native S3 backend — see CI-pr.yml's `test` for why. This job
+ # populates the shared cache: PRs restore-only, this saves on `push`.
RUSTC_WRAPPER: sccache
+ SCCACHE_DIR: ${{ github.workspace }}/.sccache
+ SCCACHE_CACHE_SIZE: "4G"
+ SCCACHE_IDLE_TIMEOUT: "0"
RUSTFLAGS: "-D warnings"
- CARGO_BUILD_JOBS: 2
steps:
- name: Checkout repository
@@ -174,12 +217,6 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- # - name: Install sccache
- # uses: taiki-e/install-action@v2
- # with:
- # tool: sccache
- # checksum: true
-
- name: Install cargo-hack
uses: taiki-e/[email protected]
with:
@@ -196,11 +233,9 @@ jobs:
shell: bash
run: .github/scripts/install-jq.sh
- # - name: Install cargo-nextest
- # uses: taiki-e/install-action@v2
- # with:
- # tool: cargo-nextest
- # checksum: true
+ - name: Mask S3 cache location in job logs
+ shell: bash
+ run: .github/scripts/sccache-mask-s3-env.sh
- name: Install sccache
uses: taiki-e/install-action@v2
@@ -208,24 +243,50 @@ jobs:
tool: sccache
checksum: true
+ - name: Restore sccache cache from S3
+ continue-on-error: true
+ shell: bash
+ run: .github/scripts/sccache-restore-s3.sh test
+
- name: Run clippy (redis-rs backend)
shell: bash
+ # Capped: uncapped + cold cache OOM'd a runner pod (git log).
+ env:
+ CARGO_BUILD_JOBS: 9
run: just clippy
- name: Run clippy (fred backend)
shell: bash
+ env:
+ CARGO_BUILD_JOBS: 9
run: just clippy fred
- name: Cargo hack
if: ${{ github.event_name == 'push' }}
shell: bash
+ env:
+ CARGO_BUILD_JOBS: 9
run: just ci_hack
- name: Cargo build release
if: ${{ github.event_name == 'merge_group' }}
shell: bash
+ env:
+ CARGO_BUILD_JOBS: 9
run: cargo check --features "release"
+ - name: Show sccache stats
+ if: always()
+ shell: bash
+ run: sccache --show-stats
+
+ # !cancelled(), not always() — cache-on-failure, but skip on cancel.
+ - name: Save sccache cache to S3
+ if: ${{ !cancelled() && github.event_name == 'push' }}
+ continue-on-error: true
+ shell: bash
+ run: .github/scripts/sccache-save-s3.sh test
+
typos:
name: Spell check
runs-on: ubuntu-latest
@@ -263,8 +324,12 @@ jobs:
runs-on: hyperswitch-runners-merge
env:
- # Use `sccache` for caching compilation artifacts
+ # sccache on local disk, restored/saved as a single compressed archive
+ # — see `test` for why.
RUSTC_WRAPPER: sccache
+ SCCACHE_DIR: ${{ github.workspace }}/.sccache
+ SCCACHE_CACHE_SIZE: "4G"
+ SCCACHE_IDLE_TIMEOUT: "0"
steps:
- name: Checkout repository
@@ -286,16 +351,41 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
+ - name: Mask S3 cache location in job logs
+ shell: bash
+ run: .github/scripts/sccache-mask-s3-env.sh
+
- name: Install sccache
uses: taiki-e/install-action@v2
with:
tool: sccache
checksum: true
+ - name: Restore sccache cache from S3
+ continue-on-error: true
+ shell: bash
+ run: .github/scripts/sccache-restore-s3.sh check-v2
+
- name: Run cargo check enabling only the release and v2 features (redis-rs backend)
shell: bash
+ env:
+ CARGO_BUILD_JOBS: 9
run: cargo check --no-default-features --features "release,v2,redis-rs"
- name: Run cargo check enabling only the release and v2 features (fred backend)
shell: bash
+ env:
+ CARGO_BUILD_JOBS: 9
run: cargo check --no-default-features --features "release,v2,fred"
+
+ - name: Show sccache stats
+ if: always()
+ shell: bash
+ run: sccache --show-stats
+
+ # !cancelled(), not always() — cache-on-failure, but skip on cancel.
+ - name: Save sccache cache to S3
+ if: ${{ !cancelled() && github.event_name == 'push' }}
+ continue-on-error: true
+ shell: bash
+ run: .github/scripts/sccache-save-s3.sh check-v2
diff --git a/.github/workflows/cypress-tests-runner.yml b/.github/workflows/cypress-tests-runner.yml
index ccec013635..bb4bb6dd07 100644
--- a/.github/workflows/cypress-tests-runner.yml
+++ b/.github/workflows/cypress-tests-runner.yml
@@ -145,8 +145,15 @@ jobs:
# use hyperswitch-runners-merge for merge queue level checks
runs-on: ${{ case(github.event_name == 'merge_group', 'hyperswitch-runners-merge', 'hyperswitch-runners') }}
env:
- # Use `sccache` for caching compilation artifacts
+ # sccache on local disk, restored/saved as one archive instead of its
+ # native S3 backend — avoids per-request round trips under load.
RUSTC_WRAPPER: sccache
+ SCCACHE_DIR: ${{ github.workspace }}/.sccache
+ SCCACHE_CACHE_SIZE: "4G"
+ # Default 600s idle timeout can kill the server mid-compile once
+ # parallelism narrows to one long-running crate near the tail of the
+ # build (mozilla/sccache#204) — reproduced on a real run here.
+ SCCACHE_IDLE_TIMEOUT: "0"
steps:
- name: Skip tests for PRs from forks
shell: bash
@@ -176,6 +183,10 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
+ - name: Mask S3 cache location in job logs
+ shell: bash
+ run: .github/scripts/sccache-mask-s3-env.sh
+
- name: Install sccache
if: ${{ env.RUN_TESTS == 'true' }}
uses: taiki-e/install-action@v2
@@ -183,18 +194,40 @@ jobs:
tool: sccache
checksum: true
+ - name: Restore sccache cache from S3
+ if: ${{ env.RUN_TESTS == 'true' }}
+ continue-on-error: true
+ shell: bash
+ run: .github/scripts/sccache-restore-s3.sh build-hyperswitch "${{ github.event.pull_request.number }}"
+
- name: Build project
if: ${{ env.RUN_TESTS == 'true' }}
- run: cargo build --package router --bin router --jobs 2
+ env:
+ CARGO_BUILD_JOBS: 9
+ run: cargo build --package router --bin router
- - name: Upload binary artifact
+ - name: Show sccache stats
+ if: ${{ always() && env.RUN_TESTS == 'true' }}
+ shell: bash
+ run: sccache --show-stats
+
+ # RUN_TESTS excludes fork PRs, so this never writes from an untrusted
+ # checkout. PR runs save PR-scoped (empty PR number on merge_group
+ # falls back to the shared job-scope key — see sccache-save-s3.sh).
+ - name: Compress and upload sccache cache to S3
if: ${{ env.RUN_TESTS == 'true' }}
- uses: actions/upload-artifact@v7
- with:
- name: hyperswitch-server
- overwrite: true
- path: target/debug/router
- retention-days: 1
+ continue-on-error: true
+ shell: bash
+ run: .github/scripts/sccache-save-s3.sh build-hyperswitch "${{ github.event.pull_request.number }}"
+
+ # Keyed by run id so concurrent runs (different PRs) never collide.
+ - name: Upload binary to S3
+ if: ${{ env.RUN_TESTS == 'true' }}
+ shell: bash
+ run: |
+ aws s3 cp target/debug/router \
+ "s3://${CACHE_S3_BUCKET}/${CACHE_S3_KEY_PREFIX}build-artifacts/${{ github.run_id }}/router" \
+ --region "${CACHE_S3_REGION}" --no-progress --only-show-errors
prepare-mandatory-matrix:
name: Prepare Mandatory Connectors matrix to run cypress tests
@@ -295,19 +328,14 @@ jobs:
toolchain: stable 2 weeks ago
components: rustfmt
- - name: Install sccache
- if: ${{ env.RUN_TESTS == 'true' }}
- uses: taiki-e/install-action@v2
- with:
- tool: sccache
- checksum: true
+ - name: Mask S3 cache location in job logs
+ shell: bash
+ run: .github/scripts/sccache-mask-s3-env.sh
- - name: Download hyperswitch server artifact
+ - name: Download hyperswitch server binary from S3
if: ${{ env.RUN_TESTS == 'true' }}
- uses: actions/download-artifact@v8
- with:
- name: hyperswitch-server
- path: target/debug
+ shell: bash
+ run: .github/scripts/download-hyperswitch-binary-s3.sh
- name: Make server executable
if: ${{ env.RUN_TESTS == 'true' }}
@@ -347,11 +375,9 @@ jobs:
- name: Install Diesel CLI
if: ${{ env.RUN_TESTS == 'true' }}
- uses: baptiste0928/[email protected]
+ uses: taiki-e/install-action@v2
with:
- crate: diesel_cli
- features: postgres
- args: --no-default-features
+ tool: diesel_cli
- name: Install Just
if: ${{ env.RUN_TESTS == 'true' }}
@@ -584,17 +610,13 @@ jobs:
toolchain: stable 2 weeks ago
components: rustfmt
- - name: Install sccache
- uses: taiki-e/install-action@v2
- with:
- tool: sccache
- checksum: true
+ - name: Mask S3 cache location in job logs
+ shell: bash
+ run: .github/scripts/sccache-mask-s3-env.sh
- - name: Download hyperswitch server artifact
- uses: actions/download-artifact@v8
- with:
- name: hyperswitch-server
- path: target/debug
+ - name: Download hyperswitch server binary from S3
+ shell: bash
+ run: .github/scripts/download-hyperswitch-binary-s3.sh
- name: Make server executable
run: chmod +x target/debug/router
@@ -629,11 +651,9 @@ jobs:
echo "CYPRESS_ADMINAPIKEY=${LOCAL_ADMIN_API_KEY}" >> $GITHUB_ENV
- name: Install Diesel CLI
- uses: baptiste0928/[email protected]
+ uses: taiki-e/install-action@v2
with:
- crate: diesel_cli
- features: postgres
- args: --no-default-features
+ tool: diesel_cli
- name: Install Just
uses: taiki-e/install-action@v2
@@ -868,19 +888,14 @@ jobs:
toolchain: stable 2 weeks ago
components: rustfmt
- - name: Install sccache
- if: ${{ env.RUN_TESTS == 'true' }}
- uses: taiki-e/install-action@v2
- with:
- tool: sccache
- checksum: true
+ - name: Mask S3 cache location in job logs
+ shell: bash
+ run: .github/scripts/sccache-mask-s3-env.sh
- - name: Download hyperswitch server artifact
+ - name: Download hyperswitch server binary from S3
if: ${{ env.RUN_TESTS == 'true' }}
- uses: actions/download-artifact@v8
- with:
- name: hyperswitch-server
- path: target/debug
+ shell: bash
+ run: .github/scripts/download-hyperswitch-binary-s3.sh
- name: Make server executable
if: ${{ env.RUN_TESTS == 'true' }}
@@ -919,11 +934,9 @@ jobs:
- name: Install Diesel CLI
if: ${{ env.RUN_TESTS == 'true' }}
- uses: baptiste0928/[email protected]
+ uses: taiki-e/install-action@v2
with:
- crate: diesel_cli
- features: postgres
- args: --no-default-features
+ tool: diesel_cli
- name: Install Just
if: ${{ env.RUN_TESTS == 'true' }}
@@ -1307,17 +1320,13 @@ jobs:
toolchain: stable 2 weeks ago
components: rustfmt
- - name: Install sccache
- uses: taiki-e/install-action@v2
- with:
- tool: sccache
- checksum: true
+ - name: Mask S3 cache location in job logs
+ shell: bash
+ run: .github/scripts/sccache-mask-s3-env.sh
- - name: Download hyperswitch server artifact
- uses: actions/download-artifact@v8
- with:
- name: hyperswitch-server
- path: target/debug
+ - name: Download hyperswitch server binary from S3
+ shell: bash
+ run: .github/scripts/download-hyperswitch-binary-s3.sh
- name: Make server executable
run: chmod +x target/debug/router
@@ -1352,11 +1361,9 @@ jobs:
echo "CYPRESS_ADMINAPIKEY=${LOCAL_ADMIN_API_KEY}" >> $GITHUB_ENV
- name: Install Diesel CLI
- uses: baptiste0928/[email protected]
+ uses: taiki-e/install-action@v2
with:
- crate: diesel_cli
- features: postgres
- args: --no-default-features
+ tool: diesel_cli
- name: Install Just
uses: taiki-e/install-action@v2
@@ -1502,12 +1509,14 @@ jobs:
if: ${{ env.RUN_TESTS == 'true' }}
uses: actions/checkout@v6
- - name: Download hyperswitch server artifact
+ - name: Mask S3 cache location in job logs
+ shell: bash
+ run: .github/scripts/sccache-mask-s3-env.sh
+
+ - name: Download hyperswitch server binary from S3
if: ${{ env.RUN_TESTS == 'true' }}
- uses: actions/download-artifact@v8
- with:
- name: hyperswitch-server
- path: target/debug
+ shell: bash
+ run: .github/scripts/download-hyperswitch-binary-s3.sh
- name: Make server executable
if: ${{ env.RUN_TESTS == 'true' }}
@@ -1534,20 +1543,11 @@ jobs:
toolchain: stable 2 weeks ago
components: rustfmt
- - name: Install sccache
- if: ${{ env.RUN_TESTS == 'true' }}
- uses: taiki-e/install-action@v2
- with:
- tool: sccache
- checksum: true
-
- name: Install Diesel CLI
if: ${{ env.RUN_TESTS == 'true' }}
- uses: baptiste0928/[email protected]
+ uses: taiki-e/install-action@v2
with:
- crate: diesel_cli
- features: postgres
- args: --no-default-features
+ tool: diesel_cli
- name: Install Just
if: ${{ env.RUN_TESTS == 'true' }}
@@ -1688,8 +1688,13 @@ jobs:
contents: read
env:
CODECOV_FILE: "lcov.info"
- # Use `sccache` for caching compilation artifacts
+ # sccache on local disk, restored/saved as one archive instead of its
+ # native S3 backend — see build-hyperswitch for why.
RUSTC_WRAPPER: sccache
+ SCCACHE_DIR: ${{ github.workspace }}/.sccache
+ SCCACHE_CACHE_SIZE: "4G"
+ # See build-hyperswitch for why.
+ SCCACHE_IDLE_TIMEOUT: "0"
services:
redis:
@@ -1782,6 +1787,10 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
+ - name: Mask S3 cache location in job logs
+ shell: bash
+ run: .github/scripts/sccache-mask-s3-env.sh
+
- name: Install sccache
if: ${{ env.RUN_TESTS == 'true' }}
uses: taiki-e/install-action@v2
@@ -1789,13 +1798,17 @@ jobs:
tool: sccache
checksum: true
+ - name: Restore sccache cache from S3
+ if: ${{ env.RUN_TESTS == 'true' }}
+ continue-on-error: true
+ shell: bash
+ run: .github/scripts/sccache-restore-s3.sh runner-v2 "${{ github.event.pull_request.number }}"
+
- name: Install Diesel CLI
if: ${{ env.RUN_TESTS == 'true' }}
- uses: baptiste0928/[email protected]
+ uses: taiki-e/install-action@v2
with:
- crate: diesel_cli
- features: postgres
- args: --no-default-features
+ tool: diesel_cli
- name: Install grcov
if: ${{ env.RUN_TESTS == 'true' }}
@@ -1852,9 +1865,23 @@ jobs:
if: ${{ env.RUN_TESTS == 'true' }}
env:
RUSTFLAGS: "-Cinstrument-coverage"
- CARGO_BUILD_JOBS: 6
+ CARGO_BUILD_JOBS: 9
run: just build_v2
+ - name: Show sccache stats
+ if: ${{ always() && env.RUN_TESTS == 'true' }}
+ shell: bash
+ run: sccache --show-stats
+
+ # RUN_TESTS excludes fork PRs, so this never writes from an untrusted
+ # checkout. PR runs save PR-scoped (empty PR number on merge_group
+ # falls back to the shared job-scope key — see sccache-save-s3.sh).
+ - name: Compress and upload sccache cache to S3
+ if: ${{ env.RUN_TESTS == 'true' }}
+ continue-on-error: true
+ shell: bash
+ run: .github/scripts/sccache-save-s3.sh runner-v2 "${{ github.event.pull_request.number }}"
+
- name: Setup Local Server
if: ${{ env.RUN_TESTS == 'true' }}
env:
diff --git a/.github/workflows/migration-check.yaml b/.github/workflows/migration-check.yaml
index 8371018cc0..d3155d46b6 100644
--- a/.github/workflows/migration-check.yaml
+++ b/.github/workflows/migration-check.yaml
@@ -53,11 +53,9 @@ jobs:
toolchain: stable 2 weeks ago
components: rustfmt
- - uses: baptiste0928/[email protected]
+ - uses: taiki-e/install-action@v2
with:
- crate: diesel_cli
- features: postgres
- args: --no-default-features
+ tool: diesel_cli
- uses: taiki-e/install-action@v2
with:
diff --git a/.github/workflows/postman-collection-runner.yml b/.github/workflows/postman-collection-runner.yml
index 82ccda8479..f9dd8bdd4b 100644
--- a/.github/workflows/postman-collection-runner.yml
+++ b/.github/workflows/postman-collection-runner.yml
@@ -103,11 +103,9 @@ jobs:
- name: Install Diesel CLI with Postgres Support
if: ${{ ((github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name)) || (github.event_name == 'merge_group')}}
- uses: baptiste0928/[email protected]
+ uses: taiki-e/install-action@v2
with:
- crate: diesel_cli
- features: postgres
- args: --no-default-features
+ tool: diesel_cli
- uses: taiki-e/install-action@v2
if: ${{ ((github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name)) || (github.event_name == 'merge_group')}}
diff --git a/.github/workflows/wasm-bulild-check.yml b/.github/workflows/wasm-bulild-check.yml
index 321da4ee28..13d3e84273 100644
--- a/.github/workflows/wasm-bulild-check.yml
+++ b/.github/workflows/wasm-bulild-check.yml
@@ -14,6 +14,20 @@ jobs:
wasm-ci:
name: Check wasm build
runs-on: ubuntu-latest
+
+ permissions:
+ contents: read
+ # actions/cache keys are immutable; needed for `gh cache delete`.
+ actions: write
+
+ env:
+ # sccache on local disk via actions/cache, not SCCACHE_GHA_ENABLED —
+ # see check-msrv in CI-push.yml for why.
+ RUSTC_WRAPPER: sccache
+ SCCACHE_DIR: ${{ github.workspace }}/.sccache
+ SCCACHE_CACHE_SIZE: "2G"
+ SCCACHE_IDLE_TIMEOUT: "0"
+
steps:
- name: Checkout repository
uses: actions/checkout@v6
@@ -23,6 +37,18 @@ jobs:
with:
toolchain: stable 2 weeks ago
+ - name: Install sccache
+ uses: taiki-e/install-action@v2
+ with:
+ tool: sccache
+ checksum: true
+
+ - name: Restore sccache cache
+ uses: actions/cache/restore@v6
+ with:
+ path: ${{ env.SCCACHE_DIR }}
+ key: sccache-local-wasm-${{ runner.os }}-${{ runner.arch }}
+
- name: Install wasm-pack
uses: taiki-e/install-action@v2
with:
@@ -36,3 +62,24 @@ jobs:
- name: payment-link wasm build
shell: bash
run: make payment-link-wasm
+
+ - name: Show sccache stats
+ if: always()
+ shell: bash
+ run: sccache --show-stats
+
+ # !cancelled(), not always() — don't delete+save on a cancelled run.
+ - name: Delete stale sccache cache entry
+ if: ${{ !cancelled() && github.event_name == 'push' }}
+ continue-on-error: true
+ shell: bash
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: gh cache delete "sccache-local-wasm-${{ runner.os }}-${{ runner.arch }}" --repo "${{ github.repository }}"
+
+ - name: Save sccache cache
+ if: ${{ !cancelled() && github.event_name == 'push' }}
+ uses: actions/cache/save@v6
+ with:
+ path: ${{ env.SCCACHE_DIR }}
+ key: sccache-local-wasm-${{ runner.os }}-${{ runner.arch }}