Skip to content

Commit 19ea110

Browse files
committed
AG-48297 add cleanup script to specs
Squashed commit of the following: commit e145698 Merge: 6d13a8e 79275c9 Author: slvvko <[email protected]> Date: Wed Nov 12 00:48:29 2025 -0500 Merge branch 'master' into fix/AG-48297 commit 6d13a8e Author: slvvko <[email protected]> Date: Tue Nov 11 22:19:08 2025 -0500 use comma commit 21c77bb Author: slvvko <[email protected]> Date: Tue Nov 11 22:01:47 2025 -0500 clean up commit b62a276 Author: slvvko <[email protected]> Date: Tue Nov 11 22:01:37 2025 -0500 fix paths commit 0ed4086 Author: slvvko <[email protected]> Date: Tue Nov 11 21:53:16 2025 -0500 Revert "fix artifacts location" This reverts commit 5027b6d. commit a0c46be Author: slvvko <[email protected]> Date: Tue Nov 11 21:52:49 2025 -0500 Revert "try to add artifact-download for lint stage" This reverts commit 86c8ee8. commit 86c8ee8 Author: slvvko <[email protected]> Date: Tue Nov 11 21:46:11 2025 -0500 try to add artifact-download for lint stage commit a2718a1 Author: slvvko <[email protected]> Date: Tue Nov 11 21:40:06 2025 -0500 fix comment commit 5027b6d Author: slvvko <[email protected]> Date: Tue Nov 11 21:38:14 2025 -0500 fix artifacts location commit 6114f4a Author: slvvko <[email protected]> Date: Tue Nov 11 21:32:12 2025 -0500 make artifacts shared commit c2bce55 Author: slvvko <[email protected]> Date: Tue Nov 11 21:25:02 2025 -0500 remove git dir anyway commit 587ce72 Author: slvvko <[email protected]> Date: Tue Nov 11 21:21:32 2025 -0500 do not share artifacts commit 44178e0 Author: slvvko <[email protected]> Date: Tue Nov 11 21:16:05 2025 -0500 make cleanup script executable commit 5bc46fd Author: slvvko <[email protected]> Date: Tue Nov 11 21:14:46 2025 -0500 do not remove git dir commit 3eca9ea Author: slvvko <[email protected]> Date: Tue Nov 11 20:28:35 2025 -0500 add ubo's sensors-analytics.js to compatibility tables commit 87b556a Author: slvvko <[email protected]> Date: Tue Nov 11 21:07:34 2025 -0500 preserve .git directory during workspace cleanup commit d68f9bc Author: slvvko <[email protected]> Date: Tue Nov 11 20:56:25 2025 -0500 add cleanup script to specs
1 parent 79275c9 commit 19ea110

File tree

4 files changed

+79
-39
lines changed

4 files changed

+79
-39
lines changed

bamboo-specs/build.yaml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,7 @@ Build:
5353
- script:
5454
interpreter: SHELL
5555
scripts:
56-
- |-
57-
set -x
58-
set -e
59-
60-
# Fix mixed logs
61-
exec 2>&1
62-
63-
ls -la
64-
65-
echo "Size before cleanup:" && du -h | tail -n 1
66-
rm -rf node_modules
67-
echo "Size after cleanup:" && du -h | tail -n 1
56+
- "./bamboo-specs/scripts/cleanup.sh scriptlets.tgz"
6857
artifacts:
6958
- name: scriptlets.tgz
7059
location: .

bamboo-specs/increment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ Increment:
4848
configuration:
4949
commitMessage: 'skipci: Automatic increment build number'
5050
selectedRepository: defaultRepository
51+
final-tasks:
52+
- script:
53+
interpreter: SHELL
54+
scripts:
55+
- "./bamboo-specs/scripts/cleanup.sh"
5156
requirements:
5257
- adg-docker: 'true'
5358

bamboo-specs/scripts/cleanup.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
# Cleanup script that preserves specified artifacts
4+
# Usage: ./cleanup.sh "artifact1,artifact2,artifact3"
5+
6+
# 'set' should be added to the beginning of each script to ensure that it runs with the correct options.
7+
# Please do not move it to some common file, like `setup-tests.sh`, because sourcing A script from B script
8+
# cannot change the options of B script.
9+
# -e: Exit immediately if any command exits with a non-zero status (i.e., if a command fails).
10+
# -x: Print each command to the terminal as it is executed, which is useful for debugging.
11+
set -ex
12+
13+
# Fix mixed logs
14+
exec 2>&1
15+
16+
echo "Size before cleanup:" && du -h | tail -n 1
17+
echo "Top 5 files:" && du -h | sort -hr | head -n 5
18+
19+
# Parse artifacts from command line argument
20+
ARTIFACTS_ARG="${1:-}"
21+
if [ -z "$ARTIFACTS_ARG" ]; then
22+
echo "No artifacts specified, cleaning entire workspace"
23+
ARTIFACTS=""
24+
else
25+
# Convert comma-separated string to space-separated
26+
ARTIFACTS=$(echo "$ARTIFACTS_ARG" | tr ',' ' ')
27+
echo "Preserving artifacts: $ARTIFACTS"
28+
fi
29+
30+
TMP="$(mktemp -d)"
31+
trap 'rm -rf "$TMP"' EXIT
32+
33+
# Stash artifacts to /tmp
34+
for f in $ARTIFACTS; do
35+
[ -e "$f" ] || continue
36+
echo "Stashing artifact: $f"
37+
mkdir -p "$TMP/$(dirname "$f")"
38+
mv "$f" "$TMP/$f"
39+
done
40+
41+
# Clean entire workspace (including dotfiles and .git)
42+
find . -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +
43+
44+
# Restore artifacts
45+
for f in $ARTIFACTS; do
46+
[ -e "$TMP/$f" ] || continue
47+
echo "Restoring artifact: $f"
48+
mkdir -p "$(dirname "$f")"
49+
mv "$TMP/$f" "$f"
50+
done
51+
52+
echo "Size after cleanup:" && du -h | tail -n 1
53+
echo "Top 5 files:" && du -h | sort -hr | head -n 5
54+
55+
echo "Cleanup completed successfully"

bamboo-specs/test.yaml

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ stages:
2222
- Test smoke
2323
# lint should be run after building of docs and lib
2424
- Lint
25-
- Cleanup:
26-
<<: *stage
27-
final: true
28-
jobs:
29-
- Cleanup
3025

3126
Build docs:
3227
key: BUILDDOCS
@@ -64,6 +59,11 @@ Build docs:
6459
# build docs to lint them later
6560
# check compatibility table updates and build it and build wiki docs
6661
pnpm wiki
62+
final-tasks:
63+
- script: &cleanup-script
64+
interpreter: SHELL
65+
scripts:
66+
- "./bamboo-specs/scripts/cleanup.sh"
6767
requirements: &requirements
6868
- adg-docker: 'true'
6969
- extension: 'true'
@@ -89,6 +89,11 @@ Build lib:
8989
location: dist
9090
pattern: redirects.json
9191
required: true
92+
final-tasks:
93+
- script:
94+
interpreter: SHELL
95+
scripts:
96+
- "./bamboo-specs/scripts/cleanup.sh dist/scriptlets.corelibs.json,dist/redirects.json"
9297
requirements: *requirements
9398

9499
Test qunit:
@@ -103,6 +108,8 @@ Test qunit:
103108
scripts:
104109
- |-
105110
pnpm test:qunit
111+
final-tasks:
112+
- script: *cleanup-script
106113
requirements: *requirements
107114

108115
Test vitest:
@@ -116,6 +123,8 @@ Test vitest:
116123
scripts:
117124
- |-
118125
pnpm test:vitest
126+
final-tasks:
127+
- script: *cleanup-script
119128
requirements: *requirements
120129

121130
Test smoke:
@@ -130,6 +139,8 @@ Test smoke:
130139
scripts:
131140
- |-
132141
pnpm test:smoke
142+
final-tasks:
143+
- script: *cleanup-script
133144
requirements: *requirements
134145

135146
Lint:
@@ -143,28 +154,8 @@ Lint:
143154
scripts:
144155
- |-
145156
pnpm lint
146-
requirements: *requirements
147-
148-
Cleanup:
149-
key: CLEAN
150-
docker: *docker
151-
tasks:
152-
- checkout
153-
- script:
154-
interpreter: SHELL
155-
scripts:
156-
- |-
157-
set -x
158-
set -e
159-
160-
# Fix mixed logs
161-
exec 2>&1
162-
163-
ls -la
164-
165-
echo "Size before cleanup:" && du -h | tail -n 1
166-
rm -rf node_modules
167-
echo "Size after cleanup:" && du -h | tail -n 1
157+
final-tasks:
158+
- script: *cleanup-script
168159
requirements: *requirements
169160

170161
branches:

0 commit comments

Comments
 (0)