ci: check if a PR can be backported #31
This file contains 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: PR checks # targeting only the main branch | |
on: | |
pull_request: | |
branches: | |
- main | |
types: [opened, synchronize, reopened, ready_for_review] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
env: | |
MINOR_VERSION_RELEASE: "0.47.999" # bump on a major release | |
BACKPORT_LIBS_LABEL: "backport-libs-0.47" # also bump on major release | |
jobs: | |
# Check if a PR has no major breaking changes to be backported to library | |
# maintenance branch. | |
can-backport: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write # Needed to add label based on the outcome | |
steps: | |
- uses: cargo-bins/cargo-binstall@main | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Instal cargo release | |
run: cargo binstall -y cargo-release | |
- name: Install build deps | |
run: sudo apt-get install -y protobuf-compiler libudev-dev | |
- name: Totally safe | |
# Workaround for https://github.com/actions/checkout/issues/766 | |
run: git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
- name: Change version as if we're doing a minor update | |
# This is needed so that semver-checks can find the last released | |
# baseline version to compare with. | |
run: | | |
cargo release version --no-confirm --isolated --exclude namada_apps \ | |
--execute ${{ env.MINOR_VERSION_RELEASE }} | |
- name: Check semver | |
id: semver | |
continue-on-error: true | |
uses: obi1kenobi/cargo-semver-checks-action@v2 | |
with: | |
exclude: namada_apps, namada_benchmarks, namada_light_sdk, namada_examples, namada_fuzz | |
- name: Label PR on success | |
uses: actions-ecosystem/action-add-labels@v1 | |
if: | | |
github.event.pull_request.draft == false && | |
steps.semver.outcome == 'success' && | |
${{ !contains( github.event.pull_request.labels.*.name, 'breaking:consensus') }} | |
with: | |
labels: "${{ env.BACKPORT_LIBS_LABEL }}" | |
- name: Label PR on failure | |
uses: actions-ecosystem/action-add-labels@v1 | |
if: | | |
github.event.pull_request.draft == false && | |
steps.semver.outcome == 'failure' | |
with: | |
labels: "breaking:api" |