Skip to content

Conversation

@ABorgna
Copy link
Member

@ABorgna ABorgna commented Dec 1, 2024

Runs cargo-semver-checks on each PR comparing it against the its base, and posting a comment when breaking API changes are detected.

The action fails on detected changes unless we flag the PR as breaking following the conventional commits format. In that case we still post a comment with the results.

Note that there exists a cargo-semver-checks-actions by obi1kenobi already but it's targeted towards comparing against the latest published crate instead of checking individual PRs, so we cannot use it here.

drive-by: Add a workflow_dispatch trigger to the ci checks action too.

Copy link
Member

@XVilka XVilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea!

@ABorgna ABorgna merged commit 3c6aa41 into master Dec 1, 2024
6 checks passed
@ABorgna ABorgna deleted the ab/semver-checks branch December 1, 2024 17:48
ABorgna added a commit that referenced this pull request Dec 8, 2024
…ow (#694)

The `semver-checks` workflow from #692 uses `pull_request_target` as a
workflow trigger.
When using `_target` instead of `pull_request` events,
`actions/checkout` fetches the _base_ branch of the PR by default.

See in this workflow, both the base and "head" checkouts use the same
sha.

https://github.com/petgraph/petgraph/actions/runs/12163228521/job/33921923785?pr=675#step:2:72

This fix sets an explicit parameter when fetching the head.

drive-by: Check if the PR has build errors and skip posting comments if
so.
ABorgna added a commit that referenced this pull request Mar 19, 2025
This is part of the CI improvements listed in #725.

Adds a check when a PR is opened or modified to ensure it's title
contains a [conventional
commits](https://www.conventionalcommits.org/en/v1.0.0/) tag, e.g.
```yml
# Some new features and bug fixes
feat: Add this algorithm
fix(component): Don't panic
# A PR that introduces a semver breaking change
fix!: Refactor all the traits
```
When a PR introduces breaking changes (that will require a breaking
semver bump) we also require a `BREAKING CHANGE: ...` line in the PR
body describing what the changes required in user code.

When the check fails, the bot posts a help message indicating what needs
to be fixed.

The list of valid tags are: `feat, fix, docs, style, refactor, perf,
test, ci, chore, revert`.
`rfc` is an invalid tag with a custom error message, useful when opening
draft PRs.
I added a pull request template with these instructions.

The main goal of this requirement is to automate changelog generation
with [release-plz](https://release-plz.dev/). The tags get grouped into
categories in the changelog, and breaking changes are automatically
picked when deciding the version bump.

This also integrates with the semver checks added in #692. The check
fails on PRs with breaking changes unless they are marked as breaking in
title.

---

The code here is based on the reusable workflow I implemented in
[CQCL/hugrverse-actions](https://github.com/CQCL/hugrverse-actions?tab=readme-ov-file#pr-title).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants