-
-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: make the commit lint job a reusable action
- Loading branch information
1 parent
656f03e
commit 82cbd5b
Showing
2 changed files
with
45 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: 'Lint Commits' | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Checkout | ||
if: github.event_name != 'pull_request' | ||
uses: actions/checkout@$CHECKOUT_VERSION | ||
with: | ||
fetch-depth: 0 # checkout full tree | ||
|
||
- name: Checkout (Pull Request) | ||
if: github.event_name == 'pull_request' | ||
uses: actions/checkout@$CHECKOUT_VERSION | ||
with: | ||
fetch-depth: 0 # checkout full tree | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Get commit information from Github (Pull Request) | ||
if: github.event_name == 'pull_request' | ||
run: gh api repos/${REPO_NAME}/pulls/${{ github.event.number }}/commits > commits.json | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set FIRST_COMMIT To Begin Linting (Pull Request) | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
pull_request_commits_length=$(cat commits.json | jq '. | length') | ||
echo "Number of commits in pull requests are $pull_request_commits_length" | ||
echo "FIRST_COMMIT=HEAD~${pull_request_commits_length}" >> $GITHUB_ENV | ||
- name: Check no merge commits | ||
run: | | ||
merge_commit_count=$(git rev-list --no-walk --count --merges $FIRST_COMMIT..HEAD) | ||
if [ "$merge_commit_count" != "0" ]; then | ||
echo " | ||
Our develop branch follows a linear history and cannot have merge commits. | ||
Please rebase to develop. | ||
" && exit 1 | ||
fi | ||
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 |
---|---|---|
|
@@ -33,33 +33,12 @@ jobs: | |
env: | ||
FIRST_COMMIT: 2fd0d36fe6ae0c2d527368683ec3a6352617b381 | ||
CONTRIBUTORS_CSV_PATH: .github/CONTRIBUTORS.csv | ||
CHECKOUT_VERSION: 8ade135a41bc03ea155e62e844d188df1ea18608 | ||
REPO_NAME: build-trust/ockam | ||
|
||
steps: | ||
- name: Checkout | ||
if: github.event_name != 'pull_request' | ||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 | ||
with: | ||
fetch-depth: 0 # checkout full tree | ||
|
||
- name: Checkout (Pull Request) | ||
if: github.event_name == 'pull_request' | ||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 | ||
with: | ||
fetch-depth: 0 # checkout full tree | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Get commit information from Github (Pull Request) | ||
if: github.event_name == 'pull_request' | ||
run: gh api repos/build-trust/ockam/pulls/${{ github.event.number }}/commits > commits.json | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set FIRST_COMMIT To Begin Linting (Pull Request) | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
pull_request_commits_length=$(cat commits.json | jq '. | length') | ||
echo "Number of commits in pull requests are $pull_request_commits_length" | ||
echo "FIRST_COMMIT=HEAD~${pull_request_commits_length}" >> $GITHUB_ENV | ||
- name: Run Composite Action | ||
uses: ./.github/actions/lint_workflow/action.yml | ||
|
||
- name: Check FIRST_COMMIT is ancestor of HEAD | ||
run: | | ||
|
@@ -78,16 +57,6 @@ jobs: | |
https://github.com/build-trust/ockam/tree/develop | ||
" && exit 1) | ||
- name: Check no merge commits | ||
run: | | ||
merge_commit_count=$(git rev-list --no-walk --count --merges $FIRST_COMMIT..HEAD) | ||
if [ "$merge_commit_count" != "0" ]; then | ||
echo " | ||
Our develop branch follows a linear history and cannot have merge commits. | ||
Please rebase to develop. | ||
" && exit 1 | ||
fi | ||
- name: Install Commitlint | ||
run: npm install --location=global @commitlint/[email protected] # TODO: move to ockam-builder docker image. | ||
|
||
|