PR Verification triggered by stonedu1011 #33
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 is a basic workflow that is manually triggered | |
name: PR | |
run-name: PR Verification triggered by ${{ github.actor }} | |
env: | |
COV_THRESHOLD: '70' | |
# Controls when the action will run. | |
on: | |
pull_request: | |
branches: [ 'main' ] | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
main: | |
name: Verify PR | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout Actions" | |
uses: actions/checkout@v4 | |
with: | |
# For security reasons, we only uses actions in "main" branch | |
ref: ${{ github.event.repository.default_branch }} | |
sparse-checkout: .github/actions | |
path: .tmp | |
- name: "Prepare" | |
uses: ./.tmp/.github/actions/prepare | |
with: | |
branch: ${{ github.head_ref }} | |
# Fetch base_ref for later use. We need to detect changed files and only consider test coverage on those files. | |
- name: "Prepare PR Verification" | |
id: prepare_pr | |
uses: ./.tmp/.github/actions/prepare_pr | |
- name: "PR Summary" | |
env: | |
PR_DIFF: ${{ steps.prepare_pr.outputs.diff }} | |
CHANGED_GO_FILES: ${{ steps.prepare_pr.outputs.changed_go_files }} | |
run: | | |
echo "Base Branch: ${{ steps.prepare_pr.outputs.base_ref }}" | |
echo "Changed Files(.go): " | |
for f in "CHANGED_GO_FILES"; do | |
echo "$f" | |
done | |
echo "Diff:" | |
echo $PR_DIFF | |
- name: "Test & Code Quality" | |
uses: ./.tmp/.github/actions/verify | |
with: | |
coverpkg: './pkg/...,./test/...' | |
lint_files: ${{ steps.prepare_pr.outputs.changed_go_files }} | |
fail_on_lint_issues: 'true' | |
- name: "Verify PR Test Coverage" | |
shell: bash | |
run: | | |
go install github.com/PaloAltoNetworks/[email protected] | |
cov dist/coverage.out -b ${{ steps.prepare_pr.outputs.base_ref }} --report-path 'dist/pr-coverage.json' -t ${{ env.COV_THRESHOLD }} -e 1 --write-report | |