|
18 | 18 | # Detect semver-incompatible (breaking) API changes in crates modified by a PR. |
19 | 19 | # |
20 | 20 | # Only public workspace crates that have file changes are checked. |
21 | | -# Internal crates (benchmarks, test-utils, sqllogictest, doc) are excluded. |
| 21 | +# Crates with `publish = false` (such as benchmarks and test-utils) and |
| 22 | +# datafusion-sqllogictest are excluded. |
22 | 23 | # |
23 | 24 | # This workflow only runs cargo-semver-checks and uploads the result as an |
24 | 25 | # artifact. The actual PR comment is posted by a companion workflow |
@@ -54,57 +55,58 @@ jobs: |
54 | 55 | name: Check semver |
55 | 56 | runs-on: ubuntu-latest |
56 | 57 | steps: |
| 58 | + # The checkout is GitHub's test merge commit of the PR into the base |
| 59 | + # branch. Depth 2 fetches that commit and its two parents: the base |
| 60 | + # branch commit the PR was merged into, and the PR head. |
57 | 61 | - name: Checkout |
58 | 62 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
59 | 63 | with: |
60 | | - fetch-depth: 0 |
| 64 | + fetch-depth: 2 |
61 | 65 |
|
62 | | - # `origin` may point at a fork (when a contributor runs this locally) or |
63 | | - # at a stale ref. Fetch the base branch from the PR's upstream repo into |
64 | | - # a dedicated `apache/<base>` ref so the baseline is unambiguous and the |
65 | | - # same ref name works locally (`git remote add apache ...`) and in CI. |
66 | | - - name: Fetch base branch |
67 | | - env: |
68 | | - BASE_REF: ${{ github.base_ref }} |
69 | | - REPO: ${{ github.repository }} |
70 | | - run: git fetch "https://github.com/${REPO}.git" "${BASE_REF}:refs/remotes/apache/${BASE_REF}" |
| 66 | + # Compare against the base branch commit the PR was merged into, not the |
| 67 | + # base branch's current tip, which may include changes the PR is not |
| 68 | + # built on. |
| 69 | + - name: Determine base commit |
| 70 | + id: base |
| 71 | + run: | |
| 72 | + BASE_SHA=$(git rev-parse HEAD^1) |
| 73 | + echo "sha=$BASE_SHA" >> "$GITHUB_OUTPUT" |
| 74 | + echo "Base commit: $BASE_SHA" |
71 | 75 |
|
72 | 76 | - name: Determine changed crates |
73 | 77 | id: changed_crates |
74 | 78 | env: |
75 | | - BASE_REF: ${{ github.base_ref }} |
| 79 | + BASE_SHA: ${{ steps.base.outputs.sha }} |
76 | 80 | run: | |
77 | | - PACKAGES=$(ci/scripts/changed_crates.sh changed-crates "apache/${BASE_REF}") |
| 81 | + PACKAGES=$(ci/scripts/changed_crates.sh changed-crates "$BASE_SHA") |
78 | 82 | echo "packages=$PACKAGES" >> "$GITHUB_OUTPUT" |
79 | 83 | echo "Changed crates: $PACKAGES" |
80 | 84 |
|
81 | | - # `datafusion-substrait` (and crates that depend on it via sqllogictest) |
82 | | - # have a build script that calls protoc, which is not preinstalled on |
83 | | - # ubuntu-latest runners. |
84 | | - - name: Install Protobuf Compiler |
| 85 | + # The `substrait` crate's build script runs protoc, which is not |
| 86 | + # preinstalled on ubuntu-latest runners. |
| 87 | + - name: Install protoc |
85 | 88 | if: steps.changed_crates.outputs.packages != '' |
86 | | - run: | |
87 | | - sudo apt-get update |
88 | | - sudo apt-get install -y protobuf-compiler |
| 89 | + uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2.87.29 |
| 90 | + with: |
| 91 | + |
89 | 92 |
|
90 | 93 | - name: Install cargo-semver-checks |
91 | 94 | if: steps.changed_crates.outputs.packages != '' |
92 | | - uses: taiki-e/install-action@861a07ce7084f55488e375df125cdc99bba60eb7 # v2.87.23 |
| 95 | + uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2.87.29 |
93 | 96 | with: |
94 | 97 | tool: cargo-semver-checks |
95 | 98 |
|
96 | 99 | - name: Run cargo-semver-checks |
97 | 100 | id: check_semver |
98 | 101 | if: steps.changed_crates.outputs.packages != '' |
99 | 102 | env: |
100 | | - BASE_REF: ${{ github.base_ref }} |
| 103 | + BASE_SHA: ${{ steps.base.outputs.sha }} |
101 | 104 | PACKAGES: ${{ steps.changed_crates.outputs.packages }} |
102 | 105 | run: | |
103 | 106 | set +e |
104 | 107 | # `tee` lets cargo's output stream live into the Actions log |
105 | 108 | # while we also keep a copy for the PR comment. |
106 | | - # Using `apache` remote here to point to the repository the pull request is against |
107 | | - ci/scripts/changed_crates.sh semver-check "apache/${BASE_REF}" $PACKAGES \ |
| 109 | + ci/scripts/changed_crates.sh semver-check "$BASE_SHA" $PACKAGES \ |
108 | 110 | 2>&1 | tee /tmp/semver-output.txt |
109 | 111 | EXIT_CODE=${PIPESTATUS[0]} |
110 | 112 | # Pass the result through an output instead of failing the job: |
@@ -137,7 +139,7 @@ jobs: |
137 | 139 |
|
138 | 140 | - name: Upload artifact |
139 | 141 | if: always() |
140 | | - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 142 | + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
141 | 143 | with: |
142 | 144 | name: semver-check-result |
143 | 145 | path: semver-artifact/ |
|
0 commit comments