|
8 | 8 | name: 'PR Validation - Auto Triggered' |
9 | 9 |
|
10 | 10 | on: |
11 | | - pull_request: |
12 | | - types: [opened, synchronize, reopened] |
13 | | - branches: |
14 | | - - main |
15 | | - - release/** |
16 | | - |
17 | | - workflow_dispatch: |
18 | | - |
19 | | -permissions: |
20 | | - contents: read # Allows the workflow to read repository contents, required for checkout and other read operations |
21 | | - pull-requests: write # This is required to delete a label from the PR |
| 11 | + workflow_call: |
| 12 | + inputs: |
| 13 | + runner-type: |
| 14 | + description: 'Runner type (self-hosted or GitHub-hosted)' |
| 15 | + required: true |
| 16 | + type: string |
| 17 | + timeout: |
| 18 | + description: 'Job timeout in minutes' |
| 19 | + required: false |
| 20 | + default: 480 |
| 21 | + type: number |
| 22 | + |
| 23 | +# permissions: |
| 24 | +# contents: read # Allows the workflow to read repository contents, required for checkout and other read operations |
| 25 | +# pull-requests: write # This is required to delete a label from the PR |
22 | 26 |
|
23 | 27 |
|
24 | 28 | # Ensures that multiple validation job runs do not execute concurrently on the same PR. |
|
31 | 35 | validate: |
32 | 36 | name: 'Validate Changed Packages' |
33 | 37 | if: ${{ ! contains(github.event.pull_request.labels.*.name, 'long-run') }} |
34 | | - timeout-minutes: 640 |
35 | | - runs-on: ubuntu-latest |
| 38 | + timeout-minutes: ${{ inputs.timeout }} |
| 39 | + runs-on: ${{ inputs.runner-type == 'github-hosted' && 'ubuntu-latest' || fromJSON('["group=${{ vars.RUNNER_GROUP_LATEST }}", "labels=self-hosted"]') }} |
36 | 40 | # container: |
37 | 41 | # image: ${{ vars.SFP_IMAGE }} |
38 | 42 | # credentials: |
|
85 | 89 | echo "Deleting stale CI org" |
86 | 90 | |
87 | 91 |
|
88 | | - |
89 | | - static-check: |
90 | | - name: 'See if Static Analysis should run' |
91 | | - runs-on: ubuntu-latest |
92 | | - |
93 | | - outputs: |
94 | | - all-changed-files: ${{ steps.changed-files.outputs.all_changed_and_modified_files }} |
95 | | - |
96 | | - steps: |
97 | | - - uses: actions/checkout@v4 |
98 | | - with: |
99 | | - fetch-depth: 0 |
100 | | - |
101 | | - - name: Get all changed files for this PR |
102 | | - id: changed-files |
103 | | - uses: tj-actions/changed-files@v42 |
104 | | - with: |
105 | | - files_ignore_from_source_file: changed-files-ignore-list.txt |
106 | | - separator: "," |
107 | | - |
108 | | - - name: List changed files, skipping this job if there are no files to analyze |
109 | | - run: | |
110 | | - if [ "${{ steps.changed-files.outputs.all_changed_and_modified_files }}" == "" ]; then |
111 | | - echo 'No files eligible for scanning were changed. Skipping Static Analysis.' |
112 | | - exit 0 |
113 | | - else |
114 | | - echo ${{ steps.changed-files.outputs.all_changed_and_modified_files }} |
115 | | - fi |
116 | | -
|
117 | | - static: |
118 | | - name: 'Run Static Analysis' |
119 | | - runs-on: ubuntu-latest |
120 | | - needs: static-check |
121 | | - if: needs.static-check.outputs.all-changed-files != '' |
122 | | - |
123 | | - steps: |
124 | | - - uses: actions/checkout@v4 |
125 | | - with: |
126 | | - fetch-depth: 0 |
127 | | - |
128 | | - - name: Install Salesforce CLI & Salesforce Code Analyzer |
129 | | - run: | |
130 | | - echo "Installing Salesforce CLI & Salesforce Code Analyzer" |
131 | | - |
132 | | - - name: Run Salesforce Code Analyzer |
133 | | - id: run-code-analyzer |
134 | | - # uses: forcedotcom/run-code-analyzer@v1 |
135 | | - run: | |
136 | | - echo "Running Salesforce Code Analyzer" |
137 | | -
|
138 | | - - name: Check the outputs to determine whether to fail |
139 | | - if: | |
140 | | - steps.run-code-analyzer.outputs.exit-code > 0 || |
141 | | - steps.run-code-analyzer.outputs.num-sev1-violations > 0 |
142 | | - run: exit 1 |
143 | | - |
144 | 92 | # validate-package-coverage: |
145 | 93 | # name: 'Validate Package Metadata Coverage' |
146 | 94 | # runs-on: ubuntu-latest |
|
0 commit comments