Repository navigation
chore(experiments): lab-only D-RST-3 borrowed pattern-CSR view (deferred, evidence only) #6
This file contains hidden or 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: Check Conventional Commits format | |
| on: | |
| pull_request: | |
| branches: [ master ] | |
| # Revalidate if the title is corrected without a new code commit. | |
| types: [opened, reopened, synchronize, edited, ready_for_review] | |
| # The action does not support running on merge_group events, | |
| # but if the check succeeds in the PR there is no need to check it again. | |
| merge_group: | |
| types: [checks_requested] | |
| permissions: | |
| pull-requests: read | |
| jobs: | |
| main: | |
| name: Validate Conventional Commit PR title | |
| runs-on: ubuntu-latest | |
| # outputs: | |
| # # Whether the PR title indicates a breaking change. | |
| # breaking: ${{ steps.breaking.outputs.breaking }} | |
| # # Whether the PR body contains a "BREAKING CHANGE:" footer describing the breaking change. | |
| # has_breaking_footer: ${{ steps.breaking.outputs.has_breaking_footer }} | |
| # The following steps are only run on pull_request events. We add the | |
| # `if` statements to each individual step since we want the job to still | |
| # succeed in merge queues. | |
| steps: | |
| - name: Validate the PR title format | |
| uses: amannn/action-semantic-pull-request@v6 | |
| if: github.event_name == 'pull_request' | |
| id: lint_pr_title | |
| with: | |
| # Configure which types are allowed (newline-delimited). | |
| # Default: https://github.com/commitizen/conventional-commit-types | |
| types: | | |
| feat | |
| fix | |
| docs | |
| refactor | |
| perf | |
| test | |
| ci | |
| chore | |
| revert | |
| # Configure that a scope must always be provided. | |
| requireScope: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # `action-semantic-pull-request` does not parse the title, so it cannot | |
| # detect if it is marked as a breaking change. | |
| # | |
| # Since at this point we know the PR title is a valid conventional commit, | |
| # we can use a simple regex that looks for a '!:' sequence. It could be | |
| # more complex, but we don't care about false positives. | |
| - name: Check for breaking change flag and footer | |
| if: github.event_name == 'pull_request' | |
| id: breaking | |
| run: | | |
| echo "=== Breaking change detection ===" | |
| if [[ "${PR_TITLE}" =~ ^.*\!:.*$ ]]; then | |
| BREAKING=true | |
| echo "ℹ️ PR title declares a breaking change (!)" | |
| else | |
| BREAKING=false | |
| echo "ℹ️ PR title does NOT declare a breaking change" | |
| fi | |
| if [[ "${PR_BODY}" == *"BREAKING CHANGE:"* ]]; then | |
| HAS_FOOTER=true | |
| echo "ℹ️ PR body contains BREAKING CHANGE footer" | |
| else | |
| HAS_FOOTER=false | |
| echo "ℹ️ PR body does NOT contain BREAKING CHANGE footer" | |
| fi | |
| echo "breaking=$BREAKING" >> "$GITHUB_OUTPUT" | |
| echo "has_breaking_footer=$HAS_FOOTER" >> "$GITHUB_OUTPUT" | |
| env: | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| PR_BODY: ${{ github.event.pull_request.body }} | |
| - name: Require BREAKING CHANGE footer for breaking changes | |
| if: ${{ github.event_name == 'pull_request_target' && steps.breaking.outputs.breaking == 'true' && steps.breaking.outputs.has_breaking_footer == 'false' }} | |
| run: | | |
| echo "Hey there and thank you for opening this pull request! 👋" | |
| echo | |
| echo "It looks like your proposed title indicates a breaking change. If that's the case, please make sure to include a \"BREAKING CHANGE:\" footer in the body of the pull request describing the breaking change and any migration instructions." | |
| exit 1 | |
| - name: Fail if the footer is required but missing | |
| if: ${{ github.event_name == 'pull_request_target' && steps.breaking.outputs.breaking == 'true' && steps.breaking.outputs.has_breaking_footer == 'false' }} | |
| run: exit 1 | |
| - name: Post a comment if the PR badly formatted | |
| # When the previous steps fails, the workflow would stop. By adding this | |
| # condition you can continue the execution with the populated error message. | |
| if: always() && github.event_name == 'pull_request' && (steps.lint_pr_title.outputs.error_message != null) | |
| run: | | |
| echo "Hey there and thank you for opening this pull request! 👋" | |
| echo "" | |
| echo "We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted." | |
| echo "" | |
| echo "Your title should look like this. The scope field is optional." | |
| echo '```' | |
| echo "<type>(<scope>): <description>" | |
| echo '```' | |
| echo "" | |
| echo "If the PR includes a breaking change, mark it with an exclamation mark:" | |
| echo '```' | |
| echo "<type>!: <description>" | |
| echo '```' | |
| echo "and include a \"BREAKING CHANGE:\" footer in the body of the pull request." | |
| echo "" | |
| echo "Available types:" | |
| echo "- feat: A new feature" | |
| echo "- fix: A bug fix" | |
| echo "- docs: Documentation only changes" | |
| echo "- refactor: A code change that neither fixes a bug nor adds a feature" | |
| echo "- perf: A code change that improves performance" | |
| echo "- test: Adding missing tests or correcting existing tests" | |
| echo "- ci: Changes to the CI configuration files and scripts" | |
| echo "- chore: Other changes that don't affect the published crate" | |
| echo "- revert: Reverts a previous commit" | |
| exit 1 |