Skip to content

Commit 35b9f55

Browse files
Actions azure file storage fix (#176)
* fixing azure file upload * testing * fix pack version check * only compare detailed results * bug fix * use more threads with codeql * save latest version if the results are the same * testing * add manual publish workflow
1 parent 03de642 commit 35b9f55

3 files changed

Lines changed: 138 additions & 171 deletions

File tree

.github/workflows/build-codeql.yaml

Lines changed: 78 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ on:
1414
workflow_dispatch:
1515

1616
env:
17-
CODEQL_VERSION: 2.20.4
18-
17+
CODEQL_VERSION: 2.21.2
18+
1919
jobs:
2020
build:
2121
runs-on: windows-latest
@@ -65,17 +65,17 @@ jobs:
6565
- name: Build all Windows queries
6666
shell: cmd
6767
run: .\codeql-cli\codeql.cmd query compile --check-only .\src
68-
68+
6969
test-query-health:
7070
runs-on: windows-latest
7171
needs: build
7272
permissions:
7373
contents: read
7474
packages: write
75+
id-token: write
7576
env:
76-
CONNECTION_STRING: ${{ secrets.CONNECTION_STRING }}
77+
ACCOUNT_NAME: ${{ secrets.ACCOUNT_NAME }}
7778
SHARE_NAME: ${{ secrets.SHARE_NAME }}
78-
CONTAINER_NAME: ${{ secrets.CONTAINER_NAME }}
7979
steps:
8080
- name: Enable long git paths
8181
shell: cmd
@@ -108,14 +108,33 @@ jobs:
108108
pip install -r .\src\drivers\test\requirements.txt
109109
- name: Add msbuild to PATH
110110
uses: microsoft/setup-msbuild@v2
111+
- name: Azure Login
112+
uses: azure/login@v2
113+
with:
114+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
115+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
116+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
117+
enable-AzPSSession: true
118+
- name: Download previous results
119+
uses: azure/powershell@v2
120+
with:
121+
azPSVersion: latest
122+
inlineScript: |
123+
$context = New-AzStorageContext -StorageAccountName "$env:ACCOUNT_NAME" -UseConnectedAccount -EnableFileBackupRequestIntent
124+
$destination = "azure-detailedfunctiontestresults.xlsx"
125+
Get-AzStorageFileContent -ShareName "$env:SHARE_NAME" -Path "detailedfunctiontestresults.xlsx" -Destination $destination -Context $context
111126
- name: Run test script
112127
shell: pwsh
113-
if: ${{ env.CONNECTION_STRING != '' }}
114-
run: python src\drivers\test\build_create_analyze_test.py --codeql_path .\codeql-cli\codeql.exe --no_build --compare_results --connection_string "$env:CONNECTION_STRING" --share_name "$env:SHARE_NAME" --container_name "$env:CONTAINER_NAME" -v
115-
- name: Run test script without compare
116-
shell: pwsh
117-
if: ${{ env.CONNECTION_STRING == '' }}
118-
run: python src\drivers\test\build_create_analyze_test.py --codeql_path .\codeql-cli\codeql.exe --no_build -v
128+
run: python src\drivers\test\build_create_analyze_test.py --codeql_path .\codeql-cli\codeql.exe --no_build --compare_results -v
129+
- name: Upload result diff
130+
if: ${{ hashFiles('diffdetailedfunctiontestresults.xlsx') != '' }} # Only upload if there are changes
131+
uses: azure/powershell@v2
132+
with:
133+
azPSVersion: latest
134+
inlineScript: |
135+
$context = New-AzStorageContext -StorageAccountName "$env:ACCOUNT_NAME" -UseConnectedAccount -EnableFileBackupRequestIntent
136+
Set-AzStorageFileContent -ShareName "$env:SHARE_NAME" -Source "diffdetailedfunctiontestresults.xlsx" -Path "health-diffdetailedfunctiontestresults.xlsx" -Context $context
137+
exit 1
119138
120139

121140
test-codeql-latest-vs-current:
@@ -126,15 +145,11 @@ jobs:
126145
permissions:
127146
contents: read
128147
packages: write
148+
id-token: write
129149
env:
130-
CONNECTION_STRING: ${{ secrets.CONNECTION_STRING }}
150+
ACCOUNT_NAME: ${{ secrets.ACCOUNT_NAME }}
131151
SHARE_NAME: ${{ secrets.SHARE_NAME }}
132-
CONTAINER_NAME: ${{ secrets.CONTAINER_NAME }}
133152
steps:
134-
- name: Check Env
135-
shell: pwsh
136-
if: ${{ env.CONNECTION_STRING == '' }}
137-
run: exit 1
138153
- name: Check Prev Job
139154
if: ${{ needs.test-query-health.result == 'failure' }}
140155
shell: pwsh
@@ -148,11 +163,13 @@ jobs:
148163
path: .
149164
fetch-depth: 0
150165
- name: CodeQL Download
151-
run:
152-
$latest=(((Invoke-WebRequest -Uri https://github.com/github/codeql-cli-binaries/releases/latest).links.href | Where-Object{$_ -like "/github/codeql-cli-binaries/releases/tag/v*"}[0]) -split "/")[-1];
153-
Invoke-WebRequest -Uri "https://github.com/github/codeql-cli-binaries/releases/download/$latest/codeql-win64.zip" -OutFile codeql-win64.zip;
154-
Expand-Archive -Path codeql-win64.zip -DestinationPath .\codeql-zip -Force;
166+
run: |
167+
$latest=(((Invoke-WebRequest -Uri https://github.com/github/codeql-cli-binaries/releases/latest).links.href | Where-Object{$_ -like "/github/codeql-cli-binaries/releases/tag/v*"}[0]) -split "/")[-1]
168+
Invoke-WebRequest -Uri "https://github.com/github/codeql-cli-binaries/releases/download/$latest/codeql-win64.zip" -OutFile codeql-win64.zip
169+
Expand-Archive -Path codeql-win64.zip -DestinationPath .\codeql-zip -Force
155170
Move-Item -Path .\codeql-zip\codeql -Destination .\codeql-cli\
171+
New-Item LatestVersion -ItemType "Directory"
172+
New-Item LatestVersion/$latest
156173
- name: Install CodeQL pack dependencies
157174
shell: cmd
158175
run: |
@@ -171,9 +188,40 @@ jobs:
171188
pip install -r .\src\drivers\test\requirements.txt
172189
- name: Add msbuild to PATH
173190
uses: microsoft/setup-msbuild@v2
191+
- name: Azure Login
192+
uses: azure/login@v2
193+
with:
194+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
195+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
196+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
197+
enable-AzPSSession: true
198+
- name: Download previous results
199+
uses: azure/powershell@v2
200+
with:
201+
azPSVersion: latest
202+
inlineScript: |
203+
$context = New-AzStorageContext -StorageAccountName "$env:ACCOUNT_NAME" -UseConnectedAccount -EnableFileBackupRequestIntent
204+
$destination = "azure-detailedfunctiontestresults.xlsx"
205+
Get-AzStorageFileContent -ShareName "$env:SHARE_NAME" -Path "detailedfunctiontestresults.xlsx" -Destination $destination -Context $context
174206
- name: Run test script
175207
shell: pwsh
176-
run: python src\drivers\test\build_create_analyze_test.py --codeql_path .\codeql-cli\codeql.exe --no_build --compare_results --connection_string "$env:CONNECTION_STRING" --share_name "$env:SHARE_NAME" -v
208+
run: python src\drivers\test\build_create_analyze_test.py --codeql_path .\codeql-cli\codeql.exe --no_build --compare_results -v
209+
- name: Upload result diff
210+
if: ${{ hashFiles('diffdetailedfunctiontestresults.xlsx') != '' }} # Only upload if there are changes
211+
uses: azure/powershell@v2
212+
with:
213+
azPSVersion: latest
214+
inlineScript: |
215+
$context = New-AzStorageContext -StorageAccountName "$env:ACCOUNT_NAME" -UseConnectedAccount -EnableFileBackupRequestIntent
216+
Set-AzStorageFileContent -ShareName "$env:SHARE_NAME" -Source "diffdetailedfunctiontestresults.xlsx" -Path "version-diffdetailedfunctiontestresults.xlsx" -Context $context
217+
exit 1
218+
- name: Save Latest Version
219+
if: ${{ hashFiles('diffdetailedfunctiontestresults.xlsx') == '' }} # Only if there were no differences
220+
uses: actions/upload-artifact@v4
221+
with:
222+
name: latest-codeql-results
223+
path: |
224+
LatestVersion\*
177225
178226
test-pack-version-update:
179227
runs-on: windows-latest
@@ -198,7 +246,7 @@ jobs:
198246
$qlpack_diff = git diff HEAD~1:src/qlpack.yml src/qlpack.yml;
199247
$rec_diff = git diff HEAD~1:src/windows-driver-suites/recommended.qls src/windows-driver-suites/recommended.qls;
200248
$mf_diff = git diff HEAD~1:src/windows-driver-suites/mustfix.qls src/windows-driver-suites/mustfix.qls;
201-
if (!$qlpack_diff -and ($rec_diff -or $mf_diff)) { "Query suite file updated without updating qlpack version"; exit 1 }
249+
if (!$qlpack_diff -and ($rec_diff -or $mf_diff)) { "Query suite file updated without updating qlpack version"; exit 2 }
202250

203251
$last_qlpack_commit = git log -n 1 --pretty=format:%H -- src/qlpack.yml;
204252
$qlpack_changes =git show $last_qlpack_commit -- .\src\qlpack.yml;
@@ -209,13 +257,14 @@ jobs:
209257
$commits_since_mf_change = [int](git rev-list --count HEAD...$last_mf_commit);
210258
$commits_since_rec_change = [int](git rev-list --count HEAD...$last_rec_commit);
211259

212-
if ($commits_since_qlpack_change -gt $commits_since_mf_change) { "Mustfix query suite file modified without updating version"; exit 1 };
213-
if ($commits_since_qlpack_change -gt $commits_since_rec_change) {"Recommended query suite file modified without updating version"; exit 1 };
260+
if ($commits_since_qlpack_change -gt $commits_since_mf_change) { "Mustfix query suite file modified without updating version"; exit 3 };
261+
if ($commits_since_qlpack_change -gt $commits_since_rec_change) {"Recommended query suite file modified without updating version"; exit 4 };
214262

215-
try{$old_qlpack_version = [version]($qlpack_changes -match "-version").Substring(10);} catch {"Changed qlpack.yml without updating version"; exit 1 }
216-
try{$new_qlpack_version = [version]($qlpack_changes -match "\+version").Substring(10);} catch {"Changed qlpack.yml without updating version"; exit 1 }
217-
if ($new_qlpack_version -gt $old_qlpack_version) { exit 0 } else { "qlpack.yml version not incremented. Previously updated to version $old_qlpack_version, current version $new_qlpack_version"; exit 1 }
218-
263+
if($qlpack_changes -contains "version"){
264+
try{$old_qlpack_version = [version]($qlpack_changes -match "-version").Substring(10);} catch {"Changed qlpack.yml without updating version"; exit 5 }
265+
try{$new_qlpack_version = [version]($qlpack_changes -match "\+version").Substring(10);} catch {"Changed qlpack.yml without updating version"; exit 6 }
266+
if ($new_qlpack_version -gt $old_qlpack_version) { exit 0 } else { "qlpack.yml version not incremented. Previously updated to version $old_qlpack_version, current version $new_qlpack_version"; exit 7 }
267+
}
219268
test-create-dvl:
220269
runs-on: windows-latest
221270
needs: build

.github/workflows/publish.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
name: Build and Publish Windows CodeQL queries
3+
on:
4+
workflow_dispatch:
5+
input:
6+
version:
7+
description: 'CodeQL version to use'
8+
required: true
9+
type: string
10+
jobs:
11+
publish:
12+
runs-on: windows-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
steps:
17+
- name: Enable long git paths
18+
shell: cmd
19+
run: git config --global core.longpaths true
20+
21+
- name: Clone self (windows-driver-developer-supplemental-tools)
22+
uses: actions/checkout@v4
23+
with:
24+
path: .
25+
fetch-depth: 0
26+
27+
- name: CodeQL Download
28+
run:
29+
Invoke-WebRequest -Uri "https://github.com/github/codeql-cli-binaries/releases/download/v${{ github.event.inputs.version }}/codeql-win64.zip" -OutFile codeql-win64.zip;
30+
Expand-Archive -Path codeql-win64.zip -DestinationPath .\codeql-zip -Force;
31+
Move-Item -Path .\codeql-zip\codeql -Destination .\codeql-cli\
32+
33+
- name: Install CodeQL pack dependencies
34+
shell: cmd
35+
run: |
36+
pushd .\src
37+
..\codeql-cli\codeql.cmd pack install
38+
popd
39+
- name: Publish New CodeQL Pack
40+
shell: pwsh
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run:
44+
.\codeql-cli\codeql.cmd pack publish ./src;

0 commit comments

Comments
 (0)