Skip to content

Commit

Permalink
SUPINT-2380: pr checksbox test feat
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshkumar1019 committed Jun 13, 2024
1 parent 30c1a82 commit 2be1dfb
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 6 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ jobs:
with:
ref: ${{ env.BRANCH_NAME }}

# - name: Remove .npmrc file if exists
# run: |
# if [ -f .npmrc ]; then
# rm .npmrc
# fi
- name: Check PR Description for Build Checkbox
id: check-build-checkbox
run: |
PR_BODY=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH")
if echo "$PR_BODY" | grep -q '\- \[x\] Stop Build'; then
echo "Build checkbox is checked. Proceeding with build."
else
echo "Build checkbox is not checked. Skipping build."
exit 78 # Exit with a neutral status to stop further jobs
fi
- name: Setup Node.js
uses: actions/setup-node@v4
Expand Down
33 changes: 32 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,45 @@ env:
BRANCH_NAME: ${{ github.head_ref || inputs.branch || 'dev' }}

jobs:
check-pr-body:
runs-on: ubuntu-latest
outputs:
should_run_ci: ${{ steps.check.outputs.should_run_ci }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.BRANCH_NAME }}

- name: Check PR body for unchecked checkbox
id: check
run: |
PR_BODY=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH")
if echo "$PR_BODY" | grep -q '\[ \]'; then
echo "should_run_ci=true" >> $GITHUB_ENV
echo "::set-output name=should_run_ci::true"
else
echo "should_run_ci=false" >> $GITHUB_ENV
echo "::set-output name=should_run_ci::false"
fi
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.BRANCH_NAME }}

- name: Check PR Description for Checkboxes
id: check-pr-description
run: |
PR_BODY=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH")
if echo "$PR_BODY" | grep -q '\- \[x\] Stop Lint'; then
echo "Lint checkbox is checked. Stopping workflow."
exit 78 # Exit with a neutral status to stop further jobs
fi
echo "Lint checkbox is not checked. Proceeding with linting."
- name: Remove .npmrc file if exists
run: |
if [ -f .npmrc ]; then
Expand All @@ -40,7 +72,6 @@ jobs:
npm config set //npm.pkg.github.com/:_authToken=${{ secrets.GIT_TOKEN }} --global
npm config set registry https://registry.npmjs.org/ --global
- name: Install @angular/cli
run: npm install -g @angular/cli

Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/pr-checkbox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Check PR Checkboxes

on:
pull_request:
types: [opened, edited, synchronize]

jobs:
check-pr-body:
runs-on: ubuntu-latest
outputs:
run_lint: ${{ steps.check.outputs.run_lint }}
run_build: ${{ steps.check.outputs.run_build }}
run_utest: ${{ steps.check.outputs.run_utest }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check PR body for checkboxes
id: check
run: |
PR_BODY=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH")
if echo "$PR_BODY" | grep -q '\- \[ \] Stop Lint'; then
echo "run_lint=true" >> $GITHUB_ENV
echo "::set-output name=run_lint::true"
else
echo "run_lint=false" >> $GITHUB_ENV
echo "::set-output name=run_lint::false"
fi
if echo "$PR_BODY" | grep -q '\- \[ \] Stop Build'; then
echo "run_build=true" >> $GITHUB_ENV
echo "::set-output name=run_build::true"
else
echo "run_build=false" >> $GITHUB_ENV
echo "::set-output name=run_build::false"
fi
if echo "$PR_BODY" | grep -q '\- \[ \] Stop Unit Tests'; then
echo "run_utest=true" >> $GITHUB_ENV
echo "::set-output name=run_utest::true"
else
echo "run_utest=false" >> $GITHUB_ENV
echo "::set-output name=run_utest::false"
fi
11 changes: 11 additions & 0 deletions .github/workflows/utest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ jobs:
with:
ref: ${{ env.BRANCH_NAME }}

- name: Check PR Description for Unit Test Checkbox
id: check-utest-checkbox
run: |
PR_BODY=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH")
if echo "$PR_BODY" | grep -q '\- \[x\] Stop Unit Tests'; then
echo "Unit Tests checkbox is checked. Proceeding with unit tests."
else
echo "Unit Tests checkbox is not checked. Skipping unit tests."
exit 78 # Exit with a neutral status to stop further jobs
fi
- name: Remove .npmrc file if exists
run: |
if [ -f .npmrc ]; then
Expand Down

0 comments on commit 2be1dfb

Please sign in to comment.