Skip to content

Commit 2caabe3

Browse files
authored
Added ignored errors patching for the build artifacts (#54)
1 parent d7cd961 commit 2caabe3

File tree

6 files changed

+92
-5
lines changed

6 files changed

+92
-5
lines changed
File renamed without changes.

configuration/code-editor-sagemaker-server.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
},
1212
"target": "code-editor-sagemaker-server",
1313
"ignoredErrors": {
14-
"path": "ignored-errors"
14+
"path": null
1515
}
1616
}

configuration/code-editor-server.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
},
1212
"target": "code-editor-server",
1313
"ignoredErrors": {
14-
"path": "ignored-errors"
14+
"path": null
1515
}
1616
}

configuration/code-editor-web-embedded-with-terminal.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
},
1212
"target": "code-editor-web-embedded-with-terminal",
1313
"ignoredErrors": {
14-
"path": "ignored-errors"
14+
"path": null
1515
}
1616
}

configuration/code-editor-web-embedded.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
},
1212
"target": "code-editor-web-embedded",
1313
"ignoredErrors": {
14-
"path": "ignored-errors"
14+
"path": null
1515
}
1616
}

scripts/build-artifacts.sh

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,91 @@ get_mem_available_kb() {
66
grep MemAvailable /proc/meminfo | awk '{print $2}'
77
}
88

9+
copy_ignored_errors() {
10+
local build_target_base="$1"
11+
local target="$2"
12+
13+
local present_working_dir="$(pwd)"
14+
local config_file="$present_working_dir/configuration/$target.json"
15+
local build_dir="$(pwd)/$build_target_base/out/vs/editor/common/errors"
16+
local output_file="$build_dir/ignored-errors.json"
17+
18+
echo "Processing ignored errors for target: $target"
19+
mkdir -p "$build_dir"
20+
21+
# Step 1: Collect all .json files from common-ignored-errors directory
22+
local common_files=()
23+
if [[ -d "${present_working_dir}/common-ignored-errors" ]]; then
24+
echo "Step 1: Looking for common ignored errors files"
25+
while IFS= read -r -d '' file; do
26+
common_files+=("$file")
27+
echo " Found: $(basename "$file")"
28+
done < <(find "${present_working_dir}/common-ignored-errors" -name "*.json" -print0 2>/dev/null || true)
29+
fi
30+
31+
# Step 2: Collect target-specific .json files if path is not null
32+
local target_files=()
33+
if [ -f "$config_file" ]; then
34+
local ignored_errors_path=$(jq -r '.ignoredErrors.path' "$config_file")
35+
if [[ "$ignored_errors_path" != "null" && -n "$ignored_errors_path" && -d "${present_working_dir}/$ignored_errors_path" ]]; then
36+
echo "Step 2: Looking for target-specific ignored errors files in: $ignored_errors_path"
37+
while IFS= read -r -d '' file; do
38+
target_files+=("$file")
39+
echo " Found: $(basename "$file")"
40+
done < <(find "${present_working_dir}/$ignored_errors_path" -name "*.json" -print0 2>/dev/null || true)
41+
else
42+
echo "Step 2: Skipping target-specific files (path is null or doesn't exist)"
43+
fi
44+
else
45+
echo "Config file not found: $config_file"
46+
fi
47+
48+
# Step 3: Merge all JSON files
49+
echo "Step 3: Merging all ignored errors files"
50+
local temp_file=$(mktemp)
51+
echo '{"stringPatterns": [], "regexPatterns": []}' > "$temp_file"
52+
53+
# Function to clean JSON (remove comments)
54+
clean_and_merge() {
55+
local file="$1"
56+
local temp_clean=$(mktemp)
57+
# Remove single-line comments and multi-line comments
58+
sed 's|//.*$||g' "$file" | sed '/\/\*/,/\*\//d' > "$temp_clean"
59+
jq -s '.[0] as $base | .[1] as $new | $base + {stringPatterns: ($base.stringPatterns + ($new.stringPatterns // [])), regexPatterns: ($base.regexPatterns + ($new.regexPatterns // []))}' "$temp_file" "$temp_clean" > "${temp_file}.tmp" && mv "${temp_file}.tmp" "$temp_file"
60+
rm "$temp_clean"
61+
}
62+
63+
# Merge common files
64+
if [[ ${#common_files[@]} -gt 0 ]]; then
65+
for file in "${common_files[@]}"; do
66+
if [[ -f "$file" ]]; then
67+
echo " Merging: $(basename "$file")"
68+
clean_and_merge "$file"
69+
fi
70+
done
71+
fi
72+
73+
# Merge target-specific files
74+
if [[ ${#target_files[@]} -gt 0 ]]; then
75+
for file in "${target_files[@]}"; do
76+
if [[ -f "$file" ]]; then
77+
echo " Merging: $(basename "$file")"
78+
clean_and_merge "$file"
79+
fi
80+
done
81+
fi
82+
83+
# Copy merged result to output location
84+
cp "$temp_file" "$output_file"
85+
rm "$temp_file"
86+
87+
# Report final counts
88+
local string_count=$(jq '.stringPatterns | length' "$output_file")
89+
local regex_count=$(jq '.regexPatterns | length' "$output_file")
90+
echo "Created ignored-errors.json with $string_count string patterns and $regex_count regex patterns"
91+
echo "Output written to: $output_file"
92+
}
93+
994
build() {
1095
local code_oss_build_target_base="$1"
1196

@@ -29,6 +114,7 @@ build() {
29114
env \
30115
NODE_OPTIONS="--max-old-space-size=${max_space_size_mb}" \
31116
npm run gulp "$build_target"
117+
cd ..
32118
}
33119

34120
main() {
@@ -37,6 +123,7 @@ main() {
37123
local build_target_base=$("$(dirname "$0")/determine-build-target.sh" "$target")
38124
echo "Building for target: $build_target_base"
39125
build "$build_target_base"
126+
copy_ignored_errors "$build_target_base" "$target"
40127
}
41128

42-
main "$@"
129+
main "$@"

0 commit comments

Comments
 (0)