name: PR Validation
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
semver:
name: Semver Check
runs-on: ubuntu-latest
if: github.event.pull_request.draft != true
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
fetch-depth: 0
- uses: tylerbutler/actions/setup-rust@2189c2e4cd75378b6db8b68ba451bf74d0975c4a - uses: tylerbutler/actions/install-tools@2189c2e4cd75378b6db8b68ba451bf74d0975c4a with:
tools: cargo-semver-checks
- name: Get merge base
id: merge-base
run: |
MERGE_BASE=$(git merge-base origin/main HEAD)
echo "sha=$MERGE_BASE" >> "$GITHUB_OUTPUT"
- name: Check semver compatibility
id: semver
env:
MERGE_BASE_SHA: ${{ steps.merge-base.outputs.sha }}
run: |
set +e
OUTPUT=$(cargo +stable semver-checks --baseline-rev "$MERGE_BASE_SHA" --color never 2>&1)
EXIT_CODE=$?
echo "$OUTPUT"
{
echo "output<<EOF"
echo "$OUTPUT"
echo "EOF"
} >> "$GITHUB_OUTPUT"
echo "has_breaking=$([[ $EXIT_CODE -ne 0 ]] && echo true || echo false)" >> "$GITHUB_OUTPUT"
exit 0
- name: Comment on PR with breaking changes
if: steps.semver.outputs.has_breaking == 'true'
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 with:
header: semver-check
message: |
## Semver Breaking Changes Detected
This PR introduces API changes that may be semver-incompatible:
```
${{ steps.semver.outputs.output }}
```
If these changes are intentional, please ensure the version bump reflects the breaking change.
- name: Remove semver comment if no breaking changes
if: steps.semver.outputs.has_breaking == 'false'
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 with:
header: semver-check
delete: true
changelog:
name: Changelog
runs-on: ubuntu-latest
if: github.event.pull_request.draft != true
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
fetch-depth: 0
- uses: tylerbutler/actions/changie-check@a2b6f63843eb7510dbcba273bd6638615f668777 id: changelog
with:
base-sha: ${{ github.event.pull_request.base.sha }}
head-sha: ${{ github.event.pull_request.head.sha }}
- name: Comment with changelog preview
if: steps.changelog.outputs.has-entries == 'true'
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 with:
header: changelog
message: |
## Changelog Preview
This PR adds the following changelog entries:
${{ steps.changelog.outputs.preview }}
- name: Comment about missing changelog
if: steps.changelog.outputs.has-entries == 'false' && steps.changelog.outputs.needs-entry == 'true'
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 with:
header: changelog
message: |
## Missing Changelog Entry
This PR includes commits with types that typically require a changelog entry (`${{ steps.changelog.outputs.commit-types-found }}`), but no changie fragment was found.
To add one, run:
```
changie new
```
- name: Remove changelog comment
if: steps.changelog.outputs.has-entries == 'false' && steps.changelog.outputs.needs-entry == 'false'
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 with:
header: changelog
delete: true