Skip to content

Commit ce52749

Browse files
authored
.sync/workflows/leaf/codeql: Remove build dirs (#242)
Intermediate build files are sometimes left in build directories during CodeQL execution. This is particularly more prevalent in module directories that contain Rust files. These files have very long names, for example: ``` D:\a\mu_tiano_platforms\Build\QemuQ35Pkg \DEBUG_VS2022\X64\MsCorePkg\HelloWorldRustDxe\HelloWorldRustDxe \DEBUG\x86_64-unknown-uefi\debug\incremental \rust_boot_services_allocator_dxe-2f5m6unckl0t8 \s-gorl2pbwn9-18oh534-e4zntah436u40i7hceav0825j ``` CodeQL actions have well known and unresolved issues with long paths when they're scanning directories for files. The directories where these files may be left are not needed after build and it takes about 3 seconds to remove them so that is done in this change. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
1 parent bdffdb2 commit ce52749

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

.sync/workflows/leaf/codeql-platform.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,29 @@ jobs:
399399
STUART_CODEQL_PATH: ${{ steps.cache_key_gen.outputs.codeql_cli_ext_dep_dir }}
400400
run: stuart_build -c ${{ matrix.build_file }} -t DEBUG -a ${{ matrix.archs }} TOOL_CHAIN_TAG=${{ matrix.tool_chain_tag }} --codeql
401401

402+
- name: Build Cleanup
403+
id: build_cleanup
404+
shell: python
405+
run: |
406+
import os
407+
import shutil
408+
from pathlib import Path
409+
410+
dirs_to_delete = ['ia32', 'x64', 'arm', 'aarch64']
411+
412+
def delete_dirs(path: Path):
413+
if path.exists() and path.is_dir():
414+
if path.name.lower() in dirs_to_delete:
415+
print(f'Removed {str(path)}')
416+
shutil.rmtree(path)
417+
return
418+
419+
for child_dir in path.iterdir():
420+
delete_dirs(child_dir)
421+
422+
build_path = Path(os.environ['GITHUB_WORKSPACE'], 'Build')
423+
delete_dirs(build_path)
424+
402425
- name: Upload Build Logs As An Artifact
403426
uses: actions/upload-artifact@v3
404427
if: success() || failure()

.sync/workflows/leaf/codeql.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,29 @@ jobs:
342342
STUART_CODEQL_PATH: ${{ steps.cache_key_gen.outputs.codeql_cli_ext_dep_dir }}
343343
run: stuart_ci_build -c .pytool/CISettings.py -t DEBUG -p ${{ matrix.package }} -a ${{ matrix.archs }} TOOL_CHAIN_TAG=${{ matrix.tool_chain_tag }} --codeql
344344

345+
- name: Build Cleanup
346+
id: build_cleanup
347+
shell: python
348+
run: |
349+
import os
350+
import shutil
351+
from pathlib import Path
352+
353+
dirs_to_delete = ['ia32', 'x64', 'arm', 'aarch64']
354+
355+
def delete_dirs(path: Path):
356+
if path.exists() and path.is_dir():
357+
if path.name.lower() in dirs_to_delete:
358+
print(f'Removed {str(path)}')
359+
shutil.rmtree(path)
360+
return
361+
362+
for child_dir in path.iterdir():
363+
delete_dirs(child_dir)
364+
365+
build_path = Path(os.environ['GITHUB_WORKSPACE'], 'Build')
366+
delete_dirs(build_path)
367+
345368
- name: Upload Build Logs As An Artifact
346369
uses: actions/upload-artifact@v3
347370
if: success() || failure()

0 commit comments

Comments
 (0)