Skip to content

Commit 809a2f1

Browse files
CopilotpwshBot
authored andcommitted
Cherry-pick PR PowerShell#26322 with conflicts for manual resolution
1 parent fa7640b commit 809a2f1

File tree

4 files changed

+122
-7
lines changed

4 files changed

+122
-7
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CodeQL Analysis (Reusable)
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
runner_os:
7+
description: 'Runner OS for CodeQL analysis'
8+
type: string
9+
required: false
10+
default: ubuntu-latest
11+
12+
permissions:
13+
actions: read # for github/codeql-action/init to get workflow details
14+
contents: read # for actions/checkout to fetch code
15+
security-events: write # for github/codeql-action/analyze to upload SARIF results
16+
17+
env:
18+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
19+
DOTNET_NOLOGO: 1
20+
POWERSHELL_TELEMETRY_OPTOUT: 1
21+
__SuppressAnsiEscapeSequences: 1
22+
nugetMultiFeedWarnLevel: none
23+
24+
jobs:
25+
analyze:
26+
name: Analyze
27+
runs-on: ${{ inputs.runner_os }}
28+
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
# Override automatic language detection by changing the below list
33+
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
34+
language: ['csharp']
35+
# Learn more...
36+
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
37+
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
41+
with:
42+
fetch-depth: '0'
43+
44+
- uses: actions/setup-dotnet@v5
45+
with:
46+
global-json-file: ./global.json
47+
48+
# Initializes the CodeQL tools for scanning.
49+
- name: Initialize CodeQL
50+
uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v3.29.5
51+
with:
52+
languages: ${{ matrix.language }}
53+
# If you wish to specify custom queries, you can do so here or in a config file.
54+
# By default, queries listed here will override any specified in a config file.
55+
# Prefix the list here with "+" to use these queries and those in the config file.
56+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
57+
58+
- run: |
59+
Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose
60+
name: Capture Environment
61+
shell: pwsh
62+
63+
- run: |
64+
Import-Module .\tools\ci.psm1
65+
Invoke-CIInstall -SkipUser
66+
name: Bootstrap
67+
shell: pwsh
68+
69+
- run: |
70+
Import-Module .\tools\ci.psm1
71+
Invoke-CIBuild -Configuration 'StaticAnalysis'
72+
name: Build
73+
shell: pwsh
74+
75+
- name: Perform CodeQL Analysis
76+
uses: github/codeql-action/analyze@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v3.29.5

.github/workflows/linux-ci.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,10 @@ jobs:
160160
uses: "./.github/actions/test/verify_xunit"
161161

162162
analyze:
163-
permissions:
164-
actions: read # for github/codeql-action/init to get workflow details
165-
contents: read # for actions/checkout to fetch code
166-
security-events: write # for github/codeql-action/analyze to upload SARIF results
167-
name: Analyze
168-
runs-on: ubuntu-latest
163+
name: CodeQL Analysis
169164
needs: changes
170165
if: ${{ needs.changes.outputs.source == 'true' }}
166+
<<<<<<< HEAD
171167

172168
strategy:
173169
fail-fast: false
@@ -217,6 +213,15 @@ jobs:
217213
218214
- name: Perform CodeQL Analysis
219215
uses: github/codeql-action/analyze@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
216+
=======
217+
uses: ./.github/workflows/analyze-reusable.yml
218+
permissions:
219+
actions: read
220+
contents: read
221+
security-events: write
222+
with:
223+
runner_os: ubuntu-latest
224+
>>>>>>> 5e5e17766 (Refactor analyze job to reusable workflow and enable on Windows CI (#26322))
220225

221226
ready_to_merge:
222227
name: Linux ready to merge

.github/workflows/windows-ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ jobs:
148148
- ci_build
149149
- changes
150150
if: ${{ needs.changes.outputs.source == 'true' }}
151+
<<<<<<< HEAD
151152
runs-on: windows-latest
152153
steps:
153154
- name: checkout
@@ -156,6 +157,29 @@ jobs:
156157
fetch-depth: 1000
157158
- name: Verify xUnit test results
158159
uses: "./.github/actions/test/verify_xunit"
160+
=======
161+
uses: ./.github/workflows/xunit-tests.yml
162+
with:
163+
runner_os: windows-latest
164+
test_results_artifact_name: testResults-xunit
165+
analyze:
166+
name: CodeQL Analysis
167+
needs: changes
168+
if: ${{ needs.changes.outputs.source == 'true' }}
169+
uses: ./.github/workflows/analyze-reusable.yml
170+
permissions:
171+
actions: read
172+
contents: read
173+
security-events: write
174+
with:
175+
runner_os: windows-latest
176+
windows_packaging:
177+
name: Windows Packaging
178+
needs:
179+
- changes
180+
if: ${{ needs.changes.outputs.packagingChanged == 'true' }}
181+
uses: ./.github/workflows/windows-packaging-reusable.yml
182+
>>>>>>> 5e5e17766 (Refactor analyze job to reusable workflow and enable on Windows CI (#26322))
159183
ready_to_merge:
160184
name: windows ready to merge
161185
needs:
@@ -164,6 +188,11 @@ jobs:
164188
- windows_test_elevated_others
165189
- windows_test_unelevated_ci
166190
- windows_test_unelevated_others
191+
<<<<<<< HEAD
192+
=======
193+
- analyze
194+
- windows_packaging
195+
>>>>>>> 5e5e17766 (Refactor analyze job to reusable workflow and enable on Windows CI (#26322))
167196
if: always()
168197
uses: PowerShell/compliance/.github/workflows/[email protected]
169198
with:

tools/ci.psm1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ function Invoke-CIFull
101101
# Implements the CI 'build_script' step
102102
function Invoke-CIBuild
103103
{
104+
param(
105+
[ValidateSet('Debug', 'Release', 'CodeCoverage', 'StaticAnalysis')]
106+
[string]$Configuration = 'Release'
107+
)
108+
104109
$releaseTag = Get-ReleaseTag
105110
# check to be sure our test tags are correct
106111
$result = Get-PesterTag
@@ -115,7 +120,7 @@ function Invoke-CIBuild
115120
Start-PSBuild -Configuration 'CodeCoverage' -PSModuleRestore -CI -ReleaseTag $releaseTag
116121
}
117122

118-
Start-PSBuild -PSModuleRestore -Configuration 'Release' -CI -ReleaseTag $releaseTag -UseNuGetOrg
123+
Start-PSBuild -PSModuleRestore -Configuration $Configuration -CI -ReleaseTag $releaseTag -UseNuGetOrg
119124
Save-PSOptions
120125

121126
$options = (Get-PSOptions)

0 commit comments

Comments
 (0)