Skip to content

Commit

Permalink
ci(core): 🔧 improve PR checks
Browse files Browse the repository at this point in the history
improve PR checks for external contributors

ref: #28
  • Loading branch information
anantakumarghosh committed Sep 21, 2024
1 parent 17a34be commit 2632c67
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions .github/workflows/pr-guardrails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name : PR Guardrails
run-name: >
Validating PR #${{ github.event.pull_request.number }}, opened by ${{ github.actor }}
on: pull_request
on: pull_request_target

jobs:

branchname:
name: Validate branch name
runs-on: ubuntu-latest
Expand Down Expand Up @@ -32,11 +33,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Check out branch
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Fetch PR commits
run: |
git fetch origin +refs/pull/${{ github.event.pull_request.number }}/head:refs/remotes/origin/pr/${{ github.event.pull_request.number }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
Expand All @@ -49,7 +54,7 @@ jobs:
- name: Install commitlint
run: |
npm ci
npm i
npm install conventional-changelog-conventionalcommits@7.0.2
- name: Print versions
Expand All @@ -59,14 +64,19 @@ jobs:
npm --version
npx commitlint --version
- name: Run commitlint
run: >
npx commitlint
--from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }}
--to ${{ github.event.pull_request.head.sha }}
--verbose
- name: Get commit range
id: commit_range
run: |
BASE_SHA=$(git merge-base ${{ github.event.pull_request.base.sha }} origin/pr/${{ github.event.pull_request.number }})
echo "base_sha=$BASE_SHA" >> $GITHUB_OUTPUT
HEAD_SHA=${{ github.event.pull_request.head.sha }}
echo "head_sha=$HEAD_SHA" >> $GITHUB_OUTPUT
codelint-app:
- name: Run commitlint
run: |
npx commitlint --from ${{ steps.commit_range.outputs.base_sha }} --to ${{ steps.commit_range.outputs.head_sha }} --verbose
codelint_app:
name: Validate app code style
runs-on: ubuntu-latest

Expand Down Expand Up @@ -110,7 +120,7 @@ jobs:
run: |
npm run code:lint:app ${{ steps.git_diff.outputs.FILES_TO_LINT }}
codelint-service:
codelint_service:
name: Validate service code style
runs-on: ubuntu-latest

Expand Down Expand Up @@ -157,7 +167,7 @@ jobs:
unit_tests:
name: Run unit test cases
runs-on: ubuntu-latest
needs: [branchname, commitlint, codelint-app, codelint-service]
needs: [branchname, commitlint, codelint_app, codelint_service]

steps:
- name: Check out branch
Expand Down

0 comments on commit 2632c67

Please sign in to comment.