-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently the benchmark page [loads](https://github.com/awslabs/mountpoint-s3/blob/gh-pages/dev/bench/index.html#L107) the chart.js library from CDN, this PR changes that and adds CSP to ensure that no other resources are loaded from external locations. ### Does this change impact existing behavior? No. ### Does this change need a changelog entry? Does it require a version change? No. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I agree to the terms of the [Developer Certificate of Origin (DCO)](https://developercertificate.org/). --------- Signed-off-by: Vlad Volodkin <[email protected]> Co-authored-by: Vlad Volodkin <[email protected]>
- Loading branch information
Showing
8 changed files
with
507 additions
and
16 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,80 @@ | ||
#!/bin/bash | ||
|
||
# Source directory in the main branch | ||
SOURCE_DIR="benchmark_website" | ||
# Temporary directory to store files in after switching to gh-pages branch | ||
TMP_DIR="/tmp/benchmark_website" | ||
|
||
# Check if at least one destination directory is provided as argument | ||
if [ "$#" -lt 1 ]; then | ||
echo "Usage: $0 <destination_dir1> <destination_dir2> ... <destination_dirN>" | ||
exit 1 | ||
fi | ||
|
||
# Function to copy files from source to destination dirs | ||
copy_files() { | ||
local SOURCE_DIR=$1 | ||
local DEST_DIR=$2 | ||
local FILES=("${@:3}") # Capture all remaining arguments as the list of files to copy | ||
|
||
echo "Copying files from $SOURCE_DIR to $DEST_DIR..." | ||
|
||
# Create destination directory if it doesn't exist | ||
mkdir -p "$DEST_DIR" | ||
|
||
# Iterate through each file in the list and copy it to the destination directory | ||
for FILE in "${FILES[@]}"; do | ||
# Check if the file exists in the source directory | ||
if [[ -f "$SOURCE_DIR/$FILE" ]]; then | ||
echo "Copying $FILE to $DEST_DIR" | ||
cp "$SOURCE_DIR/$FILE" "$DEST_DIR/" | ||
else | ||
echo "File $FILE not found in $SOURCE_DIR" | ||
exit 1 | ||
fi | ||
done | ||
} | ||
|
||
# List of predefined filenames of static resources | ||
FILES=( | ||
"Chart.min.css" | ||
"Chart.min.js" | ||
"index.html" | ||
"main.js" | ||
"styles.css" | ||
) | ||
|
||
# Copy files to the temporary directory | ||
copy_files "$SOURCE_DIR" "$TMP_DIR" "${FILES[@]}" | ||
|
||
# Switch to the gh-pages to provision static resources to it | ||
git switch gh-pages | ||
|
||
# Iterate through the destination directories and copy files from the temporary one to each of them | ||
for DEST_DIR in "$@"; do | ||
copy_files "$TMP_DIR" "$DEST_DIR" "${FILES[@]}" | ||
done | ||
|
||
echo "Copied static files for all charts" | ||
|
||
for DIR in "$@"; do | ||
if [ -d "$DIR" ]; then | ||
echo "Adding files from $DIR..." | ||
git add "$DIR"/* | ||
else | ||
echo "Warning: Directory $DIR does not exist. Skipping." | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Check if there are any files to commit | ||
if git diff --cached --quiet; then | ||
echo "No changes to commit." | ||
exit 0 | ||
fi | ||
|
||
# Commit the changes | ||
git \ | ||
-c user.name=github-bench-workflow \ | ||
-c [email protected] \ | ||
commit -m "Stored static files" |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,59 @@ | ||
<!-- | ||
the MIT License | ||
Copyright (c) 2019 rhysd | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR | ||
THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
--> | ||
<!DOCTYPE html> | ||
<meta | ||
http-equiv="Content-Security-Policy" | ||
content="upgrade-insecure-requests; default-src 'none'; object-src 'none'; frame-ancestors 'none'; base-uri 'none'; script-src 'self'; style-src 'self';" | ||
> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes" /> | ||
<link rel="stylesheet" href="styles.css"> | ||
<link rel="stylesheet" type="text/css" href="Chart.min.css"> | ||
<title>Benchmarks</title> | ||
</head> | ||
|
||
<body> | ||
<header id="header"> | ||
<div class="header-item"> | ||
<strong class="header-label">Last Update:</strong> | ||
<span id="last-update"></span> | ||
</div> | ||
<div class="header-item"> | ||
<strong class="header-label">Repository:</strong> | ||
<a id="repository-link" rel="noopener"></a> | ||
</div> | ||
</header> | ||
<main id="main"></main> | ||
<footer> | ||
<button id="dl-button">Download data as JSON</button> | ||
<div class="spacer"></div> | ||
<div class="small">Powered by <a rel="noopener" href="https://github.com/marketplace/actions/continuous-benchmark">github-action-benchmark</a></div> | ||
</footer> | ||
|
||
<script src="Chart.min.js"></script> | ||
<script src="data.js"></script> | ||
<script src="main.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.