espressif/shared--dangerjs

Repository files navigation


Codebase tests (Jest)

Welcome to the DangerJS Pull Request linter!

This is action that can be used across different Espressif repositories and helps make sure that contributors Pull Requests (PRs) follow a specific style.

It checks things like:

  • sufficient merge request descriptions
  • meaningful commit messages in conventional commit style
  • size of changes in MR
  • simple branch git history
  • source and target branch

Because DangerJS does this automatically, human reviewers can focus more on code changes and spend their time reviewing PRs more productively.


To integrate DangerJS, add workflow ./workflows/dangerjs.yml to your project with this content:

name: DangerJS Pull Request linter
on:
  pull_request_target:
    types: [opened, edited, reopened, synchronize]

permissions:
  pull-requests: write
  contents: read

jobs:
  pull-request-style-linter:
    runs-on: ubuntu-latest
    steps:
    - name: Check out PR head
      uses: actions/checkout@v4
      with:
        ref: ${{ .event.pull_request.head.sha }}

    - name: DangerJS pull request linter
      uses: espressif/shared--dangerjs@v1
      env:
        _TOKEN: ${{ secrets._TOKEN }}
  • Note: The permissions: block here is doing basically nothing; both values are default, and it would work the same without this block. It is recommended, though, to keep this block in the workflow file to be more explicit about workflow permissions since this action is running with the pull_request_target trigger. Feel free to remove the permissions block if a minimalist syntax suits you better.

  • token This token is automatically obtained from the project and its specific permissions are set in the yaml workflow file. Avoid adding unnecessarily high permissions to this token, keep it set as in the example above.


🀝 Quick Integration: If your goal is to add Shared DangerJS into your project with the default Espressif settings, then at this point you're all set!

For custom configurations, refer to the descriptions of individual rules to learn how to tweak them to your needs.


πŸ“– Important note: The Danger action will not run in the pull request where you are adding this to your project. This is due to the workflow trigger pull_request_target; this trigger runs code in the context of the target branch (typically master/main), and at that point, the workflow file is not there yet.

It will work for all subsequent pull requests right after workflow file ./workflows/dangerjs.yml is on the default branch of your project.

We recommend creating an independent PR just for this and not mixing it with other code changes or repository workflow file updates. That way, it can be easily merged and be ready for your contributors' PRs.



If your project has specific needs, Shared DangerJS can be configured to meet them.

Here is complete list of configurable parameters:

ParameterCI VariableTypeDefault value
Enable rule PR Descriptionrule-descriptionstr"true" (use "false" to disable this rule)
Enable rule PR Lint Commit Messagesrule-commit-messagesstr"true" (use "false" to disable this rule)
Enable rule PR Size (changed lines)rule-size-linesstr"true" (use "false" to disable this rule)
Enable rule PR Source branch namerule-source-branchstr"true" (use "false" to disable this rule)
Enable rule PR Target branch namerule-target-branchstr"true" (use "false" to disable this rule)
Enable rule PR Too Many Commitsrule-max-commitsstr"true" (use "false" to disable this check)
Commit message allowed "Type"scommit-messages-typesstr"change,ci,docs,feat,fix,refactor,remove,revert,test"
Commit message maximum length "Body" linecommit-messages-max-body-line-lengthstr"100"
Commit message maximum length "Summary"commit-messages-max-summary-lengthstr"72"
Commit message minimum length "Summary"commit-messages-min-summary-lengthstr"20"
Ignore sections of PR description when counting lengthdescription-ignore-sectionsstr"related,release,breaking"
Maximum changed code lines in PRmax-size-linesstr"1000"
Maximum commits in PR (soft limit, throw info)max-commits-infostr"2"
Maximum commits in PR (hard limit, throw warn)max-commits-warnstr"5"
Minimum length of PR descriptiondescription-min-lengthstr"50"

These values can be defined in your project DangerJS Pull Request linter workflow, for example like this:

    - name: DangerJS pull request linter
      uses: espressif/shared--dangerjs@v1
      env:
        _TOKEN: ${{ secrets._TOKEN }}
      with:
        instructions-contributions-file: 'CONTRIBUTING.md'
        instructions-cla-link: 'https://cla-assistant.io/espressif/test'
        instructions-gitlab-mirror: 'true'
        max-commits-info: '3'
        max-commits-warn: '6'

See more config options in DangerJS rules.


If you encounter any issues, feel free to report them in the project's issues or create Pull Request with your suggestion.

πŸ“˜ If you are interested in contributing to this project, see the project Contributing Guide.


About

This is a reusable Action CI DangerJS workflow for Espressif projects.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors 2

  •  
  •  

Languages