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

Provide a "check" command #29

Open
nedbat opened this issue Dec 31, 2020 · 1 comment
Open

Provide a "check" command #29

nedbat opened this issue Dec 31, 2020 · 1 comment

Comments

@nedbat
Copy link
Owner

nedbat commented Dec 31, 2020

For use in CI, to check if a pull request has followed the right procedure: did it add a new fragment, and does the fragment have content.

Question:

  • Some pull requests don't need new fragments. A PR might have a comment or label indicating that no fragment is needed. Should this command know how to interpret that signal? Or is that something the CI integration can do, and then it decides whether to use this command or not?
@sirosen
Copy link

sirosen commented Oct 7, 2021

I've recently setup a GitHub Actions workflow which does this, including the label to exclude a PR.

example GitHub workflow
name: has_changelog
on:
  - pull_request

jobs:
  check_has_news_in_changelog_dir:
    if: ${{ ! contains(github.event.pull_request.labels.*.name, 'no-news-is-good-news') }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:  # do a deep fetch to allow merge-base and diff
          fetch-depth: 0
      - name: check PR adds a news file
        run: |
          news_files="$(git diff --name-only "$(git merge-base origin/main "$GITHUB_SHA")" "$GITHUB_SHA" -- changelog.d/*.md)"
          if [ -n "$news_files" ]; then
            echo "Saw new files. changelog.d:"
            echo "$news_files"
          else
            echo "No news files seen"
            exit 1
          fi

It would be great to replace the bash with something from scriv. I don't think it should try to replace the label check, but that an example GitHub Actions workflow like the above could go into the docs (with room for other CI systems, if anyone contributes example configs).

I would be happy to put in a PR to add something, or at least get it started! If this would be welcome, I have two questions:

  • Where should the diff be done? Should it test config.main_branches until we find one that exists, and error if none is found?
  • Any options which are needed? Maybe --git-diff-from and --git-diff-to in case someone has a special case for the diff?

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

No branches or pull requests

2 participants