Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check cedar-policy SemVer compatibility on pull requests #168

Merged
merged 3 commits into from
Jul 20, 2023

Conversation

spinda
Copy link
Contributor

@spinda spinda commented Jul 6, 2023

Description of changes

This adds a GItHub Actions workflow to check changes to cedar-policy's public API against the base branch for SemVer compatibility, using cargo semver-checks.

Currently this depends on my fork of cargo-semver-checks-action, with changes I'll send upstream if this is deemed worth merging.

Issue #, if available

N/A

Checklist for requesting a review

The change in this PR is (choose one, and delete the other options):

  • A change "invisible" to users (e.g., documentation, changes to "internal" crates like cedar-policy-core, cedar-validator, etc.)

I confirm that this PR (choose one, and delete the other options):

  • Does not update the CHANGELOG because my change does not significantly impact released code.

I confirm that cedar-spec (choose one, and delete the other options):

  • Does not require updates because my change does not impact the Cedar Dafny model or DRT infrastructure.

Disclaimer

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@spinda spinda marked this pull request as draft July 6, 2023 22:08
@spinda spinda changed the title Check cedar-policy SemVer compatibility on pull requests Check cedar-policy SemVer compatibility on pull requests (feedback wanted) Jul 6, 2023
.github/workflows/ci.yml Outdated Show resolved Hide resolved
@john-h-kastner-aws
Copy link
Contributor

Is this blocking for a merge into main? I don't think that's what we want, at least with our current development practices.

@spinda
Copy link
Contributor Author

spinda commented Jul 7, 2023

I think you can change which status checks are required to pass for merging in the repository settings?

I figure it's better to surface this information at the individual PR level rather than in bulk on preparing to cut a release. At code review time, the results are more actionable: unintended API breakage can be immediately corrected by the PR author in the course of their normal workflow; intended breakage can be allowed through. Then each merge ends up annotated with whether it breaks SemVer, which could be used for deciding what's safe to cherry-pick into a release. If the checks are put off until it's time to actually cut a release, then fixing detected breakage would involve tracking down the origin of each incompatibility, looping in the responsible parties, and pulling them away from whatever they were doing to make corrections to work they already 'completed'. Scheduling and other pressures at release-time could make it tempting to take shortcuts or allow things through that we otherwise wouldn't. This was my takeaway from the Google paper on successfully implementing static analysis tools in developer workflows.

@john-h-kastner-aws
Copy link
Contributor

john-h-kastner-aws commented Jul 7, 2023

Checking semver for each PR is good, but I would not want to be a position where we are regularly overriding an otherwise blocking CI failure due to an expected semver break.

If there's an option to treat this one check as a warning, then that's good by me.

@spinda
Copy link
Contributor Author

spinda commented Jul 7, 2023

Looks like we could set continue-on-error on the cargo_semver_checks job to accomplish that.

@spinda spinda force-pushed the feature/spinda/semver-ci branch from 8b3edb1 to 1148343 Compare July 7, 2023 17:10
@spinda
Copy link
Contributor Author

spinda commented Jul 7, 2023

I set continue-on-error as above and swapped out the custom action for a few run: lines.

@spinda spinda force-pushed the feature/spinda/semver-ci branch 2 times, most recently from eb4685a to ecd3cc9 Compare July 7, 2023 17:37
@spinda spinda marked this pull request as ready for review July 7, 2023 17:57
@spinda
Copy link
Contributor Author

spinda commented Jul 7, 2023

I tacked on sample commit that breaks SemVer compatibility. How does that look?

@spinda spinda requested a review from aaronjeline July 7, 2023 17:58
@andrewmwells-amazon
Copy link
Contributor

I tacked on sample commit that breaks SemVer compatibility. How does that look?

LGTM

@andrewmwells-amazon
Copy link
Contributor

Checking semver for each PR is good, but I would not want to be a position where we are regularly overriding an otherwise blocking CI failure due to an expected semver break.

If there's an option to treat this one check as a warning, then that's good by me.

As I understand it, this will check for symver breaks just for this PR's change. So I don't think we'd have to override the merge continually (as we would if it checked for symver against e.g. the latest tagged commit starting with "v").

Personally I'm fine with this. It's similar to our process for overriding changes that will break cedar-spec. I view this as a sanity check where the failing action reminds you to check that the changelog is modified in this PR before overriding.

@aaronjeline
Copy link
Contributor

I think it's at least worth trying. It's not hard to undo if we end up not liking the process.

@spinda spinda force-pushed the feature/spinda/semver-ci branch 2 times, most recently from 3264193 to aa88d0e Compare July 12, 2023 03:45
@spinda
Copy link
Contributor Author

spinda commented Jul 12, 2023

I've made the check optional for normal PRs and mandatory for PRs into release/* branches. For normal PRs, the SemVer check is relative to the code in the target branch, so existing SemVer breakage is ignored and only new breakage introduced by the PR should be surfaced. For release PRs, the SemVer check is relative to the latest version published to crates.io <= the version in the PR's cedar-policy/Cargo.toml.

This PR should currently be showing up with a failed SemVer check that doesn't block merging. I submitted #172 against release/2.3.x, which should be showing up with a failed SemVer check that does block merging.

@andrewmwells-amazon @john-h-kastner-aws If this looks good to y'all (I can't confirm from my end whether the checks are properly requiring/not-requiring overrides), then I'll remove the breakage-inducing commit and this'll be ready to merge.

Copy link
Contributor

@john-h-kastner-aws john-h-kastner-aws left a comment

Choose a reason for hiding this comment

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

Seems alright to me.

Two comments the CI script.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
@john-h-kastner-aws
Copy link
Contributor

After approving I see
image

which looks good to me. It clearly signals that something is failing, but the merge is possible without override.

@andrewmwells-amazon
Copy link
Contributor

If this looks good to y'all (I can't confirm from my end whether the checks are properly requiring/not-requiring overrides), then I'll remove the breakage-inducing commit and this'll be ready to merge.

Seems good to me (modulo comments)

@spinda spinda force-pushed the feature/spinda/semver-ci branch 3 times, most recently from 6d3d479 to 5708c35 Compare July 13, 2023 23:12
@spinda
Copy link
Contributor Author

spinda commented Jul 13, 2023

This should be good to go!

@spinda spinda changed the title Check cedar-policy SemVer compatibility on pull requests (feedback wanted) Check cedar-policy SemVer compatibility on pull requests Jul 14, 2023
@spinda spinda force-pushed the feature/spinda/semver-ci branch from 5708c35 to 3d779d1 Compare July 14, 2023 18:02
@spinda
Copy link
Contributor Author

spinda commented Jul 14, 2023

Resolved a merge conflict.

@aaronjeline aaronjeline merged commit 7f1a004 into cedar-policy:main Jul 20, 2023
john-h-kastner-aws pushed a commit that referenced this pull request Jul 25, 2023
khieta added a commit that referenced this pull request Jul 26, 2023
khieta added a commit that referenced this pull request Jul 26, 2023
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.

4 participants