From d5e73848c49f7764fd7b8bf826748e767b955fd3 Mon Sep 17 00:00:00 2001 From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Sun, 3 Nov 2024 01:40:18 -0400 Subject: [PATCH] Strip trailing whitespace generated by ruamel-yaml --- .github/workflows/debug-artifacts-failure.yml | 2 +- .github/workflows/debug-artifacts-legacy.yml | 2 +- .github/workflows/debug-artifacts.yml | 2 +- pr-checks/sync.py | 10 +++++++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/debug-artifacts-failure.yml b/.github/workflows/debug-artifacts-failure.yml index bcc38d28a..e6cddb0a8 100644 --- a/.github/workflows/debug-artifacts-failure.yml +++ b/.github/workflows/debug-artifacts-failure.yml @@ -50,7 +50,7 @@ jobs: run: ./build.sh - uses: ./../action/analyze id: analysis - env: + env: # Forces a failure in this step. CODEQL_ACTION_EXTRA_OPTIONS: '{ "database": { "finalize": ["--invalid-option"] } }' with: diff --git a/.github/workflows/debug-artifacts-legacy.yml b/.github/workflows/debug-artifacts-legacy.yml index 2f024964b..3ea3074bf 100644 --- a/.github/workflows/debug-artifacts-legacy.yml +++ b/.github/workflows/debug-artifacts-legacy.yml @@ -56,7 +56,7 @@ jobs: debug-artifact-name: my-debug-artifacts debug-database-name: my-db # We manually exclude Swift from the languages list here, as it is not supported on Ubuntu - languages: cpp,csharp,go,java,javascript,python,ruby + languages: cpp,csharp,go,java,javascript,python,ruby - name: Build code shell: bash run: ./build.sh diff --git a/.github/workflows/debug-artifacts.yml b/.github/workflows/debug-artifacts.yml index cd38ea506..cfdf8e40d 100644 --- a/.github/workflows/debug-artifacts.yml +++ b/.github/workflows/debug-artifacts.yml @@ -55,7 +55,7 @@ jobs: debug-artifact-name: my-debug-artifacts debug-database-name: my-db # We manually exclude Swift from the languages list here, as it is not supported on Ubuntu - languages: cpp,csharp,go,java,javascript,python,ruby + languages: cpp,csharp,go,java,javascript,python,ruby - name: Build code shell: bash run: ./build.sh diff --git a/pr-checks/sync.py b/pr-checks/sync.py index c7b6abfdf..37b120b43 100755 --- a/pr-checks/sync.py +++ b/pr-checks/sync.py @@ -4,6 +4,7 @@ from ruamel.yaml.scalarstring import FoldedScalarString, SingleQuotedScalarString import pathlib import textwrap +import os # The default set of CodeQL Bundle versions to use for the PR checks. defaultTestVersions = [ @@ -153,7 +154,8 @@ def writeHeader(checkStream): checkJob['env']['CODEQL_ACTION_TEST_MODE'] = True checkName = file.stem - with open(this_dir.parent / ".github" / "workflows" / f"__{checkName}.yml", 'w') as output_stream: + raw_file = this_dir.parent / ".github" / "workflows" / f"__{checkName}.yml.raw" + with open(raw_file, 'w') as output_stream: writeHeader(output_stream) yaml.dump({ 'name': f"PR Check - {checkSpecification['name']}", @@ -175,3 +177,9 @@ def writeHeader(checkStream): checkName: checkJob } }, output_stream) + + with open(raw_file, 'r') as input_stream: + with open(this_dir.parent / ".github" / "workflows" / f"__{checkName}.yml", 'w') as output_stream: + content = input_stream.read() + output_stream.write("\n".join(list(map(lambda x:x.rstrip(), content.splitlines()))+[''])) + os.remove(raw_file)