Skip to content

Commit e1451a8

Browse files
authored
Merge pull request #196 from aakashmandavilli96/sri1.8
Refactor the Github Actions Into Separate steps during the PR Build process
2 parents 17be254 + 251e328 commit e1451a8

File tree

6 files changed

+438
-75
lines changed

6 files changed

+438
-75
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,45 @@
1-
# Workflow name
21
name: Build
32

4-
# This workflow is triggered on pushes and pull requests to the main branch.
53
on:
64
push:
7-
#branches:
8-
#- main
95
pull_request:
10-
#branches:
11-
#- main
126

13-
# Concurrency settings to cancel in-progress runs for the same PR or branch
14-
# This prevents wasting resources on outdated commits.
157
concurrency:
168
group: ${{ github.workflow }}-${{ github.ref }}
179
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
1810

1911
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://openvsxorg.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-
50-
# The main job for building the application
5112
build:
5213
name: Build sagemaker-code-editor
5314
runs-on: ubuntu-latest
54-
# Ensure unit tests pass before building
55-
needs: run-unit-tests
5615
timeout-minutes: 180
5716
env:
58-
# Environment variable to optimize the build process
5917
DISABLE_V8_COMPILE_CACHE: 1
6018

6119
steps:
62-
# Step 1: Check out the repository code, including its submodules.
6320
- name: Checkout repo with submodules
6421
uses: actions/checkout@v4
6522
with:
6623
submodules: recursive
6724

68-
# Step 2: Install system-level dependencies required for the build.
6925
- name: Install system dependencies
7026
run: |
7127
sudo apt-get update
7228
sudo apt-get install -y make gcc g++ libx11-dev xorg-dev libxkbfile-dev libsecret-1-dev libkrb5-dev python3 jq perl gettext automake autoconf quilt
7329
74-
# Step 3: Set up the Node.js environment. Version 20 is specified.
7530
- name: Set up Node.js
7631
uses: actions/setup-node@v4
7732
with:
7833
node-version: 20
79-
# Use npm for caching, not yarn
8034
cache: 'npm'
8135
cache-dependency-path: '**/package-lock.json'
8236

83-
# Step 4: Apply patches from the 'patches' directory if it exists.
8437
- name: Apply patches (if any)
8538
run: |
8639
if [ -d patches ] && [ "$(ls -A patches)" ]; then
87-
set -e
88-
quilt push -a
40+
quilt push -a || true
8941
fi
9042
91-
# Step 5: Generate a version string for this specific build.
92-
# It's based on the commit SHA to create a unique identifier.
9343
- name: Set Development Version
9444
id: version
9545
run: |
@@ -98,32 +48,24 @@ jobs:
9848
echo "VERSION=$VERSION" >> $GITHUB_ENV
9949
echo "Generated version for this build: $VERSION"
10050
101-
# Step 6: The main build process for vscode, now using npm.
10251
- name: Build vscode
10352
run: |
10453
cd vscode
10554
export DISABLE_V8_COMPILE_CACHE=1
10655
export UV_THREADPOOL_SIZE=4
10756
108-
# Install dependencies using npm
10957
npm install
11058
111-
# The logic for temporarily removing and re-adding ripgrep remains
11259
VSCODE_RIPGREP_VERSION=$(jq -r '.dependencies."@vscode/ripgrep"' package.json)
11360
mv package.json package.json.orig
11461
jq 'del(.dependencies."@vscode/ripgrep")' package.json.orig > package.json
11562
116-
# Re-run install to remove ripgrep
11763
npm install
118-
119-
# Add ripgrep back using npm
12064
npm install --ignore-scripts "@vscode/ripgrep@${VSCODE_RIPGREP_VERSION}"
12165
12266
ARCH_ALIAS=linux-x64
123-
# Run the gulp build task using npx
12467
npx gulp vscode-reh-web-${ARCH_ALIAS}-min
12568
126-
# Step 7: Find the exact path of the original build output directory.
12769
- name: Find build output
12870
id: find_output
12971
run: |
@@ -135,7 +77,6 @@ jobs:
13577
echo "Build output found at: $BUILD_PATH"
13678
echo "build_path=$BUILD_PATH" >> $GITHUB_OUTPUT
13779
138-
# Step 8: Rename the build output directory to sagemaker-code-editor
13980
- name: Rename build output directory
14081
id: rename_output
14182
run: |
@@ -145,7 +86,6 @@ jobs:
14586
echo "Renamed build output directory to: $PARENT_DIR/sagemaker-code-editor"
14687
echo "build_path=$PARENT_DIR/sagemaker-code-editor" >> $GITHUB_OUTPUT
14788
148-
# Step 9: Create a compressed tarball of the renamed build output.
14989
- name: Create tarball archive
15090
run: |
15191
TARBALL="sagemaker-code-editor-${{ env.VERSION }}.tar.gz"
@@ -155,22 +95,8 @@ jobs:
15595
echo "Creating '$TARBALL' from '$BUILD_DIR_NAME' in '$PARENT_DIR'"
15696
tar czf $TARBALL -C "$PARENT_DIR" "$BUILD_DIR_NAME"
15797
158-
# Step 10: Upload the tarball as a build artifact.
15998
- name: Upload build artifact
16099
uses: actions/upload-artifact@v4
161100
with:
162101
name: npm-package
163102
path: sagemaker-code-editor-${{ env.VERSION }}.tar.gz
164-
# Run end-to-end tests after the build is complete
165-
run-e2e-tests:
166-
name: Run e2e tests
167-
runs-on: ubuntu-latest
168-
needs: build # Ensure e2e tests run after build
169-
steps:
170-
# Checkout repository code
171-
- name: Checkout code
172-
uses: actions/checkout@v4
173-
174-
# Output placeholder message for e2e tests
175-
- name: Test of e2e test
176-
run: echo "Test of e2e test"

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
10+
11+
jobs:
12+
run-unit-tests:
13+
name: Run unit tests
14+
runs-on: ubuntu-latest
15+
steps:
16+
# Checkout repository code
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
22+
# Verify CSP line exists in target TypeScript file
23+
- name: Check CSP configuration in webClientServer.ts
24+
run: |
25+
TARGET_FILE="patched-vscode/src/vs/server/node/webClientServer.ts"
26+
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://openvsxorg.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;'"
27+
28+
if [ ! -f "$TARGET_FILE" ]; then
29+
echo "❌ FAIL: Target file $TARGET_FILE does not exist."
30+
exit 1
31+
fi
32+
33+
if grep -F "$REQUIRED_TEXT" "$TARGET_FILE" > /dev/null; then
34+
echo "✅ PASS: Required CSP text exists."
35+
else
36+
echo "❌ FAIL: Required CSP text NOT found in $TARGET_FILE"
37+
exit 1
38+
fi

.github/workflows/e2e.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: E2E Tests
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build"]
6+
types: [completed]
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
e2e-tests:
15+
name: E2E tests
16+
runs-on: ubuntu-latest
17+
if: github.event.workflow_run.conclusion == 'success' || github.event_name == 'pull_request'
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
cache: npm
24+
- run: npm ci
25+
- name: Download build artifact
26+
if: github.event_name != 'pull_request'
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: build-package
30+
github-token: ${{ secrets.GITHUB_TOKEN }}
31+
run-id: ${{ github.event.workflow_run.id }}
32+
- name: Run E2E tests
33+
run: |
34+
# Add your actual E2E test commands here
35+
echo "Running E2E tests..."
36+
# Example: npm run test:e2e
37+
- uses: actions/upload-artifact@v4
38+
if: failure()
39+
with:
40+
name: e2e-test-results
41+
path: test-results/

0 commit comments

Comments
 (0)