Skip to content

Commit 0b069cb

Browse files
chore: update pr workflow, dependencies for SealLight unit test integration
1 parent effdbf1 commit 0b069cb

File tree

1 file changed

+39
-9
lines changed

1 file changed

+39
-9
lines changed

.github/workflows/pr.yaml

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
if: ${{ steps.check-image.outputs.is_skipped != 'true' }}
9898
run: |
9999
echo "${SL_TOKEN}" > sltoken.txt
100-
echo "Token last 7 chars: ...${SL_TOKEN: -7}"
100+
echo "Token last 7 chars : ...${SL_TOKEN: -7}"
101101
env:
102102
SL_TOKEN: '${{secrets.SL_TOKEN}}'
103103

@@ -111,6 +111,8 @@ jobs:
111111

112112
- name: Scan all packages with SealLight
113113
if: ${{ steps.check-image.outputs.is_skipped != 'true' }}
114+
env:
115+
NODE_DEBUG: sl
114116
run: |
115117
# Define scan targets: workspace_path:module_id
116118
scan_targets=(
@@ -125,19 +127,47 @@ jobs:
125127
)
126128
127129
# Common scan parameters
128-
common_params="--tokenfile ./sltoken.txt --buildsessionidFile ./buildsessionid --scm none --projectroot ${{ github.workspace }}"
130+
common_params="--tokenfile ./sltoken.txt --buildsessionidFile ./buildSessionId --scm none --projectroot ${{ github.workspace }}"
131+
132+
# Verify build session file exists
133+
if [[ ! -f ./buildSessionId ]]; then
134+
echo "Error: buildsessionid file not found. SealLight session may not be properly initialized."
135+
exit 1
136+
fi
129137
130138
# Scan each target
131139
for target in "${scan_targets[@]}"; do
132140
workspace_path="${target%:*}"
133141
module_id="${target#*:}"
142+
full_path="${{ github.workspace }}/$workspace_path"
143+
134144
echo "Scanning $module_id at $workspace_path"
135-
npx slnodejs scan $common_params --workspacepath "${{ github.workspace }}/$workspace_path" --uniqueModuleId "$module_id"
145+
echo "Full path: $full_path"
146+
147+
# Verify the path exists
148+
if [[ ! -d "$full_path" ]]; then
149+
echo "Warning: Directory $full_path does not exist, skipping scan for $module_id"
150+
continue
151+
fi
152+
153+
# Run the scan with error handling
154+
if ! npx slnodejs scan $common_params --workspacepath "$full_path" --uniqueModuleId "$module_id"; then
155+
echo "Error: SealLight scan failed for $module_id at $full_path"
156+
echo "Continuing with other scans..."
157+
continue
158+
fi
159+
160+
echo "Successfully scanned $module_id"
136161
done
137162
138163
- name: End SealLight build session
139-
if: ${{ steps.check-image.outputs.is_skipped != 'true' }}
140-
run: npx slnodejs buildend --tokenfile ./sltoken.txt --buildsessionidFile ./buildsessionid --ok
164+
if: ${{ steps.check-image.outputs.is_skipped != 'true' && always() }}
165+
run: |
166+
if [[ -f ./buildSessionId ]]; then
167+
npx slnodejs buildend --tokenfile ./sltoken.txt --buildsessionidFile ./buildSessionId --ok
168+
else
169+
echo "Warning: buildSessionId file not found, cannot end SealLight session"
170+
fi
141171
142172
test:
143173
name: Test with Node.js ${{ matrix.node-version }}
@@ -215,28 +245,28 @@ jobs:
215245

216246
- name: Start SealLight test stage
217247
if: ${{ steps.check-image.outputs.is_skipped != 'true' }}
218-
run: npx slnodejs start --tokenfile ./sltoken.txt --buildsessionidFile ./buildsessionid --teststage "Unit Tests"
248+
run: npx slnodejs start --tokenfile ./sltoken.txt --buildsessionidFile ./buildSessionId --teststage "Unit Tests"
219249

220250
- name: Run tests
221251
if: ${{ steps.check-image.outputs.is_skipped != 'true' }}
222252
run: yarn run test --continue --affected
223253

224254
- name: Upload JUnit XML report to SealLight
225255
if: ${{ steps.check-image.outputs.is_skipped != 'true' }}
226-
run: npx slnodejs uploadReports --tokenfile ./sltoken.txt --buildsessionidFile ./buildsessionid --reportFile "./jest-junit-results/junit.xml"
256+
run: npx slnodejs uploadReports --tokenfile ./sltoken.txt --buildsessionidFile ./buildSessionId --reportFile "./jest-junit-results/junit.xml"
227257

228258
- name: Upload coverage reports to SealLight
229259
if: ${{ steps.check-image.outputs.is_skipped != 'true' }}
230260
run: |
231261
# Upload coverage reports from all packages
232262
find . -name "coverage-final.json" -path "*/coverage/*" | while read coverage_file; do
233263
echo "Uploading coverage report: $coverage_file"
234-
npx slnodejs nycReport --tokenfile ./sltoken.txt --buildsessionidFile ./buildsessionid --report "$coverage_file"
264+
npx slnodejs nycReport --tokenfile ./sltoken.txt --buildsessionidFile ./buildSessionId --report "$coverage_file"
235265
done
236266
237267
- name: End SealLight test stage
238268
if: ${{ steps.check-image.outputs.is_skipped != 'true' }}
239-
run: npx slnodejs end --tokenfile ./sltoken.txt --buildsessionidFile ./buildsessionid
269+
run: npx slnodejs end --tokenfile ./sltoken.txt --buildsessionidFile ./buildSessionId
240270
- name: Install dynamic plugin dependencies
241271
if: ${{ steps.check-image.outputs.is_skipped != 'true' }}
242272
run: cd ./dynamic-plugins && yarn install && cd ..

0 commit comments

Comments
 (0)