Skip to content

Commit eb11eb5

Browse files
deepfuriyaDeep Furiya
andauthored
test(cloudformation): Added CFN LSP E2E tests to PR runners (aws#8379)
## Description - Added existing E2E tests to PR runners for `MacOS`, `Ubuntu` and `Windows` - Configured LSP server to be pre downloaded before the tests starts using the manifest and added a fallback to download directly from Github releases - Printing extension logs in the test runners if there are test failures --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: Deep Furiya <[email protected]>
1 parent 9a9f8ba commit eb11eb5

File tree

2 files changed

+99
-4
lines changed

2 files changed

+99
-4
lines changed

.github/workflows/node.js.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,67 @@ jobs:
181181
with:
182182
run: npm run testWeb
183183

184+
cloudformation-integ:
185+
needs: lint-commits
186+
name: CloudFormation LSP E2E Tests
187+
runs-on: ${{ matrix.os }}
188+
strategy:
189+
fail-fast: false
190+
matrix:
191+
os: [ubuntu-latest, macos-latest, windows-latest]
192+
node-version: [18.x]
193+
vscode-version: [stable]
194+
env:
195+
VSCODE_TEST_VERSION: ${{ matrix.vscode-version }}
196+
NODE_OPTIONS: '--max-old-space-size=8192'
197+
steps:
198+
- uses: actions/checkout@v4
199+
- name: Use Node.js ${{ matrix.node-version }}
200+
uses: actions/setup-node@v4
201+
with:
202+
node-version: ${{ matrix.node-version }}
203+
- name: Setup CloudFormation LSP
204+
shell: bash
205+
run: bash packages/core/src/testE2E/cloudformation/setup-local-lsp.sh
206+
- run: npm ci
207+
- name: Run CloudFormation E2E Tests (Unix)
208+
if: runner.os != 'Windows'
209+
uses: coactions/setup-xvfb@v1
210+
with:
211+
run: npm run testE2ECfn -w packages/toolkit
212+
- name: Run CloudFormation E2E Tests (Windows)
213+
if: runner.os == 'Windows'
214+
run: npm run testE2ECfn -w packages/toolkit
215+
- name: Print Extension Logs
216+
if: failure()
217+
shell: bash
218+
run: |
219+
echo "=== AWS Toolkit Extension Logs ==="
220+
find packages/toolkit/.vscode-test/user-data/logs -name "*.log" -type f 2>/dev/null | while read logfile; do
221+
echo "--- $logfile ---"
222+
cat "$logfile" || echo "Could not read log file"
223+
done || echo "No extension logs found"
224+
225+
echo ""
226+
echo "=== CloudFormation LSP Server Logs ==="
227+
echo "LSP Path: $__CLOUDFORMATIONLSP_PATH"
228+
if [ -n "$__CLOUDFORMATIONLSP_PATH" ]; then
229+
LSP_LOG_DIR="$__CLOUDFORMATIONLSP_PATH/.aws-cfn-storage/logs"
230+
echo "Checking directory: $LSP_LOG_DIR"
231+
if [ -d "$LSP_LOG_DIR" ]; then
232+
find "$LSP_LOG_DIR" -name "*.log" -type f 2>/dev/null | while read logfile; do
233+
echo "--- $logfile ---"
234+
cat "$logfile" || echo "Could not read log file"
235+
done
236+
else
237+
echo "LSP logs directory does not exist: $LSP_LOG_DIR"
238+
echo "Contents of LSP path:"
239+
ls -la "$__CLOUDFORMATIONLSP_PATH" 2>/dev/null || echo "Cannot list LSP path"
240+
fi
241+
else
242+
echo "Environment variable __CLOUDFORMATIONLSP_PATH is not set"
243+
fi
244+
184245
windows:
185246
needs: lint-commits
186247
name: test Windows

packages/core/src/testE2E/cloudformation/setup-local-lsp.sh

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ARCH=$(uname -m)
2222
case "$OS" in
2323
darwin) PLATFORM="darwin" ;;
2424
linux) PLATFORM="linux" ;;
25+
mingw*|msys*|cygwin*) PLATFORM="win32" ;;
2526
*) echo "Unsupported OS: $OS"; exit 1 ;;
2627
esac
2728

@@ -35,13 +36,31 @@ NODE_VERSION="22"
3536

3637
# Fetch latest release
3738
echo "Fetching latest LSP server release..."
38-
RELEASE_URL="https://api.github.com/repos/aws-cloudformation/cloudformation-languageserver/releases/latest"
39-
DOWNLOAD_URL=$(curl -s "$RELEASE_URL" | grep "browser_download_url.*${PLATFORM}-${ARCH}-node${NODE_VERSION}.zip" | cut -d'"' -f4 | head -1)
39+
MANIFEST_URL="https://raw.githubusercontent.com/aws-cloudformation/cloudformation-languageserver/main/assets/release-manifest.json"
40+
41+
# Try manifest first
42+
if command -v jq &> /dev/null; then
43+
echo "Trying manifest: $MANIFEST_URL"
44+
DOWNLOAD_URL=$(curl -s "$MANIFEST_URL" | jq -r ".prod[] | select(.latest == true) | .targets[] | select(.platform == \"$PLATFORM\" and .arch == \"$ARCH\" and .nodejs == \"$NODE_VERSION\") | .contents[0].url")
45+
if [ -n "$DOWNLOAD_URL" ]; then
46+
echo "✓ Using manifest URL"
47+
fi
48+
else
49+
echo "jq not available, skipping manifest"
50+
fi
51+
52+
# Fallback to GitHub API if manifest fails
53+
if [ -z "$DOWNLOAD_URL" ]; then
54+
echo "Trying GitHub API fallback..."
55+
RELEASE_URL="https://api.github.com/repos/aws-cloudformation/cloudformation-languageserver/releases/latest"
56+
DOWNLOAD_URL=$(curl -s "$RELEASE_URL" | grep "browser_download_url.*${PLATFORM}-${ARCH}-node${NODE_VERSION}.zip" | cut -d'"' -f4 | head -1)
57+
if [ -n "$DOWNLOAD_URL" ]; then
58+
echo "✓ Using GitHub API URL"
59+
fi
60+
fi
4061

4162
if [ -z "$DOWNLOAD_URL" ]; then
4263
echo "Error: Could not find LSP server release for ${PLATFORM}-${ARCH}-node${NODE_VERSION}"
43-
echo "Available releases:"
44-
curl -s "$RELEASE_URL" | grep "browser_download_url" | cut -d'"' -f4
4564
exit 1
4665
fi
4766

@@ -78,5 +97,20 @@ done
7897
echo ""
7998
echo "✓ LSP server ready at: $LSP_SERVER_DIR"
8099
echo ""
100+
101+
# Export to GitHub Actions environment if running in CI
102+
if [ -n "$GITHUB_ENV" ]; then
103+
# Convert to Windows path format if on Windows
104+
if [[ "$PLATFORM" == "win32" ]]; then
105+
# Convert /d/path to D:/path format for Node.js on Windows
106+
WIN_PATH=$(echo "$LSP_SERVER_DIR" | sed 's|^/\([a-z]\)/|\U\1:/|')
107+
echo "__CLOUDFORMATIONLSP_PATH=$WIN_PATH" >> "$GITHUB_ENV"
108+
echo "Exported __CLOUDFORMATIONLSP_PATH=$WIN_PATH to GitHub Actions environment"
109+
else
110+
echo "__CLOUDFORMATIONLSP_PATH=$LSP_SERVER_DIR" >> "$GITHUB_ENV"
111+
echo "Exported __CLOUDFORMATIONLSP_PATH=$LSP_SERVER_DIR to GitHub Actions environment"
112+
fi
113+
fi
114+
81115
echo "Run tests with:"
82116
echo "__CLOUDFORMATIONLSP_PATH=\"$LSP_SERVER_DIR\" npm run testE2E -w packages/toolkit"

0 commit comments

Comments
 (0)