-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
verify generated files exist in ui/dist (#847)
* verify files script * ui change * minor fix * updated scriot * updated scriot * updated scriot * updated scriot * updated scriot * test * make file * removed html change * addressing comments
- Loading branch information
1 parent
9296b6e
commit a6e9323
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# Define the path to the dist directory and index.html file | ||
DIST_DIR="ui/dist/ui" | ||
INDEX_FILE="${DIST_DIR}/index.html" | ||
|
||
# Check if index.html exists | ||
if [ ! -f "$INDEX_FILE" ]; then | ||
echo "Error: index.html not found in $DIST_DIR" | ||
exit 1 | ||
fi | ||
|
||
# Define the patterns to search for | ||
declare -a patterns=("styles[^\"']*\.css" "runtime[^\"']*\.js" "polyfills[^\"']*\.js" "main[^\"']*\.js") | ||
|
||
# Flag to check if any file is missing | ||
MISSING_FILES=false | ||
|
||
# Check each pattern | ||
for pattern in "${patterns[@]}"; do | ||
# Use grep to find the file reference in index.html | ||
file=$(grep -oP "(?<=href=\"|src=\")$pattern(?=\")" "$INDEX_FILE" | head -n 1) | ||
|
||
if [ -z "$file" ]; then | ||
echo "Error: No file matching pattern $pattern found in $INDEX_FILE" | ||
MISSING_FILES=true | ||
else | ||
# Check if the file exists in the dist directory | ||
FILE_PATH="${DIST_DIR}/${file}" | ||
if [ ! -f "$FILE_PATH" ]; then | ||
echo "Error: File not found - $FILE_PATH" | ||
MISSING_FILES=true | ||
else | ||
echo "File exists: $FILE_PATH" | ||
fi | ||
fi | ||
done | ||
|
||
# Exit with an error if any file was missing | ||
if [ "$MISSING_FILES" = true ]; then | ||
echo "Verification failed. File mismatch issue. Please ensure that you have run ng build." | ||
exit 1 | ||
else | ||
echo "All expected files are present. Verification passed." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: ui-generated-files-check | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
paths: | ||
- 'ui/**' | ||
|
||
jobs: | ||
verify: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Verify files | ||
run: | | ||
chmod +x .github/scripts/verify-files.sh | ||
.github/scripts/verify-files.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters