Skip to content

Commit 5a44e1c

Browse files
authored
Merge pull request #164 from harvenstar/1.8
Add unit test(check the file) and e2e test
2 parents 866a924 + 05ab0c4 commit 5a44e1c

File tree

2 files changed

+70
-16
lines changed

2 files changed

+70
-16
lines changed

.github/workflows/build.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,42 @@ concurrency:
1717
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
1818

1919
jobs:
20+
# Run unit tests before building the application
21+
22+
run-unit-tests:
23+
name: Run unit tests
24+
runs-on: ubuntu-latest
25+
steps:
26+
# Checkout repository code
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
# Verify CSP line exists in target TypeScript file
31+
- name: Check CSP configuration in webClientServer.ts
32+
run: |
33+
TARGET_FILE="patched-vscode/src/vs/server/node/webClientServer.ts"
34+
REQUIRED_TEXT="'connect-src \'self\' ws: wss: https://main.vscode-cdn.net http://localhost:* https://localhost:* https://login.microsoftonline.com/ https://update.code.visualstudio.com https://*.vscode-unpkg.net/ https://default.exp-tas.com/vscode/ab https://vscode-sync.trafficmanager.net https://vscode-sync-insiders.trafficmanager.net https://*.gallerycdn.vsassets.io https://marketplace.visualstudio.com https://*.blob.core.windows.net https://az764295.vo.msecnd.net https://code.visualstudio.com https://*.gallery.vsassets.io https://*.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com https://*.servicebus.windows.net/ https://vscode.blob.core.windows.net https://vscode.search.windows.net https://vsmarketplacebadges.dev https://vscode.download.prss.microsoft.com https://download.visualstudio.microsoft.com https://*.vscode-unpkg.net https://open-vsx.org;'"
35+
36+
if [ ! -f "$TARGET_FILE" ]; then
37+
echo "❌ FAIL: Target file $TARGET_FILE does not exist."
38+
exit 1
39+
fi
40+
41+
if grep -F "$REQUIRED_TEXT" "$TARGET_FILE" > /dev/null; then
42+
echo "✅ PASS: Required CSP text exists."
43+
else
44+
echo "❌ FAIL: Required CSP text NOT found in $TARGET_FILE"
45+
exit 1
46+
fi
47+
48+
49+
2050
# The main job for building the application
2151
build:
2252
name: Build sagemaker-code-editor
2353
runs-on: ubuntu-latest
54+
# Ensure unit tests pass before building
55+
needs: run-unit-tests
2456
timeout-minutes: 180
2557
env:
2658
# Environment variable to optimize the build process
@@ -128,3 +160,16 @@ jobs:
128160
with:
129161
name: npm-package
130162
path: sagemaker-code-editor-${{ env.VERSION }}.tar.gz
163+
# Run end-to-end tests after the build is complete
164+
run-e2e-tests:
165+
name: Run e2e tests
166+
runs-on: ubuntu-latest
167+
needs: build # Ensure e2e tests run after build
168+
steps:
169+
# Checkout repository code
170+
- name: Checkout code
171+
uses: actions/checkout@v4
172+
173+
# Output placeholder message for e2e tests
174+
- name: Hudson's test of e2e test
175+
run: echo "Hudson's test of e2e test"

.github/workflows/release.yml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
type: string
1212
# This input allows you to specify which branch to create the release from.
1313
source_branch:
14-
description: 'The branch to find the latest successful build artifact on.'
14+
description: 'The branch to find the artifact on and to tag for the release.'
1515
required: true
1616
type: string
1717
# We default to 'main' to make the most common case easy.
@@ -28,13 +28,19 @@ jobs:
2828
contents: write
2929

3030
steps:
31-
# Step 1: Check out the repository code.
32-
# This is necessary for the release action to create a Git tag in your repository.
31+
# Step 1: Check out the repository code FROM THE SPECIFIED SOURCE BRANCH.
3332
- name: Checkout code
3433
uses: actions/checkout@v4
3534
with:
3635
ref: ${{ github.event.inputs.source_branch }}
3736

37+
# Step 2: Explicitly get the commit SHA of the checked-out branch HEAD.
38+
# This ensures we are using the correct commit for tagging.
39+
- name: Get commit SHA
40+
id: get_sha
41+
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
42+
43+
# Step 3: Delete existing tag if you want to re-run the release.
3844
- name: Delete existing tag (if any)
3945
uses: actions/github-script@v7
4046
with:
@@ -50,31 +56,29 @@ jobs:
5056
} catch (e) {
5157
console.log(`Tag ${tag} does not exist or already deleted.`);
5258
}
53-
# Step 2: Download the build artifact from your 'Build' workflow.
54-
# This finds the latest successful run on the specified branch and downloads the artifact.
59+
60+
# Step 4: Download the build artifact from your 'Build' workflow.
5561
- name: Download artifact from build workflow
5662
uses: dawidd6/action-download-artifact@v6
5763
with:
5864
# IMPORTANT: This must match the 'name:' field in your build.yaml file.
5965
workflow: build.yml
60-
# Use the branch from the manual input instead of hardcoding 'main'.
66+
# Use the branch from the manual input.
6167
branch: ${{ github.event.inputs.source_branch }}
6268

6369
# Tell the action to look for artifacts created by a 'pull_request' event.
6470
event: pull_request
6571
allow_forks: true
6672

67-
6873
# We use a wildcard (*) because the artifact name from the build workflow
69-
# contains a dynamic commit SHA (e.g., vscode-reh-web-linux-x64-0.0.0-dev-...).
74+
# contains a dynamic commit SHA.
7075
name: npm-package
7176
# The path where the downloaded artifact will be saved.
7277
path: ./release-assets
7378
# Ensure we only get the artifact from a successful run.
7479
workflow_conclusion: success
7580

76-
# Step 3: Prepare the release assets by renaming the artifact.
77-
# This takes the downloaded file and gives it a clean, versioned name.
81+
# Step 5: Prepare the release assets by renaming the artifact.
7882
- name: Prepare release assets
7983
id: prepare_assets
8084
run: |
@@ -91,7 +95,7 @@ jobs:
9195
VERSION_NUM="${VERSION_TAG#v}"
9296
9397
# Create the new, clean filename for the release.
94-
# This is the standardized name that your conda-forge recipe will expect.
98+
9599
NEW_FILENAME="code-editor${VERSION_NUM}.tar.gz"
96100
97101
# Rename the file.
@@ -100,8 +104,10 @@ jobs:
100104
echo "Renamed artifact to $NEW_FILENAME"
101105
# Set the new filename as an output for the next step.
102106
echo "filename=./release-assets/$NEW_FILENAME" >> $GITHUB_OUTPUT
103-
# Step 4: Create the GitHub Release and upload the prepared asset.
104-
# This action creates the tag, the release, and uploads your .tar.gz file.
107+
108+
109+
# Step 6: Create the GitHub Release using the CORRECT commit SHA.
110+
105111
- name: Create GitHub Release
106112
uses: softprops/action-gh-release@v2
107113
with:
@@ -111,8 +117,11 @@ jobs:
111117
tag_name: ${{ github.event.inputs.version }}
112118
# Path to the file(s) to upload as release assets.
113119
files: ${{ steps.prepare_assets.outputs.filename }}
114-
# Set to 'false' to publish immediately, or 'true' to create a draft.
120+
# Set to 'false' to publish immediately.
115121
draft: false
116-
# Automatically generate release notes from commits since the last release.
122+
# Set to false as we are not using auto-generated notes.
117123
generate_release_notes: false
118-
124+
# CRITICAL: Force the tag to be created on the commit we explicitly got in Step 2.
125+
# This overrides any incorrect metadata from the downloaded artifact.
126+
target_commitish: ${{ steps.get_sha.outputs.sha }}
127+

0 commit comments

Comments
 (0)