diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index bc85c92..c8ab244 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -24,19 +24,25 @@ runs: - name: Build with cross (Linux) if: runner.os == 'Linux' shell: bash + env: + TARGET: ${{ inputs.target }} run: | cargo install cross --locked - cross build --release --locked --target ${{ inputs.target }} + cross build --release --locked --target "$TARGET" - name: Build natively (macOS/Windows) if: runner.os != 'Linux' shell: bash - run: cargo build --release --locked --target ${{ inputs.target }} + env: + TARGET: ${{ inputs.target }} + run: cargo build --release --locked --target "$TARGET" - name: Final path id: get_binary_path shell: bash + env: + TARGET: ${{ inputs.target }} run: | binary=yek - [ "${{ runner.os }}" = "Windows" ] && binary=yek.exe - echo "path=target/${{ inputs.target }}/release/$binary" >> "$GITHUB_OUTPUT" + [ "$RUNNER_OS" = "Windows" ] && binary=yek.exe + echo "path=target/$TARGET/release/$binary" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 482f101..9c50526 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -212,15 +212,18 @@ jobs: - uses: dtolnay/rust-toolchain@stable - name: Run benchmarks + env: + BASE_REF: ${{ github.base_ref }} run: | - git fetch origin ${{ github.base_ref }} - git checkout ${{ github.base_ref }} + git fetch origin "$BASE_REF" + git checkout "$BASE_REF" cargo bench --bench serialization --no-run - cargo bench --bench serialization -- --save-baseline ${{ github.base_ref }} '${{ matrix.benchmark_group.group }}/' + cargo bench --bench serialization -- --save-baseline "$BASE_REF" '${{ matrix.benchmark_group.group }}/' - git checkout ${{ github.head_ref }} + # Back to the commit actions/checkout fetched; a fork's branch is not on origin. + git checkout "$GITHUB_SHA" cargo bench --bench serialization --no-run - cargo bench --bench serialization -- --baseline ${{ github.base_ref }} --noise-threshold 2 '${{ matrix.benchmark_group.group }}/' > benchmark_results.md + cargo bench --bench serialization -- --baseline "$BASE_REF" --noise-threshold 2 '${{ matrix.benchmark_group.group }}/' > benchmark_results.md echo "## Benchmark Results for ${{ matrix.benchmark_group.name }}" >> $GITHUB_STEP_SUMMARY cat benchmark_results.md >> $GITHUB_STEP_SUMMARY @@ -260,9 +263,11 @@ jobs: # --- Base Branch Coverage --- - name: Fetch and check out base branch if: github.event_name == 'pull_request' + env: + BASE_REF: ${{ github.base_ref }} run: | - git fetch origin ${{ github.base_ref }} - git checkout ${{ github.base_ref }} + git fetch origin "$BASE_REF" + git checkout "$BASE_REF" - name: Build + Test coverage on base if: github.event_name == 'pull_request' @@ -294,7 +299,8 @@ jobs: - name: Check out head branch (PR) if: github.event_name == 'pull_request' run: | - git checkout ${{ github.head_ref }} + # Back to the commit actions/checkout fetched; a fork's branch is not on origin. + git checkout "$GITHUB_SHA" - name: Build + Test coverage on PR run: | @@ -323,6 +329,8 @@ jobs: - name: Compare coverage if: github.event_name == 'pull_request' + env: + BASE_REF: ${{ github.base_ref }} run: | # Check if base coverage file exists if [ ! -f coverage-base/coverage.json ]; then @@ -341,7 +349,7 @@ jobs: # Compare and fail if coverage decreased check=$(awk -v base="$BASE_COV" -v pr="$PR_COV" 'BEGIN { if (pr < base) print 1; else print 0; }') if [ "$check" -eq 1 ]; then - git diff --unified=0 origin/${{ github.base_ref }}...HEAD -- 'src/*.rs' \ + git diff --unified=0 "origin/$BASE_REF...HEAD" -- 'src/*.rs' \ | awk ' /^\+\+\+ b\/src\// { file = substr($0, 11); next } /^@@/ {