Skip to content

Commit 3fb0190

Browse files
committed
Script for running macOS tests in swift CI
1 parent 98519ba commit 3fb0190

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

docker/test-macos.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the VS Code Swift open source project
5+
##
6+
## Copyright (c) 2024 the VS Code Swift project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of VS Code Swift project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
set -e
17+
18+
NODE_VERSION="$(cat .nvmrc)"
19+
NODE_NAME="node-v$NODE_VERSION-darwin-arm64"
20+
NODE_ARCHIVE="$NODE_NAME.tar.gz"
21+
ARTIFACTS="$PWD/.vscode-test"
22+
VSCODE_SETTINGS="$ARTIFACTS/user-data/User/settings.json"
23+
LSP_SETTINGS="$HOME/.sourcekit-lsp/config.json"
24+
25+
export TMPDIR="$ARTIFACTS/tmp"
26+
mkdir -p $TMPDIR
27+
28+
function cleanup {
29+
rm SHASUMS256.txt
30+
rm $NODE_ARCHIVE
31+
rm -rf "$ARTIFACTS"
32+
rm -rf "$LSP_SETTINGS"
33+
}
34+
trap "cleanup" EXIT
35+
36+
curl -O "https://nodejs.org/dist/v$NODE_VERSION/$NODE_ARCHIVE"
37+
curl -O "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt"
38+
39+
NODE_CHECKSUM="$(grep $NODE_ARCHIVE SHASUMS256.txt)"
40+
41+
grep "$NODE_ARCHIVE" SHASUMS256.txt | sha256sum -c -
42+
43+
tar -xzf $NODE_ARCHIVE -C $ARTIFACTS
44+
45+
export NPM_CONFIG_CACHE="$ARTIFACTS/$NODE_NAME/cache"
46+
export NPM_CONFIG_PREFIX="$ARTIFACTS/$NODE_NAME"
47+
export NPM_CONFIG_USERCONFIG="$ARTIFACTS/$NODE_NAME/usernpmrc"
48+
export NPM_CONFIG_GLOBALCONFIG="$ARTIFACTS/$NODE_NAME/globalnpmrc"
49+
50+
PATH="$ARTIFACTS/$NODE_NAME/bin:$PATH"
51+
52+
mkdir -p $(dirname "$VSCODE_SETTINGS")
53+
cat <<EOT > $VSCODE_SETTINGS
54+
{
55+
"swift.buildArguments": [
56+
"--disable-sandbox",
57+
"-Xswiftc",
58+
"-disable-sandbox"
59+
]
60+
}
61+
EOT
62+
63+
mkdir -p $(dirname "$LSP_SETTINGS")
64+
cat <<EOT > $LSP_SETTINGS
65+
{
66+
"swiftPM": {
67+
"disableSandbox": true,
68+
"swiftCompilerFlags": [
69+
"-disable-sandbox"
70+
]
71+
}
72+
}
73+
EOT
74+
75+
npm ci -ignore-script node-pty
76+
npm run lint
77+
npm run format
78+
npm run package
79+
FAST_TEST_RUN=1 npm run coverage -- --coverage-output "$PWD/coverage"

0 commit comments

Comments
 (0)