Skip to content

Commit 8dfb7d7

Browse files
Update QLT to use new codeql-bundle tool (#27)
* Update references to org and version * Bump version of `actions/upload-artifact` from v2 to v4 * Change refs of 0.2.1 to 0.4.0 * Bump download-artifact@v2 to @v4 and format. * Use poetry-plugin-export instead of export * Add error checks to build_codeql_bundle_dist --------- Co-authored-by: Nicolas Will <[email protected]>
1 parent 4d5cb8a commit 8dfb7d7

12 files changed

+58
-42
lines changed

.github/actions/install-qlt-local/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ runs:
6060
pip install -U pyinstaller
6161
6262
# run the packaging
63-
./scripts/build_codeql_bundle_dist.ps1 -Version 0.3.0 -WorkDirectory dist -DestinationDirectory ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/tools/
63+
./scripts/build_codeql_bundle_dist.ps1 -Version 0.4.0 -WorkDirectory dist -DestinationDirectory ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/tools/
6464
env:
6565
GH_TOKEN: ${{ github.token }}
6666

.github/workflows/internal-build-release-linux64.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
pip install -U pyinstaller
5151
5252
# run the packaging
53-
./scripts/build_codeql_bundle_dist.ps1 -Version 0.3.0 -WorkDirectory dist -DestinationDirectory ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/tools/
53+
./scripts/build_codeql_bundle_dist.ps1 -Version 0.4.0 -WorkDirectory dist -DestinationDirectory ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/linux-x64/tools/
5454
env:
5555
GH_TOKEN: ${{ github.token }}
5656

@@ -69,7 +69,7 @@ jobs:
6969
7070
7171
- name: Upload build artifacts
72-
uses: actions/upload-artifact@v3
72+
uses: actions/upload-artifact@v4
7373
with:
7474
name: qlt-dist
7575
path: qlt*.zip

.github/workflows/internal-build-release-macos64.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
pip install -U pyinstaller
4949
5050
# run the packaging
51-
./scripts/build_codeql_bundle_dist.ps1 -Version 0.3.0 -WorkDirectory dist -DestinationDirectory ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/macos-arm64/tools/
51+
./scripts/build_codeql_bundle_dist.ps1 -Version 0.4.0 -WorkDirectory dist -DestinationDirectory ./src/CodeQLToolkit.Core/bin/Release/net6.0/publish/macos-arm64/tools/
5252
env:
5353
GH_TOKEN: ${{ github.token }}
5454

@@ -65,7 +65,7 @@ jobs:
6565
popd
6666
6767
- name: Upload build artifacts
68-
uses: actions/upload-artifact@v3
68+
uses: actions/upload-artifact@v4
6969
with:
7070
name: qlt-dist
7171
path: qlt*.zip

.github/workflows/internal-build-release-win64.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
pip install -U pyinstaller
4646
4747
# run the packaging
48-
.\scripts\build_codeql_bundle_dist.ps1 -Version 0.3.0 -WorkDirectory dist -DestinationDirectory .\src\CodeQLToolkit.Core\bin\Release\net6.0\publish\windows-x64\tools\
48+
.\scripts\build_codeql_bundle_dist.ps1 -Version 0.4.0 -WorkDirectory dist -DestinationDirectory .\src\CodeQLToolkit.Core\bin\Release\net6.0\publish\windows-x64\tools\
4949
env:
5050
GH_TOKEN: ${{ github.token }}
5151

@@ -59,7 +59,7 @@ jobs:
5959
Pop-Location
6060
6161
- name: Upload build artifacts
62-
uses: actions/upload-artifact@v3
62+
uses: actions/upload-artifact@v4
6363
with:
6464
name: qlt-dist
6565
path: qlt*.zip

.github/workflows/internal-pr-build-linux.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
Compress-Archive -Path .\src\CodeQLToolkit.Core\bin\Release\net6.0\publish\linux-x64\* -DestinationPath qlt-linux-x86_64.zip
3434
3535
- name: Upload build artifacts
36-
uses: actions/upload-artifact@v3
36+
uses: actions/upload-artifact@v4
3737
with:
3838
name: qlt-dist
3939
path: qlt*.zip

.github/workflows/internal-pr-bundle-integration-test-cpp.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ jobs:
8585
ls -l ${{ steps.analysis.outputs.sarif-output }}
8686
8787
- name: Upload SARIF Results
88-
uses: actions/upload-artifact@v2
88+
uses: actions/upload-artifact@v4
8989
with:
9090
name: actual.sarif
9191
path: |
9292
${{ steps.analysis.outputs.sarif-output }}/*.sarif
9393
if-no-files-found: error
9494

9595
- name: Upload Bundles
96-
uses: actions/upload-artifact@v2
96+
uses: actions/upload-artifact@v4
9797
with:
9898
name: codeql-bundles
9999
path: |
@@ -107,4 +107,4 @@ jobs:
107107
shell: bash
108108
run: |
109109
# Compare the expected vs the actual
110-
qlt bundle run validate-integration-tests --expected example/integration-tests/cpp/expected.sarif --actual ${{ steps.analysis.outputs.sarif-output }}/cpp.sarif
110+
qlt bundle run validate-integration-tests --expected example/integration-tests/cpp/expected.sarif --actual ${{ steps.analysis.outputs.sarif-output }}/cpp.sarif

.github/workflows/run-bundle-integration-tests-cpp.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
ls -l ${{ env.QLT_CODEQL_HOME }}/../out/
6666
6767
- name: Upload Bundles
68-
uses: actions/upload-artifact@v2
68+
uses: actions/upload-artifact@v4
6969
with:
7070
name: codeql-bundles
7171
path: |
@@ -102,7 +102,7 @@ jobs:
102102
ls -l ${{ steps.analysis.outputs.sarif-output }}
103103
104104
- name: Upload SARIF Results
105-
uses: actions/upload-artifact@v2
105+
uses: actions/upload-artifact@v4
106106
with:
107107
name: actual.sarif
108108
path: |

.github/workflows/run-codeql-unit-tests-cpp.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
107107
108108
- name: Upload test results
109-
uses: actions/upload-artifact@v2
109+
uses: actions/upload-artifact@v4
110110
with:
111111
name: test-results-${{ runner.os }}-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library_ident }}
112112
path: |
@@ -132,7 +132,7 @@ jobs:
132132

133133

134134
- name: Collect test results
135-
uses: actions/download-artifact@v2
135+
uses: actions/download-artifact@v4
136136

137137
- name: Validate test results
138138
run: |

developer_guide.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Note that we keep recent copies of tools (for local debugging purposes) in the `
1515
**CodeQL Bundle**
1616

1717
```
18-
./scripts/build_codeql_bundle_dist.ps1 -Version 0.3.0 -WorkDirectory dist -DestinationDirectory ./src/CodeQLToolkit.Core/bin/Debug/net6.0/tools
18+
./scripts/build_codeql_bundle_dist.ps1 -Version 0.4.0 -WorkDirectory dist -DestinationDirectory ./src/CodeQLToolkit.Core/bin/Debug/net6.0/tools
1919
```
2020

2121

@@ -47,4 +47,4 @@ namespace CodeQLToolkit.Features.Test.Lifecycle.Targets.Actions
4747
}
4848
}
4949
}
50-
```
50+
```

scripts/build_codeql_bundle_dist.ps1

+37-21
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
param(
22
[Parameter(Mandatory = $true)]
3-
[string]
4-
$Version,
3+
[string] $Version,
4+
55
[Parameter(Mandatory = $true)]
6-
[string]
7-
$WorkDirectory,
6+
[string] $WorkDirectory,
87

98
[Parameter(Mandatory = $true)]
10-
[string]
11-
$DestinationDirectory
9+
[string] $DestinationDirectory
1210
)
1311

12+
# Fail on any built-in command failure
13+
$ErrorActionPreference = "Stop"
14+
1415
if (-not (Test-Path $WorkDirectory)) {
1516
New-Item -ItemType Directory -Path $WorkDirectory | Out-Null
1617
}
@@ -19,41 +20,56 @@ if (-not (Test-Path $DestinationDirectory)) {
1920
New-Item -ItemType Directory -Path $DestinationDirectory | Out-Null
2021
}
2122

22-
# download a copy of the release from GitHub
23-
gh release download "v$Version" --repo https://github.com/kraiouchkine/codeql-bundle -D $WorkDirectory -A zip
23+
# Download a copy of the release from GitHub
24+
gh release download "v$Version" --repo https://github.com/advanced-security/codeql-bundle -D $WorkDirectory -A zip
25+
if ($LASTEXITCODE -ne 0) {
26+
throw "Failed to download release from GitHub (gh)"
27+
}
2428

25-
# extract the zip file
29+
# Extract the zip file
2630
Expand-Archive -Path "$WorkDirectory\codeql-bundle-$Version.zip" -DestinationPath $WorkDirectory
2731

28-
# creates a directory named `codeql-bundle-<version>`
32+
# Create path to archive directory (named codeql-bundle-<version>)
2933
$ArchiveDirectory = Join-Path $WorkDirectory "codeql-bundle-$Version"
3034

3135
Push-Location $ArchiveDirectory
3236

33-
# at this point python should already be installed as well as poetry
34-
# export the requirements
35-
poetry export -f requirements.txt > requirements.txt
37+
# Export the requirements using poetry
38+
poetry self add poetry-plugin-export
39+
if ($LASTEXITCODE -ne 0) {
40+
throw "Failed to add poetry-plugin-export"
41+
}
42+
43+
poetry export -f requirements.txt --output requirements.txt
44+
if ($LASTEXITCODE -ne 0) {
45+
throw "Failed to export requirements using poetry"
46+
}
3647

37-
# install the requirements
48+
# Install the requirements using pip
3849
pip install -r requirements.txt
50+
if ($LASTEXITCODE -ne 0) {
51+
throw "Failed to install requirements using pip"
52+
}
3953

54+
# Move into the cli directory
4055
Push-Location "codeql_bundle"
4156

42-
# pyinstaller should also be installed
57+
# Build executable with pyinstaller
4358
pyinstaller -F -n codeql_bundle cli.py
59+
if ($LASTEXITCODE -ne 0) {
60+
throw "PyInstaller build failed"
61+
}
4462

45-
Pop-Location
46-
Pop-Location
63+
Pop-Location
64+
Pop-Location
4765

66+
# Determine built output binary path
4867
if ($IsWindows) {
4968
$OutputFile = Join-Path $ArchiveDirectory "codeql_bundle" "dist" "codeql_bundle.exe"
5069
}
5170
else {
5271
$OutputFile = Join-Path $ArchiveDirectory "codeql_bundle" "dist" "codeql_bundle"
5372
}
5473

55-
56-
# this will output the binary in the `dist` directory - we should copy that binary the toplevel directory.
74+
# Copy the binary to the destination directory
5775
Copy-Item -Path $OutputFile -Destination $DestinationDirectory
58-
59-

src/CodeQLToolkit.Features/Templates/Bundle/Actions/run-bundle-integration-tests.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
ls -l ${{ env.QLT_CODEQL_HOME }}/../out/
8787
8888
- name: Upload Bundles
89-
uses: actions/upload-artifact@v2
89+
uses: actions/upload-artifact@v4
9090
with:
9191
name: codeql-bundles
9292
path: |
@@ -130,7 +130,7 @@ jobs:
130130
ls -l ${{ steps.analysis.outputs.sarif-output }}
131131
132132
- name: Upload SARIF Results
133-
uses: actions/upload-artifact@v2
133+
uses: actions/upload-artifact@v4
134134
with:
135135
name: actual.sarif
136136
path: |

src/CodeQLToolkit.Features/Templates/Test/Actions/run-unit-tests.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
{% endif %}
138138
{% raw %}
139139
- name: Upload test results
140-
uses: actions/upload-artifact@v2
140+
uses: actions/upload-artifact@v4
141141
with:
142142
name: test-results-${{ runner.os }}-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library_ident }}
143143
path: |
@@ -170,7 +170,7 @@ jobs:
170170
{% endif %}
171171
{% raw %}
172172
- name: Collect test results
173-
uses: actions/download-artifact@v2
173+
uses: actions/download-artifact@v4
174174
175175
- name: Validate test results
176176
run: |

0 commit comments

Comments
 (0)