-
Notifications
You must be signed in to change notification settings - Fork 950
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Check if the PR contains a single commit, and fail otherwise. - Enable commitlint to check if commits adhere to the conventialcommits.org spec. - Update the the pull request template to point to the conventional commit spec. - Update the dependabot configuration to add the "build(...)" prefix to commits.
- Loading branch information
1 parent
2d303aa
commit 9db632f
Showing
9 changed files
with
2,099 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
helpUrl: 'https://www.conventionalcommits.org/' | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
name: Lint commit | ||
|
||
on: | ||
push: | ||
pull_request: | ||
merge_group: | ||
|
||
jobs: | ||
commitlint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check if the pull request contains a single commit | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
commit_count=${{ github.event.pull_request.commits }} | ||
if [ -z ${commit_count} ]; then | ||
echo "[ERROR] commit_count is empty" | ||
exit 1 | ||
fi | ||
if [[ ${commit_count} -ne 1 ]]; then | ||
echo "[ERROR] This pull request contains ${commit_count} commits. Squash these commits into a single commit." | ||
exit 1 | ||
else | ||
echo "This pull request contains ${commit_count} commit." | ||
fi | ||
- name: Set commit metadata | ||
run: | | ||
SET_INTERVAL_VALUES="true" | ||
if [[ ${{ github.event_name }} == 'push' ]] || [[ ${{ github.event_name }} == 'merge_group' ]]; then | ||
echo "Using default commit metadata" | ||
SET_INTERVAL_VALUES="false" | ||
elif [[ ${{ github.event_name }} == 'pull_request' ]]; then | ||
FROM_INTERVAL_COMMITLINT=${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} | ||
TO_INTERVAL_COMMITLINT=${{ github.event.pull_request.head.sha }} | ||
else | ||
echo "[ERROR] Event not supported when setting commit metadata" | ||
exit 1 | ||
fi | ||
if [ "${SET_INTERVAL_VALUES}" == "true" ]; then | ||
if [ -z "${FROM_INTERVAL_COMMITLINT}" ]; then | ||
echo "[ERROR] FROM_INTERVAL_COMMITLINT is empty" | ||
exit 1 | ||
fi | ||
if [ -z "${TO_INTERVAL_COMMITLINT}" ]; then | ||
echo "[ERROR] TO_INTERVAL_COMMITLINT is empty" | ||
exit 1 | ||
fi | ||
{ | ||
echo "FROM_INTERVAL_COMMITLINT=${FROM_INTERVAL_COMMITLINT}" | ||
echo "TO_INTERVAL_COMMITLINT=${TO_INTERVAL_COMMITLINT}" | ||
} >> "${GITHUB_ENV}" | ||
else | ||
echo "Skip updating GITHUB_ENV. SET_INTERVAL_VALUES: ${SET_INTERVAL_VALUES}" | ||
fi | ||
- name: Validate commits | ||
run: | | ||
make lint-commits | ||
... |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM node:21.4.0-bookworm | ||
|
||
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c"] | ||
|
||
RUN apt-get update \ | ||
&& apt-get --assume-yes --no-install-recommends install \ | ||
jq \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json ./ | ||
|
||
RUN jq '.dependencies | to_entries[] | select(.key | startswith("@commitlint/")) | .key + "@" + .value' package.json > commitlint-packages.txt \ | ||
&& xargs npm install -g < commitlint-packages.txt \ | ||
&& rm package.json commitlint-packages.txt \ | ||
&& commitlint --version \ | ||
&& git config --global --add safe.directory /source-repository | ||
|
||
ENTRYPOINT [ "commitlint" ] |
Oops, something went wrong.