summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.github/actions/check-file-size/action.yml32
-rw-r--r--.github/workflows/downloader.yml80
2 files changed, 112 insertions, 0 deletions
diff --git a/.github/actions/check-file-size/action.yml b/.github/actions/check-file-size/action.yml
new file mode 100644
index 0000000000..cc40e2709a
--- /dev/null
+++ b/.github/actions/check-file-size/action.yml
@@ -0,0 +1,32 @@
+name: "Check file size"
+description: "Fails a file exceeds a given size limit"
+inputs:
+ artifact:
+ description: "Path to the file"
+ required: true
+ max_size:
+ description: "Maximum allowed size in bytes"
+ required: true
+runs:
+ using: "composite"
+ steps:
+ - name: Check file size
+ shell: bash
+ run: |
+ if [ -f "${{ inputs.artifact }}" ]; then
+ if [ "$(uname)" = "Darwin" ]; then
+ SIZE=$(stat -f %z "${{ inputs.artifact }}")
+ else
+ SIZE=$(stat -c %s "${{ inputs.artifact }}")
+ fi
+ echo "File size: $SIZE bytes"
+ echo "Size limit: ${{ inputs.max_size }} bytes"
+
+ if [ "$SIZE" -gt "${{ inputs.max_size }}" ]; then
+ echo "Error: Binary size exceeds limit."
+ exit 1
+ fi
+ else
+ echo "Error: File not found!"
+ exit 1
+ fi
diff --git a/.github/workflows/downloader.yml b/.github/workflows/downloader.yml
new file mode 100644
index 0000000000..ae8aabd4a8
--- /dev/null
+++ b/.github/workflows/downloader.yml
@@ -0,0 +1,80 @@
+---
+name: Installer downloader - Size test
+on:
+ pull_request:
+ paths:
+ - '**'
+ - '!**/**.md'
+ - '!.github/workflows/**'
+ - '.github/workflows/downloader.yml'
+ - '!.github/CODEOWNERS'
+ - '!android/**'
+ - '!audits/**'
+ - '!build.sh'
+ - '!ci/**'
+ - '!clippy.toml'
+ - '!deny.toml'
+ - '!rustfmt.toml'
+ - '!.yamllint'
+ - '!docs/**'
+ - '!graphics/**'
+ - '!desktop/**'
+ - '!ios/**'
+ - '!scripts/**'
+ - '!.*ignore'
+ - '!prepare-release.sh'
+ - '!**/osv-scanner.toml'
+
+permissions: {}
+
+jobs:
+ build-windows:
+ strategy:
+ matrix:
+ config:
+ - os: windows-latest
+ arch: x64
+ runs-on: ${{ matrix.config.os }}
+ env:
+ # If the file is larger than this, a regression has probably been introduced.
+ # You should think twice before increasing this limit.
+ MAX_BINARY_SIZE: 1572864
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Build
+ shell: bash
+ env:
+ # On Windows, the checkout is on the D drive, which is very small.
+ # Moving the target directory to the C drive ensures that the runner
+ # doesn't run out of space on the D drive.
+ CARGO_TARGET_DIR: "C:/cargo-target"
+ run: ./installer-downloader/build.sh
+
+ - name: Check file size
+ uses: ./.github/actions/check-file-size
+ with:
+ artifact: "C:/cargo-target/release/installer-downloader.exe"
+ max_size: ${{ env.MAX_BINARY_SIZE }}
+
+ build-macos:
+ runs-on: macos-latest
+ env:
+ # TODO: Figure out a reasonable limit for macOS
+ # If the file is larger than this, a regression has probably been introduced.
+ # You should think twice before increasing this limit.
+ MAX_BINARY_SIZE: 2097152
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Build
+ shell: bash
+ run: ./installer-downloader/build.sh
+
+ - name: Check file size
+ uses: ./.github/actions/check-file-size
+ with:
+ artifact: "./target/release/installer-downloader"
+ max_size: ${{ env.MAX_BINARY_SIZE }}