Skip to content

[CI] GitHub Actions support #1159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Pull request

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
# 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
format_check_enabled: false
shell_check_enabled: true
unacceptable_language_check_enabled: true

tests:
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
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
14 changes: 14 additions & 0 deletions assets/test/sleep.sh
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 13 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 13 additions & 0 deletions docker/test-ci.sh
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
23 changes: 21 additions & 2 deletions docker/test.sh
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -20,5 +34,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 "$(<exitcode)"
xvfb-run -a npm run coverage 2>&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}"
23 changes: 11 additions & 12 deletions scripts/soundness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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/.."
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/TestExplorer/TestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,9 @@ export class TestRunner {
}
},
reason => {
this.workspaceContext.outputChannel.logDiagnostic(
`Failed to debug test: ${reason}`
);
subscriptions.forEach(sub => sub.dispose());
reject(reason);
}
Expand Down
7 changes: 7 additions & 0 deletions src/debugger/buildConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
}
: {}),
};
}

Expand Down