Detect breaking changes #10
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Detect breaking changes" | |
| on: | |
| pull_request: | |
| # branches: | |
| # - main | |
| permissions: | |
| contents: read | |
| jobs: | |
| check-semver: | |
| name: Check semver | |
| runs-on: ubuntu-latest | |
| outputs: | |
| logs: ${{ steps.check_semver.outputs.logs }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Fetch base branch | |
| run: git fetch https://github.com/${{ github.repository }}.git ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }} | |
| - name: Determine changed crates | |
| id: changed_crates | |
| run: | | |
| # Get workspace members from root Cargo.toml, excluding non-public crates | |
| MEMBERS=$(sed -n '/^members = \[/,/\]/p' Cargo.toml | grep '"' | sed 's/.*"\(.*\)".*/\1/' \ | |
| | grep -v -e '^benchmarks$' -e '^test-utils$' -e '^datafusion/sqllogictest$' -e '^datafusion/doc$') | |
| # Get changed files compared to base | |
| CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) | |
| # Check which workspace members have changes | |
| PACKAGES="" | |
| for member in $MEMBERS; do | |
| if echo "$CHANGED_FILES" | grep -q "^${member}/"; then | |
| pkg=$(grep '^name\s*=' "$member/Cargo.toml" | head -1 | sed 's/.*=\s*"\(.*\)"/\1/') | |
| if [ -n "$pkg" ]; then | |
| PACKAGES="$PACKAGES $pkg" | |
| fi | |
| fi | |
| done | |
| PACKAGES=$(echo "$PACKAGES" | xargs) | |
| echo "packages=$PACKAGES" >> "$GITHUB_OUTPUT" | |
| echo "Changed crates: $PACKAGES" | |
| - name: Install Rust toolchain | |
| if: steps.changed_crates.outputs.packages != '' | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install cargo-semver-checks | |
| if: steps.changed_crates.outputs.packages != '' | |
| run: cargo install cargo-semver-checks | |
| - name: Run cargo-semver-checks | |
| id: check_semver | |
| if: steps.changed_crates.outputs.packages != '' | |
| run: | | |
| set +e | |
| ARGS="" | |
| for pkg in ${{ steps.changed_crates.outputs.packages }}; do | |
| ARGS="$ARGS --package $pkg" | |
| done | |
| cargo semver-checks --baseline-rev origin/${{ github.base_ref }} $ARGS 2>&1 | tee /tmp/semver-output.txt | |
| EXIT_CODE=${PIPESTATUS[0]} | |
| OUTPUT=$(sed 's/\x1b\[[0-9;]*m//g' /tmp/semver-output.txt) | |
| echo "logs<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "$OUTPUT" >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| exit $EXIT_CODE | |
| comment-on-pr: | |
| name: Comment on pull request | |
| runs-on: ubuntu-latest | |
| needs: check-semver | |
| if: always() | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Comment | |
| if: ${{ needs.check-semver.result != 'success' }} | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| header: pr-semver-check-error | |
| message: | | |
| Thank you for opening this pull request! | |
| Reviewer note: [cargo-semver-checks](https://github.com/obi1kenobi/cargo-semver-checks) reported the current version number is not SemVer-compatible with the changes made since the last release. | |
| Details: | |
| ``` | |
| ${{ needs.check-semver.outputs.logs }} | |
| ``` | |
| - name: Delete comment | |
| if: ${{ needs.check-semver.result == 'success' }} | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| header: pr-semver-check-error | |
| delete: true |