forked from delta-io/delta-kernel-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (85 loc) · 3.67 KB
/
semver-checks.yml
File metadata and controls
88 lines (85 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: semver-checks
# Trigger when a PR is opened or changed. This runs with `pull_request` trigger, which means it has
# only read perms. The adding of the label happens in semver-label.yml via workflow_run which will
# will look at the status of this job, and always runs in the base-repo context.
on:
pull_request:
types:
- opened
- synchronize
- reopened
merge_group:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
check_if_pr_breaks_semver:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
ref: >-
${{ github.event_name == 'merge_group'
&& github.event.merge_group.head_sha
|| github.event.pull_request.head.sha }}
- name: Install minimal stable
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
with:
cache: false
# See build.yml top-level comment for why save-if is restricted to main.
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
save-if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
- name: Install cargo-semver-checks
uses: taiki-e/install-action@7bc99eee1f1b8902a125006cf790a1f4c8461e63 # v2.69.8
with:
tool: cargo-semver-checks
- name: Compute baseline revision
id: baseline
shell: bash
env:
MERGE_GROUP_BASE_SHA: ${{ github.event.merge_group.base_sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
if [ "${{ github.event_name }}" = "merge_group" ]; then
echo "rev=${MERGE_GROUP_BASE_SHA}" >> "$GITHUB_OUTPUT"
else
# Use the merge-base instead of the PR base SHA. The base SHA is the tip of
# the target branch when the webhook fires, which can differ from where the PR
# actually diverged. Using merge-base avoids false positives when the PR branch
# is behind the target branch.
MERGE_BASE=$(git merge-base "$PR_HEAD_SHA" "$PR_BASE_SHA")
echo "rev=${MERGE_BASE}" >> "$GITHUB_OUTPUT"
fi
- name: Run semver check
id: check
continue-on-error: true
shell: bash
env:
BASELINE_REV: ${{ steps.baseline.outputs.rev }}
# only check semver on released crates (delta_kernel and delta_kernel_ffi).
# note that this won't run on proc macro/derive crates, so don't need to include
# delta_kernel_derive etc.
run: |
cargo semver-checks -p delta_kernel -p delta_kernel_ffi --all-features \
--baseline-rev "$BASELINE_REV"
# Upload the step outcome as an artifact so semver-label.yml can read it via workflow_run.
# steps.check.outcome is the raw result *before* continue-on-error converts it to "success",
# so it correctly reflects whether a breaking change was detected.
# Only upload for pull_request events; merge_group runs have no PR to label.
- name: Save semver outcome
if: github.event_name == 'pull_request'
env:
SEMVER_OUTCOME: ${{ steps.check.outcome }}
run: echo "$SEMVER_OUTCOME" > semver-outcome.txt
- name: Upload semver outcome
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: semver-outcome
path: semver-outcome.txt
retention-days: 1