admin icon indicating copy to clipboard operation
admin copied to clipboard

Install semantic-pull-requests for nodejs/examples

Open bnb opened this issue 5 years ago • 10 comments

I'd like to request that the Semantic Pull Request GitHub App (source) be added for nodejs/examples.

The GitHub App is built by a long-time Node.js community member and current Node.js project member (i18n) @zeke.

I've found it useful in helping create consistent and understandable commit logs in projects, especially as they grow. It seems like an ideal tool to use for nodejs/examples because it helps enforce a consistent commit structure, which will helpfully help reduce confusion for those who are trying to learn 💚

bnb avatar Apr 16 '20 18:04 bnb

👋 happy to help support this if it's what the community wants.

For the uninitiated, I recorded a demo that covers how to set up and use semantic-release and the Semantic Pull Requests GitHub app:

  • Tweet: https://twitter.com/zeke/status/1240717367501414400
  • Video: https://www.youtube.com/watch?v=rCXq86FOlzQ&feature=emb_logo
  • Repo: https://github.com/zeke/semantic-release-with-github-actions

zeke avatar Apr 16 '20 20:04 zeke

Per the new bot guidelines, here are the permissions the bot requires:

image

also, per the same policy need 2 +1s from both @nodejs/tsc and @nodejs/community-committee

bnb avatar Aug 11 '20 18:08 bnb

+1

out of curiosity, any reasons to have this as a GitHub App instead of an Action (besides it already being implemented as an App)?

mmarchini avatar Aug 11 '20 18:08 mmarchini

That would be a good question for @zeke 👍🏻

bnb avatar Aug 11 '20 18:08 bnb

Borrowing from https://github.com/zeke/semantic-pull-requests/issues/90#issuecomment-671442448

FWIW, an app works out much better for multiple projects. It's faster than GH actions, doesn't eat up actions runtime quota, easier to configure and so on. There's more you can do with GH actions but doing so again and again across projects becomes tedious after a while.

There is at least one GitHub Action with similar functionality: https://github.com/amannn/action-semantic-pull-request -- but last I checked it still had an issue with surfacing multiple checks on a single PR: https://github.com/amannn/action-semantic-pull-request/issues/5

On a personal note, I would love to see users gravitate toward Actions for validating their semantic pull requests, because maintaining the semantic-pull-requests GitHub App has required a lot of my attention. See https://github.com/zeke/semantic-pull-requests/issues/90 -- that said, I will continue to support the app until a suitable Actions alternative becomes available.

zeke avatar Aug 11 '20 18:08 zeke

what a weird issue :O

Both the Action and the App only check if commits are following https://conventionalcommits.org, right? If so I've been doing that on some projects with the following Action:

---
name: Conventional Commit Linter
on:
  push:
    branches:
      - master
  pull_request:

jobs:
  name: Lint
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v2
    - name: Use Node.js v12
      uses: actions/setup-node@v1
      with:
        node-version: v12
    - run: npm install
    - run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }}

I'm probably missing some edge cases or some use cases though.

mmarchini avatar Aug 11 '20 18:08 mmarchini

@mmarchini commits || title for squash merging, and auto-updates when the title changes.

bnb avatar Aug 11 '20 19:08 bnb

Right, was just reading the Action and my example above definitely ignores the Pull Request title. I think the problem is that the https://github.com/amannn/action-semantic-pull-request Action is creating a new Status for each run so it can stay Pending until WIP is removed. It would probably be better to create a new Check Run, since those will be tied to the current Action Check Suite (what a coincidence, I was playing with this yesterday 😅):

const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
const eventPayload = JSON.parse(await readFile(process.env.GITHUB_EVENT_PATH));

const { data: checkRun } = await octokit.checks.create({
  repo,
  owner,
  'name': 'Validate Commit',
  'head_sha': eventPayload.pull_request.head.sha
});

https://github.com/nodejs/node-auto-test/blob/master/tools/actions/validate-commit.js#L9-L17. Although I'm not 100% sure this prevents duplicate, but I think it does. Will retry on the node-auto-test repository later.

mmarchini avatar Aug 11 '20 19:08 mmarchini

cc @amann FYI 👋🏼

zeke avatar Aug 11 '20 23:08 zeke

+1

mcollina avatar Aug 12 '20 07:08 mcollina