-
Notifications
You must be signed in to change notification settings - Fork 73
Script for running macOS tests in swift CI #1272
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
Draft
award999
wants to merge
27
commits into
swiftlang:main
Choose a base branch
from
award999:macos-script
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
ebcfa7c
Fix some failures I kept hitting locally
award999 41831a9
Fix script permission
award999 19c032a
Sandbox config
award999 0f6dae7
Proxy port
award999 a39e4f3
Use different command to check sha
award999 1756a36
Fix shellcheck errors
award999 4037923
use x64 arch
award999 00a3d88
Fix downloading vscode
award999 81ac8d0
Allow reading plist
award999 75a7619
Shorter socket name
award999 1a780c5
Allow accessing entire .vscode folder
award999 68d63ca
Allow writing xcode caches
award999 66c715b
Update socket path in sandbox
award999 f983193
Pass arguments to disable sandboxing when enabled
award999 8008eda
Update sandbox setting
award999 567ddf7
Disable hardware acceleration
award999 3303fba
Some cleanup
award999 5d15cd3
Fix some local failures
award999 4d224a0
Add comment
award999 11db198
Fix soundness error
award999 5c44712
Fix Swift rpath lookup
award999 b5a7fd3
Longer timeouts since this build machine seems slower
award999 e465395
Cleanup sanbox config
award999 0458315
Fix failing xcode watcher unit test
award999 00d97a1
Update package.json
award999 462fadf
Fix review comments
award999 e61dea7
Fix failing test after rebase
award999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ default.profraw | |
assets/documentation-webview | ||
assets/test/**/Package.resolved | ||
assets/swift-docc-render | ||
ud |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,6 @@ node_modules/ | |
/coverage/ | ||
/dist/ | ||
/snippets/ | ||
|
||
# macOS CI | ||
/ud/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
(version 1) | ||
; Deny everything by default | ||
(deny default) | ||
|
||
; Get fonts | ||
(import "system.sb") | ||
|
||
; Helpers | ||
(define (param-regex param-name param-relative-regex) | ||
(regex (string-append "^" (regex-quote (param param-name)) param-relative-regex))) | ||
(define (param-subpath param-name param-relative-subpath) | ||
(subpath (string-append (param param-name) param-relative-subpath))) | ||
(define workspace | ||
(param "workspace")) | ||
|
||
; Read | ||
(allow file-read-metadata | ||
(subpath "/")) | ||
(allow file-read* | ||
(subpath workspace) | ||
(path "/") | ||
(path "/private/etc/ssl/openssl.cnf") | ||
(path "/dev/dtracehelper") | ||
(path "/dev/fd") | ||
(path "/dev/null") | ||
(path "/dev/ptmx") | ||
(regex #"^/dev/tty.*") | ||
(path "/etc/shells") | ||
(path "/private/etc/shells") | ||
(path "/private/etc/ssl/cert.pem") | ||
(path "/System/Library/OpenSSL/openssl.cnf") | ||
(regex #"^/Users/[^/]+/.vscode.*") | ||
(regex #"^/Users/[^/]+/.gitconfig$") | ||
(regex #"^/Users/[^/]+/.gitignore$") | ||
(regex #"^/Users/[^/]+/.lldbinit$") | ||
(regex #"^/Users/[^/]+/.sourcekit-lsp.*") | ||
(regex #"^/Users/[^/]+/.swiftpm.*") | ||
(regex #"^/Users/[^/]+/Library/org.swift.swiftpm.*") | ||
(regex #"^/Users/[^/]+/Library/Developer/CommandLineTools") | ||
(regex #"^/Users/[^/]+/Library/Developer/Toolchains") | ||
(regex #"^/Users/[^/]+/Library/Developer/Xcode/DerivedData.*") | ||
(regex #"^/Users/[^/]+/Library/Caches/org.swift.swiftpm.*") | ||
(regex #"^/Users/[^/]+/Library/Caches/com.apple.dt.Xcode.*") | ||
(regex #"^/Users/[^/]+/Library/Caches/com.apple.python.*") | ||
(regex #"^/Users/[^/]+/Library/Application Support/Code.*") | ||
(regex #"^/Users/[^/]+/Library/Application Support/Microsoft.*") | ||
(regex #"^/Users/[^/]+/Library/Preferences/.*.plist") | ||
(regex #"^/Users/[^/]+/Library/Python") | ||
(regex #"^/Users/[^/]+/Library/SymbolCache/dsyms/uuids") | ||
(regex #"^/Users/[^/]+/Library/Saved Application State/com.microsoft.VSCode.savedState.*") | ||
(regex #"^/private/var/folders/[^/]+/[^/]+/.+") | ||
(regex #"^/Library/Preferences/.*.plist") | ||
(regex #"^/[^/]+/Library/Python") | ||
(subpath "/Library/Developer/CommandLineTools") | ||
(subpath "/Library/Developer/Toolchains") | ||
(subpath "/Library/Frameworks/UIAutomation.framework") | ||
(subpath "/Library/Python") | ||
(subpath "/System/Library/Perl") | ||
(subpath "/Applications/Xcode.app") | ||
(subpath "/Applications/Xcode-beta.app") | ||
(subpath "/bin") | ||
(subpath "/usr/bin") | ||
(subpath "/usr/local/bin") | ||
(subpath "/usr/libexec/path_helper") | ||
(subpath "/usr/local/share/git-core") | ||
(subpath "/usr/local/share/hwtrace") | ||
|
||
(regex #".*/LLDB.framework/.*") | ||
(regex #".*/Python3.framework/.*") | ||
(regex #".*/branch-main/.*") | ||
(regex #".*/usr/lib/swift/.*") | ||
) | ||
|
||
(allow mach-lookup) | ||
(allow mach-priv-task-port) | ||
(allow mach-register) | ||
(allow sysctl-read) | ||
(allow system-debug) | ||
(allow ipc-posix-shm-read-data (literal "apple.shm.notification_center")) | ||
|
||
; Write | ||
(allow file-write* | ||
(subpath workspace) | ||
(path "/dev/null") | ||
(path "/dev/ptmx") | ||
(regex #"^/dev/tty.*") | ||
(regex #"^/Users/[^/]+/.sourcekit-lsp.*") | ||
(regex #"^/Users/[^/]+/Library/org.swift.swiftpm.*") | ||
(regex #"^/Users/[^/]+/Library/Caches/org.swift.swiftpm.*") | ||
(regex #"^/Users/[^/]+/Library/Caches/com.apple.dt.Xcode.*") | ||
(regex #"^/Users/[^/]+/Library/Caches/com.apple.python.*") | ||
(regex #"^/Users/[^/]+/Library/Developer/Xcode/DerivedData.*") | ||
(regex #"^/Users/[^/]+/Library/Application Support/Code.*") | ||
(regex #"^/Users/[^/]+/Library/Application Support/Microsoft.*") | ||
(regex #"^/private/var/folders/[^/]+/[^/]+/.+") | ||
(regex #"^/Users/[^/]+/.vscode.*") | ||
|
||
(regex #".*/branch-main.*") | ||
) | ||
|
||
; Execute | ||
(allow process-exec*) | ||
(allow process-fork) | ||
|
||
; Network | ||
(allow system-socket) | ||
(allow network-outbound | ||
(path "/private/var/run/mDNSResponder") | ||
(remote tcp4 "*:443") | ||
(remote tcp4 "*:3128") | ||
; (local tcp4 "*:*") ; CodeLLDB | ||
) | ||
|
||
; CodeLLDB | ||
; (allow network-bind | ||
; (local tcp4 "*:*") | ||
; ) | ||
; (allow network-inbound | ||
; (local tcp4 "*:*") | ||
; ) | ||
|
||
; VSCode sockets | ||
(allow network* | ||
(param-regex "workspace" "/ud/1\.[0-9]+-main\.sock") | ||
) | ||
|
||
; Open VSCode window | ||
(allow file-ioctl) | ||
(allow iokit-open-user-client) | ||
|
||
; VSCode terminal | ||
(allow pseudo-tty) | ||
|
||
; SourceKit-LSP | ||
(allow job-creation) | ||
|
||
; JSON language server | ||
(allow signal) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/bin/bash | ||
##===----------------------------------------------------------------------===## | ||
## | ||
## 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 | ||
## | ||
##===----------------------------------------------------------------------===## | ||
|
||
set -e | ||
|
||
platform=$([ "$(arch)" == "arm64" ] && echo "arm64" || echo "x64") | ||
|
||
NODE_VERSION="$(cat .nvmrc)" | ||
NODE_NAME="node-v$NODE_VERSION-darwin-$platform" | ||
NODE_ARCHIVE="$NODE_NAME.tar.gz" | ||
ARTIFACTS="$PWD/.vscode-test" | ||
USER_DATA="$PWD/ud" | ||
VSCODE_SETTINGS="$USER_DATA/User/settings.json" | ||
LSP_SETTINGS="$HOME/.sourcekit-lsp/config.json" | ||
|
||
export TMPDIR="$ARTIFACTS/tmp" | ||
export TMP="$TMPDIR" | ||
mkdir -p "$TMPDIR" | ||
|
||
function cleanup { | ||
rm SHASUMS256.txt | ||
rm "$NODE_ARCHIVE" | ||
rm -rf "$ARTIFACTS" | ||
rm -rf "$LSP_SETTINGS" | ||
rm -rf "$USER_DATA" | ||
} | ||
trap "cleanup" EXIT | ||
trap "cleanup" INT | ||
|
||
curl -O "https://nodejs.org/dist/v$NODE_VERSION/$NODE_ARCHIVE" | ||
curl -O "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt" | ||
|
||
grep "$NODE_ARCHIVE" SHASUMS256.txt | shasum -a 256 -c - | ||
|
||
tar -xzf "$NODE_ARCHIVE" -C "$ARTIFACTS" | ||
|
||
export NPM_CONFIG_CACHE="$ARTIFACTS/$NODE_NAME/cache" | ||
export NPM_CONFIG_PREFIX="$ARTIFACTS/$NODE_NAME" | ||
export NPM_CONFIG_USERCONFIG="$ARTIFACTS/$NODE_NAME/usernpmrc" | ||
export NPM_CONFIG_GLOBALCONFIG="$ARTIFACTS/$NODE_NAME/globalnpmrc" | ||
|
||
PATH="$ARTIFACTS/$NODE_NAME/bin:$PATH" | ||
|
||
mkdir -p "$(dirname "$VSCODE_SETTINGS")" | ||
cat <<EOT > "$VSCODE_SETTINGS" | ||
{ | ||
"swift.path": "/Users/ec2-user/jenkins/workspace/pr-vscode-swift-macos/branch-main/latest_toolchain/usr/bin" | ||
"swift.disableSandbox": true, | ||
"swift.debugger.disable": true, | ||
"swift.debugger.path": "/Users/ec2-user/jenkins/workspace/pr-vscode-swift-macos/branch-main/latest_toolchain/usr/bin/lldb-dap", | ||
"lldb.library": "/Applications/Xcode-beta.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB", | ||
"lldb.launch.expressions": "native", | ||
"lldb.suppressUpdateNotifications": true | ||
} | ||
EOT | ||
|
||
mkdir -p "$(dirname "$LSP_SETTINGS")" | ||
cat <<EOT > "$LSP_SETTINGS" | ||
{ | ||
"swiftPM": { | ||
"disableSandbox": true, | ||
"swiftCompilerFlags": [ | ||
"-disable-sandbox" | ||
] | ||
} | ||
} | ||
EOT | ||
|
||
npm ci -ignore-script node-pty | ||
npm run lint | ||
npm run format | ||
npm run package | ||
|
||
# Ignore hooks when running locally for development | ||
export GIT_CONFIG_COUNT=1 | ||
export GIT_CONFIG_KEY_0="core.hookspath" | ||
export GIT_CONFIG_VALUE_0="$PWD/hooks" | ||
|
||
# Need to set proxy to download VS Code | ||
export npm_config_https_proxy="$HTTPS_PROXY" | ||
|
||
VSCODE_DATA_DIR="$USER_DATA" CI=1 FAST_TEST_RUN=1 npm run coverage -- --coverage-output "$PWD/coverage" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.