|
32 | 32 | containing the content of the 'source' directory for the analysis. |
33 | 33 | Also supports sub-folders for multiple source code bases. |
34 | 34 | Please use 'include-hidden-files: true' if you also want to upload the git history. |
| 35 | + Note: JavaScript dependencies will NOT be installed automatically when using this option. This needs to be done before uploading the sources. |
35 | 36 | required: false |
36 | 37 | type: string |
37 | 38 | default: '' |
|
40 | 41 | The URL of the source repository to analyze. For now, only GitHub repositories are supported. |
41 | 42 | This can be used instead of 'sources-upload-name' to directly analyze a repository without uploading artifacts first. |
42 | 43 | It can also be used in addition to 'sources-upload-name' to analyze both uploaded sources and a repository. |
| 44 | + If specified, JavaScript dependencies will be installed automatically if a package.json file is found in the repository. |
43 | 45 | required: false |
44 | 46 | type: string |
45 | 47 | default: '' |
@@ -143,7 +145,8 @@ jobs: |
143 | 145 | distribution: "temurin" |
144 | 146 | java-version: ${{ matrix.java }} |
145 | 147 |
|
146 | | - # "Setup Python" can be skipped if jupyter notebook analysis-results aren't needed |
| 148 | + # "Setup Python" could be skipped if jupyter notebook analysis-results aren't needed or .venv is used. |
| 149 | + # However, since this is a reuseable workflow, we always do it here. |
147 | 150 | - name: (Python Setup) Use version ${{ matrix.python }} with Conda package manager Miniforge |
148 | 151 | if: inputs.use-venv_virtual_python_environment == 'false' |
149 | 152 | id: prepare-conda-environment |
@@ -203,7 +206,31 @@ jobs: |
203 | 206 | working-directory: temp/${{ inputs.analysis-name }} |
204 | 207 | run: ./../../scripts/cloneGitRepository.sh --url "${{ inputs.source-repository }}" --branch "${{ inputs.source-repository-branch }}" --history-only "${{ inputs.source-repository-history-only }}" --target "source/${{ inputs.analysis-name }}" |
205 | 208 |
|
206 | | - - name: (Code Analysis Setup) Install JavaScript dependencies in cloned source repository if needed |
| 209 | + - name: (Code Analysis JavaScript Setup) Detect node version file .nvmrc in cloned source repository |
| 210 | + if: inputs.source-repository != '' |
| 211 | + working-directory: temp/${{ inputs.analysis-name }}/source/${{ inputs.analysis-name }} |
| 212 | + run: echo "nodeVersionFileDetected=$(if [ -f ".nvmrc" ]; then echo "true"; else echo "false"; fi)" >> $GITHUB_ENV |
| 213 | + - name: (Code Analysis JavaScript Setup) Detect pnpm project in cloned source repository |
| 214 | + if: inputs.source-repository != '' |
| 215 | + working-directory: temp/${{ inputs.analysis-name }}/source/${{ inputs.analysis-name }} |
| 216 | + run: echo "pnpmDetected=$(if [ -f "pnpm-lock.yaml" ]; then echo "true"; else echo "false"; fi)" >> $GITHUB_ENV |
| 217 | + - name: (Code Analysis JavaScript Setup) Setup Node.js with version in .nvmrc for cloned source repository |
| 218 | + if: inputs.source-repository != '' && env.nodeVersionFileDetected == 'true' |
| 219 | + uses: actions/setup-node@v6.1.0 |
| 220 | + with: |
| 221 | + node-version-file: temp/${{ inputs.analysis-name }}/source/${{ inputs.analysis-name }}/.nvmrc |
| 222 | + - name: (Code Analysis JavaScript Setup) Setup Node.js (long-term support version fallback, no .nvmrc) for cloned source repository |
| 223 | + if: inputs.source-repository != '' && env.nodeVersionFileDetected != 'true' |
| 224 | + uses: actions/setup-node@v6.1.0 |
| 225 | + with: |
| 226 | + node-version: 'lts/*' |
| 227 | + - name: (Code Analysis JavaScript Setup) Setup pnpm for cloned source repository |
| 228 | + if: inputs.source-repository != '' && env.pnpmDetected == 'true' |
| 229 | + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 |
| 230 | + with: |
| 231 | + package_json_file: temp/${{ inputs.analysis-name }}/source/${{ inputs.analysis-name }}/package.json |
| 232 | + run_install: false |
| 233 | + - name: (Code Analysis JavaScript Setup) Install JavaScript dependencies in cloned source repository if needed |
207 | 234 | if: inputs.source-repository != '' |
208 | 235 | working-directory: temp/${{ inputs.analysis-name }} |
209 | 236 | run: ./../../scripts/installJavaScriptDependencies.sh |
@@ -243,16 +270,26 @@ jobs: |
243 | 270 | id: set-analysis-results-artifact-name |
244 | 271 | run: echo "uploaded-analysis-results-artifact-name=code-analysis-results-${{ env.ENVIRONMENT_INFO }}" >> $GITHUB_OUTPUT |
245 | 272 |
|
246 | | - # Upload successful analysis-results in case they are needed for troubleshooting |
| 273 | + # Upload successful analysis-results as the main output artifact |
247 | 274 | - name: (Code Analysis Results) Archive successful analysis-results |
248 | | - if: success() |
| 275 | + if: success() && !contains(inputs.analysis-arguments, '--explore') |
249 | 276 | uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
250 | 277 | with: |
251 | 278 | name: ${{ steps.set-analysis-results-artifact-name.outputs.uploaded-analysis-results-artifact-name }} |
252 | 279 | path: ./temp/${{ inputs.analysis-name }}/reports/* |
253 | 280 | if-no-files-found: error |
254 | 281 | retention-days: ${{ inputs.retention-days }} |
255 | 282 |
|
| 283 | + # Upload logs if analysis results had been skipped ("--explore" analysis option) |
| 284 | + - name: (Code Analysis Results) Archive successful analysis-results |
| 285 | + if: success() && contains(inputs.analysis-arguments, '--explore') |
| 286 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 287 | + with: |
| 288 | + name: ${{ steps.set-analysis-results-artifact-name.outputs.uploaded-analysis-results-artifact-name }} |
| 289 | + path: ./temp/${{ inputs.analysis-name }}/runtime/* |
| 290 | + if-no-files-found: error |
| 291 | + retention-days: ${{ inputs.retention-days }} |
| 292 | + |
256 | 293 |
|
257 | 294 | # Upload logs and unfinished analysis-results in case of an error for troubleshooting |
258 | 295 | - name: (Code Analysis Results) Archive failed run with logs and unfinished analysis-results |
|
0 commit comments