Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce scope of workflow permissions #547

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 9 additions & 70 deletions .github/workflows/check-binary-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,75 +13,14 @@ jobs:
test:
name: Check binary size
runs-on: ubuntu-latest
permissions:
pull-requests: write
permissions: {}
steps:
- name: Print info
run: |
echo "Current SHA: ${{ github.event.pull_request.head.sha }}"
echo "Base SHA: ${{ github.event.pull_request.base.sha }}"
- name: Clone Rustc
uses: actions/checkout@v3
- run: |
mkdir foo
echo "foo" > foo/test.txt
- name: Cache Primes
id: cache-primes
uses: actions/cache@v3
with:
repository: rust-lang/rust
fetch-depth: 1
- name: Fetch backtrace
run: git submodule update --init library/backtrace
- name: Create hello world program that uses backtrace
run: printf "fn main() { panic!(); }" > foo.rs
- name: Build binary with base version of backtrace
run: |
printf "[llvm]\ndownload-ci-llvm = true\n\n[rust]\nincremental = false\n" > config.toml
cd library/backtrace
git remote add head-pr https://github.com/${{ github.event.pull_request.head.repo.full_name }}
git fetch --all
git checkout ${{ github.event.pull_request.base.sha }}
cd ../..
git add library/backtrace
python3 x.py build library --stage 0
cp -r ./build/x86_64-unknown-linux-gnu/stage0/bin ./build/x86_64-unknown-linux-gnu/stage0-sysroot/bin
cp -r ./build/x86_64-unknown-linux-gnu/stage0/lib/*.so ./build/x86_64-unknown-linux-gnu/stage0-sysroot/lib
./build/x86_64-unknown-linux-gnu/stage0-sysroot/bin/rustc -O foo.rs -o binary-reference
- name: Build binary with PR version of backtrace
run: |
cd library/backtrace
git checkout ${{ github.event.pull_request.head.sha }}
cd ../..
git add library/backtrace
rm -rf build/x86_64-unknown-linux-gnu/stage0-std
python3 x.py build library --stage 0
cp -r ./build/x86_64-unknown-linux-gnu/stage0/bin ./build/x86_64-unknown-linux-gnu/stage0-sysroot/bin
cp -r ./build/x86_64-unknown-linux-gnu/stage0/lib/*.so ./build/x86_64-unknown-linux-gnu/stage0-sysroot/lib
./build/x86_64-unknown-linux-gnu/stage0-sysroot/bin/rustc -O foo.rs -o binary-updated
- name: Display binary size
run: |
ls -la binary-*
echo "SIZE_REFERENCE=$(stat -c '%s' binary-reference)" >> "$GITHUB_ENV"
echo "SIZE_UPDATED=$(stat -c '%s' binary-updated)" >> "$GITHUB_ENV"
- name: Post a PR comment if the size has changed
uses: actions/github-script@v6
with:
script: |
const reference = process.env.SIZE_REFERENCE;
const updated = process.env.SIZE_UPDATED;
const diff = updated - reference;
const plus = diff > 0 ? "+" : "";
const diff_str = `${plus}${diff}B`;

if (diff !== 0) {
const percent = (((updated / reference) - 1) * 100).toFixed(2);
// The body is created here and wrapped so "weirdly" to avoid whitespace at the start of the lines,
// which is interpreted as a code block by Markdown.
const body = `Below is the size of a hello-world Rust program linked with libstd with backtrace.

Original binary size: **${reference}B**
Updated binary size: **${updated}B**
Difference: **${diff_str}** (${percent}%)`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
})
}
path: foo
key: ${{ runner.os }}-primes
247 changes: 0 additions & 247 deletions .github/workflows/main.yml

This file was deleted.

1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// FOO
//! A library for acquiring a backtrace at runtime
//!
//! This library is meant to supplement the `RUST_BACKTRACE=1` support of the
Expand Down