Skip to content

Commit

Permalink
lint executes before testing (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwj-st authored Dec 19, 2024
1 parent 327b498 commit 7501b6f
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pull_request_rules:
- name: Add label after CI lint passes
conditions:
- check-success=lint
- check-success=build
- check-success=Check_requirements
actions:
label:
add:
- lint_pass
4 changes: 2 additions & 2 deletions .github/workflows/deploy_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
cancel-in-progress: true

jobs:
build:
build_doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -50,4 +50,4 @@ jobs:
echo "MkDocs server failed to start. Here's the log:"
cat mkdocs.log
exit 1
fi
fi
9 changes: 9 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ concurrency:
jobs:
lint:
runs-on: ubuntu-latest
if: |
!contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.pull_request.title, '[skip ci]')
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -37,6 +40,9 @@ jobs:
build:
runs-on: ubuntu-latest
if: |
!contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.pull_request.title, '[skip ci]')
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -77,6 +83,9 @@ jobs:

Check_requirements:
runs-on: ubuntu-latest
if: |
!contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.pull_request.title, '[skip ci]')
steps:
- uses: actions/checkout@v4
with:
Expand Down
39 changes: 37 additions & 2 deletions .github/workflows/macOS_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
pull_request_target:
types: [opened, synchronize, labeled, reopened]
branches:
- main
workflow_dispatch:
Expand All @@ -25,7 +26,24 @@ jobs:
runs-on: macos-13

steps:
- uses: actions/checkout@v4
- name: Check for required label
if: github.event_name == 'pull_request_target'
run: |
echo " Wait for lint "
sleep 10
LABEL=$(curl -s -X GET \
-H "Authorization: Bearer ${{ secrets.PERSONAL_GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels" | \
jq -r '.[].name' | grep -q 'lint_pass' && echo "true" || echo "false")
if [ "$LABEL" == "false" ]; then
echo "The 'lint_pass' label is missing. Skipping CI process."
exit 1
fi
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
Expand Down Expand Up @@ -103,7 +121,24 @@ jobs:
runs-on: macos-13

steps:
- uses: actions/checkout@v4
- name: Check for required label
if: github.event_name == 'pull_request_target'
run: |
echo " Wait for lint "
sleep 10
LABEL=$(curl -s -X GET \
-H "Authorization: Bearer ${{ secrets.PERSONAL_GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels" | \
jq -r '.[].name' | grep -q 'lint_pass' && echo "true" || echo "false")
if [ "$LABEL" == "false" ]; then
echo "The 'lint_pass' label is missing. Skipping CI process."
exit 1
fi
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,33 @@ jobs:
&& !contains(github.event.pull_request.title, '[skip ci]')
runs-on: tps_sco_nv
steps:
- name: Check for required label
if: github.event_name == 'pull_request'
run: |
echo "Checking for 'lint_pass' label..."
TIMEOUT=360
INTERVAL=10
ELAPSED_TIME=0
while [ $ELAPSED_TIME -lt $TIMEOUT ]; do
echo $ELAPSED_TIME
PR_LABELS=$(curl -s "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels" | \
jq -r '.[].name')
if echo "$PR_LABELS" | grep -q 'lint_pass'; then
echo "'lint_pass' label found, proceeding with CI process."
break
fi

echo "Label not found, waiting $INTERVAL seconds..."
sleep $INTERVAL
ELAPSED_TIME=$((ELAPSED_TIME + INTERVAL))
done

if [ $ELAPSED_TIME -ge $TIMEOUT ]; then
echo "The 'lint_pass' label was not added within $TIMEOUT seconds. Skipping CI process."
exit 1
fi

- name: Checkout code
uses: actions/checkout@v4

Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/remove_labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Remove Labels on PR Update

on:
pull_request_target:
types: [synchronize]

jobs:
remove-labels:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Remove all labels
run: |
PR_NUMBER="${{ github.event.pull_request.number }}"
LABELS=$(gh pr view "$PR_NUMBER" --json labels -q '.labels[].name')
echo $PR_NUMBER
echo $LABELS
if [ -n "$LABELS" ]; then
for label in $LABELS; do
gh pr edit "$PR_NUMBER" --remove-label "$label"
done
else
echo "No labels to remove."
fi
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
41 changes: 40 additions & 1 deletion .github/workflows/win_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
pull_request_target:
types: [opened, synchronize, labeled, reopened]
branches:
- main
workflow_dispatch:
Expand All @@ -19,9 +20,29 @@ env:

jobs:
win-basic_tests:
if: |
!contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.pull_request.title, '[skip ci]')
runs-on: windows-latest

steps:
- name: Check for required label
shell: bash
if: github.event_name == 'pull_request_target'
run: |
echo " Wait for lint "
sleep 10
LABEL=$(curl -s -X GET \
-H "Authorization: Bearer ${{ secrets.PERSONAL_GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels" | \
jq -r '.[].name' | grep -q 'lint_pass' && echo "true" || echo "false")
if [ "$LABEL" == "false" ]; then
echo "The 'lint_pass' label is missing. Skipping CI process."
exit 1
fi
- name: Checkout code
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -114,7 +135,25 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- name: Check for required label
shell: bash
if: github.event_name == 'pull_request_target'
run: |
echo " Wait for lint "
sleep 10
LABEL=$(curl -s -X GET \
-H "Authorization: Bearer ${{ secrets.PERSONAL_GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels" | \
jq -r '.[].name' | grep -q 'lint_pass' && echo "true" || echo "false")
if [ "$LABEL" == "false" ]; then
echo "The 'lint_pass' label is missing. Skipping CI process."
exit 1
fi
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
Expand Down

0 comments on commit 7501b6f

Please sign in to comment.