From 0f47667431d32003ebad09ae8ff5bbe44b8da1e3 Mon Sep 17 00:00:00 2001 From: Mishal Shah Date: Thu, 24 Oct 2024 14:12:37 -0700 Subject: [PATCH 1/9] [CI] GitHub Actions support --- .github/workflows/pull_request.yml | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/pull_request.yml diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 000000000..c804de718 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,40 @@ +name: Pull request + +on: + pull_request: + types: [opened, reopened, synchronize] + +jobs: + soundness: + name: Soundness + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main + with: + # https://github.com/swiftlang/github-workflows/issues/48 + license_header_check_enabled: false + license_header_check_project_name: "VS Code Swift" + api_breakage_check_enabled: false + docs_check_enabled: false + format_check_enabled: false + # https://github.com/swiftlang/vscode-swift/issues/1162 + shell_check_enabled: false + # https://github.com/swiftlang/vscode-swift/issues/1161 + unacceptable_language_check_enabled: false + + tests: + name: Test + uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main + with: + linux_env_vars: | + NODE_VERSION=v18.19.0 + NODE_PATH=/usr/local/nvm/versions/node/v18.19.0/bin + NVM_DIR=/usr/local/nvm + CI=1 + FAST_TEST_RUN=1 + linux_pre_build_command: | + apt-get update && apt-get install -y rsync curl gpg libasound2 libgbm1 libgtk-3-0 libnss3 xvfb build-essential + mkdir -p $NVM_DIR + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash + /bin/bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION" + echo "$NODE_PATH" >> $GITHUB_PATH + linux_build_command: ./docker/test.sh + enable_windows_checks: false From 7d10088a1769cb8be3858ddc9e792b82c9071a3c Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Mon, 28 Oct 2024 08:30:38 -0400 Subject: [PATCH 2/9] Fix improperly reported test exit code in github actions --- docker/test.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docker/test.sh b/docker/test.sh index c017ba53d..b79cbedde 100755 --- a/docker/test.sh +++ b/docker/test.sh @@ -20,5 +20,10 @@ npm run format npm run package npm run test-soundness -- --force-run -(xvfb-run -a npm run coverage; echo $? > exitcode) | grep -Ev "Failed to connect to the bus|GPU stall due to ReadPixels" && rm -rf "${current_directory}/coverage" && (cp -R ./coverage "${current_directory}" || true) -exit "$(&1 | grep -Ev "Failed to connect to the bus|GPU stall due to ReadPixels" +exit_code=${PIPESTATUS[0]} + +rm -rf "${current_directory}/coverage" +cp -R ./coverage $current_directory || true + +exit "${exit_code}" From 3f246010a3247d76df0e3d77b0a9c0e892f7ccc2 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Mon, 28 Oct 2024 08:30:51 -0400 Subject: [PATCH 3/9] Enable shellcheck and unacceptable language jobs --- .github/workflows/pull_request.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index c804de718..a220865ac 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -15,10 +15,8 @@ jobs: api_breakage_check_enabled: false docs_check_enabled: false format_check_enabled: false - # https://github.com/swiftlang/vscode-swift/issues/1162 - shell_check_enabled: false - # https://github.com/swiftlang/vscode-swift/issues/1161 - unacceptable_language_check_enabled: false + shell_check_enabled: true + unacceptable_language_check_enabled: true tests: name: Test From 7e13f64b03ec93ef8ac4284f5069aff943c4b72b Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Mon, 28 Oct 2024 08:43:34 -0400 Subject: [PATCH 4/9] Fixup last shellcheck issue after rebase --- docker/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/test.sh b/docker/test.sh index b79cbedde..4dde23210 100755 --- a/docker/test.sh +++ b/docker/test.sh @@ -24,6 +24,6 @@ xvfb-run -a npm run coverage 2>&1 | grep -Ev "Failed to connect to the bus|GPU s exit_code=${PIPESTATUS[0]} rm -rf "${current_directory}/coverage" -cp -R ./coverage $current_directory || true +cp -R ./coverage "${current_directory}" || true exit "${exit_code}" From 09321bba516c2ff10c913819dddeac1e8f3f38de Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Mon, 28 Oct 2024 15:54:17 -0400 Subject: [PATCH 5/9] Set disableASLR false in CI to fix lldb-dap tests --- src/TestExplorer/TestRunner.ts | 3 +++ src/debugger/buildConfig.ts | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/TestExplorer/TestRunner.ts b/src/TestExplorer/TestRunner.ts index 60171e775..51cde990d 100644 --- a/src/TestExplorer/TestRunner.ts +++ b/src/TestExplorer/TestRunner.ts @@ -925,6 +925,9 @@ export class TestRunner { } }, reason => { + this.workspaceContext.outputChannel.logDiagnostic( + `Failed to debug test: ${reason}` + ); subscriptions.forEach(sub => sub.dispose()); reject(reason); } diff --git a/src/debugger/buildConfig.ts b/src/debugger/buildConfig.ts index 3d68c2d9c..4837141a6 100644 --- a/src/debugger/buildConfig.ts +++ b/src/debugger/buildConfig.ts @@ -649,6 +649,13 @@ function getBaseConfig(ctx: FolderContext, expandEnvVariables: boolean) { args: [], preLaunchTask: `swift: Build All${nameSuffix}`, terminal: "console", + // DisableASLR when running in Docker CI https://stackoverflow.com/a/78471987 + ...(process.env["CI"] + ? { + disableASLR: false, + initCommands: ["settings set target.disable-aslr false"], + } + : {}), }; } From 53a8f4f90919f70a1dc5d1a46e2bddf7f988caf9 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Mon, 28 Oct 2024 16:06:31 -0400 Subject: [PATCH 6/9] Enable licence header check --- .github/workflows/pull_request.yml | 3 +-- docker/Dockerfile | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index a220865ac..f7068e2f9 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -9,8 +9,7 @@ jobs: name: Soundness uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main with: - # https://github.com/swiftlang/github-workflows/issues/48 - license_header_check_enabled: false + license_header_check_enabled: true license_header_check_project_name: "VS Code Swift" api_breakage_check_enabled: false docs_check_enabled: false diff --git a/docker/Dockerfile b/docker/Dockerfile index eddec6e42..b14fd44e6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,3 +1,16 @@ +#===----------------------------------------------------------------------===// +# +# This source file is part of the VS Code Swift open source project +# +# Copyright (c) 2024 the VS Code Swift project authors +# Licensed under Apache License v2.0 +# +# See LICENSE.txt for license information +# See CONTRIBUTORS.txt for the list of VS Code Swift project authors +# +# SPDX-License-Identifier: Apache-2.0 +# +#===----------------------------------------------------------------------===// ARG swift_version=5.10 ARG ubuntu_version=jammy ARG base_image=swift:$swift_version-$ubuntu_version From a773fc6bc81f37324dab22489ec9dfec90733da2 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Fri, 1 Nov 2024 10:43:27 -0400 Subject: [PATCH 7/9] Temporarily disable licence check in actions --- .github/workflows/pull_request.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index f7068e2f9..0ebd46bb1 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -9,7 +9,8 @@ jobs: name: Soundness uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main with: - license_header_check_enabled: true + # Pending https://github.com/swiftlang/vscode-swift/pull/1176 + license_header_check_enabled: false license_header_check_project_name: "VS Code Swift" api_breakage_check_enabled: false docs_check_enabled: false From b98891e4de48a51f4680186c75b11774a14731b1 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Fri, 1 Nov 2024 11:03:47 -0400 Subject: [PATCH 8/9] Fix shellcheck issues in soundness.sh --- assets/test/sleep.sh | 14 ++++++++++++++ docker/test-ci.sh | 13 +++++++++++++ docker/test.sh | 14 ++++++++++++++ scripts/soundness.sh | 23 +++++++++++------------ 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/assets/test/sleep.sh b/assets/test/sleep.sh index 2eeb6d110..3bbe0bd72 100755 --- a/assets/test/sleep.sh +++ b/assets/test/sleep.sh @@ -1,3 +1,17 @@ #!/bin/bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the VS Code Swift open source project +## +## Copyright (c) 2021 the VS Code Swift project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## See CONTRIBUTORS.txt for the list of VS Code Swift project authors +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## + sleep "$1" exit "$2" \ No newline at end of file diff --git a/docker/test-ci.sh b/docker/test-ci.sh index 35c8382cf..710002a14 100755 --- a/docker/test-ci.sh +++ b/docker/test-ci.sh @@ -1,4 +1,17 @@ #!/bin/bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the VS Code Swift open source project +## +## Copyright (c) 2021 the VS Code Swift project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## See CONTRIBUTORS.txt for the list of VS Code Swift project authors +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## node << 'EOF' const { execSync } = require('child_process'); diff --git a/docker/test.sh b/docker/test.sh index 4dde23210..c522df292 100755 --- a/docker/test.sh +++ b/docker/test.sh @@ -1,4 +1,18 @@ #!/bin/bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the VS Code Swift open source project +## +## Copyright (c) 2021 the VS Code Swift project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## See CONTRIBUTORS.txt for the list of VS Code Swift project authors +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## + set -ex current_directory=$(pwd) diff --git a/scripts/soundness.sh b/scripts/soundness.sh index 4e8e3651b..897e9b31c 100755 --- a/scripts/soundness.sh +++ b/scripts/soundness.sh @@ -25,6 +25,10 @@ if [[ "$1" != "--force-run" ]]; then fi set -eu + +original_dir=$(pwd) +cd "$(dirname "$0")/.." + here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" function replace_acceptable_years() { @@ -81,8 +85,8 @@ EOF ;; esac - expected_lines=$(cat "$tmp" | wc -l) - expected_sha=$(cat "$tmp" | shasum) + expected_lines=$(wc -l < "$tmp") + expected_sha=$(shasum < "$tmp") ( cd "$here/.." @@ -98,16 +102,10 @@ EOF \( \! -path './coverage/*' -a \ \( "${matching_files[@]}" \) \ \) \) \) \) \) \) \) \) - - if [[ "$language" = bash ]]; then - # add everything with a shell shebang too - git grep --full-name -l '#!/bin/bash' - git grep --full-name -l '#!/bin/sh' - fi - } | while read line; do - if [[ "$(cat "$line" | replace_acceptable_years | head -n $expected_lines | shasum)" != "$expected_sha" ]]; then - printf "\033[0;31mmissing headers in file '$line'!\033[0m\n" - diff -u <(cat "$line" | replace_acceptable_years | head -n $expected_lines) "$tmp" + } | while read -r line; do + if [[ "$(replace_acceptable_years < "$line" | head -n "$expected_lines" | shasum)" != "$expected_sha" ]]; then + printf "\033[0;31mmissing headers in file '%s'!\033[0m\n" "$line" + diff -u <(replace_acceptable_years < "$line" | head -n "$expected_lines") "$tmp" exit 1 fi done @@ -116,6 +114,7 @@ EOF done rm "$tmp" +cd "$original_dir" # printf "=> Checking for broken links in documentation... " # find . -name node_modules -prune -o -name \*.md -print0 | xargs -0 -n1 npx markdown-link-check From 482591550175196e83058d552c63d4124899fd7a Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Fri, 1 Nov 2024 14:46:47 -0400 Subject: [PATCH 9/9] Disable nightly-main test job --- .github/workflows/pull_request.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 0ebd46bb1..4a55a027f 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -22,6 +22,7 @@ jobs: name: Test uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main with: + linux_exclude_swift_versions: '[{"swift_version": "nightly-main"}]' linux_env_vars: | NODE_VERSION=v18.19.0 NODE_PATH=/usr/local/nvm/versions/node/v18.19.0/bin