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

ci: improve commit lint enforcement #659

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ inputs:
node-version:
description: 'The Node.js version to use. The default one is going to be the defined on the .nvmrc file.'
required: false
full-checkout:
description: 'Whether to do a full checkout or not. A full checkout will fetch all commits from the repository.'
required: false
default: true
runs:
using: composite
steps:
- name: Checkout all commits
if: ${{ inputs.full-checkout == 'true' }}
uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -24,6 +29,12 @@ runs:
echo "NODE_VERSION=${{ inputs.node-version }}" >> $GITHUB_ENV
fi

- name: git config
shell: bash
run: |
git config user.name "ngx-deploy-npm bot"
git config user.email "-"

- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand Down
18 changes: 4 additions & 14 deletions .github/workflows/pr.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: PR's
on:
pull_request:
types: [opened, synchronize, reopened]
name: CI
# on:
# pull_request:
# types: [opened, synchronize, reopened]

env:
PR_NUMBER: ${{ github.event.pull_request.number }}
Expand All @@ -13,16 +13,6 @@ jobs:
pr-e2e-test:
uses: ./.github/workflows/e2e-test.yml

check-commit-lint:
name: Check commit message follows guidelines
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup

- name: Execute commitlint
run: npx commitlint --from=origin/${{ github.base_ref }}

check-file-format:
name: Check files changes follow guidelines
runs-on: ubuntu-latest
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/enforce-semantic-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#? should we comment in the PR?
name: Enforce Semantic Commits

on:
pull_request:
types: [opened, edited, synchronize] #? reopened

jobs:
check-semantic-commits:
name: Check Semantic Commits
runs-on: ubuntu-latest

steps:
- name: git clone
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup

- name: Check commit messages
run: npx commitlint --from=origin/${{ github.base_ref }}

# Based on PR name
generate-commit-message:
name: Generate Commit Message
runs-on: ubuntu-latest
outputs:
commit_message: ${{ steps.generate-message.outputs.commit_message }}
steps:
- name: git clone
uses: actions/checkout@v4

- name: Generate Title
id: generate-message
run: |
COMMIT_MESSAGE='${{ github.event.pull_request.title }}'
echo "Commit Message": '$COMMIT_MESSAGE'
echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
echo "$COMMIT_MESSAGE"

validate-commit-message:
needs: [generate-commit-message]
name: Validate Commit Message
runs-on: ubuntu-latest
steps:
- name: git clone
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
full-checkout: false

- name: Validate Title
run: echo "${{needs.generate-commit-message.outputs.commit_message}}" | npx commitlint

generate-changelog:
needs: [generate-commit-message, validate-commit-message]
name: Generate Changelog
runs-on: ubuntu-latest
steps:
- name: git clone
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup

- name: Generate tmp branch
run: git checkout -b changelog

- name: Squash commits
run: |
git reset --soft $(git merge-base origin/${{ github.base_ref }} HEAD)
git commit -m "$COMMIT_MESSAGE"
git log -n 3
env:
COMMIT_MESSAGE: ${{needs.generate-commit-message.outputs.commit_message}}
6 changes: 0 additions & 6 deletions .github/workflows/publishment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup

- name: git config
shell: bash
run: |
git config user.name "Github Actions"
git config user.email "-"

- uses: ./.github/actions/download-build

- name: Check npm credentials
Expand Down
5 changes: 2 additions & 3 deletions packages/ngx-deploy-npm/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@
]
}
},
"deploy": {
"publish": {
"executor": "./dist/packages/ngx-deploy-npm:deploy",
"options": {
"distFolderPath": "dist/packages/ngx-deploy-npm",
"access": "public"
},
"dependsOn": ["build"]
},
"deploy:without-build": {
"publish:without-build": {
"executor": "./dist/packages/ngx-deploy-npm:deploy",
"options": {
"distFolderPath": "dist/packages/ngx-deploy-npm",
Expand All @@ -90,7 +90,6 @@
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"postTargets": ["build", "deploy"],
"versionTagPrefix": "v"
}
}
Expand Down