-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: enable rosetta cache for builds #17336
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ceebf80
chore: enable rosetta cache for builds
rix0rrr 9053206
Add extension
rix0rrr d016f6d
Do rosetta run full well after `transform`
rix0rrr 004b707
One directory up too far
rix0rrr 1afd9e2
Merge branch 'master' into huijbers/enable-rosetta-cache
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
# | ||
# If the environment variable S3_BUILD_CACHE is set, download and extract the | ||
# tarball it points to into the directory $HOME/.s3buildcache. | ||
# | ||
set -eu | ||
|
||
cachedir=$HOME/.s3buildcache | ||
mkdir -p $cachedir | ||
|
||
if [[ "${S3_BUILD_CACHE:-}" = "" ]]; then | ||
exit 0 | ||
fi | ||
|
||
echo "🧳 Build cache enabled: ${S3_BUILD_CACHE}" | ||
if ! aws s3 ls ${S3_BUILD_CACHE} > /dev/null; then | ||
echo "🧳⚠️ Cache not found." | ||
exit 0 | ||
fi | ||
|
||
if ! (cd $cachedir && aws s3 cp ${S3_BUILD_CACHE} - | tar xzv); then | ||
echo "🧳⚠️ Something went wrong fetching the cache. Continuing anyway." | ||
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,21 @@ | ||
#!/bin/bash | ||
# | ||
# If the environment variable S3_BUILD_CACHE is set, compress and upload the | ||
# contents of $HOME/.s3buildcache to it. | ||
# | ||
set -eu | ||
|
||
cachedir=$HOME/.s3buildcache | ||
mkdir -p $cachedir | ||
|
||
if [[ "${S3_BUILD_CACHE:-}" = "" ]]; then | ||
exit 0 | ||
fi | ||
|
||
echo "🧳 Storing build cache at: ${S3_BUILD_CACHE}" | ||
|
||
if ! (cd $cachedir && tar czv . | aws s3 cp - ${S3_BUILD_CACHE}); then | ||
echo "🧳⚠️ Something went wrong storing the cache." | ||
fi | ||
|
||
echo "🧳 Finished." |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
# | ||
# Run jsii-rosetta on all jsii packages, using the S3 build cache if available. | ||
# | ||
# Usage: run-rosetta [PKGSFILE] | ||
# | ||
# If you already have a file with a list of all the JSII package directories | ||
# in it, pass it as the first argument. Otherwise, this script will run | ||
# 'list-packages' to determine a list itself. | ||
set -eu | ||
scriptdir=$(cd $(dirname $0) && pwd) | ||
|
||
ROSETTA=${ROSETTA:-npx jsii-rosetta} | ||
|
||
if [[ "${1:-}" = "" ]]; then | ||
echo "Collecting package list..." >&2 | ||
TMPDIR=${TMPDIR:-$(dirname $(mktemp -u))} | ||
node $scriptdir/list-packages $TMPDIR/jsii.txt $TMPDIR/nonjsii.txt | ||
jsii_pkgs_file=$TMPDIR/jsii.txt | ||
else | ||
jsii_pkgs_file=$1 | ||
fi | ||
|
||
rosetta_cache_file=$HOME/.s3buildcache/rosetta-cache.tabl.json | ||
rosetta_cache_opts="" | ||
if [[ -f $rosetta_cache_file ]]; then | ||
rosetta_cache_opts="--cache-from ${rosetta_cache_file}" | ||
fi | ||
|
||
$ROSETTA \ | ||
--compile \ | ||
--output samples.tabl.json \ | ||
$rosetta_cache_opts \ | ||
--directory packages/decdk \ | ||
$(cat $jsii_pkgs_file) | ||
|
||
if [[ -d $(dirname $rosetta_cache_file) ]]; then | ||
# If the cache directory is available, copy the current tablet into it | ||
cp samples.tabl.json $rosetta_cache_file | ||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~
(Nit) - Move this to after the env variable check so this script no-ops if the environment variable isn't set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I did this on purpose. It's convenient to always be able to rely on the
~/.s3buildcache
directory existing (whether it's empty or not).Makes the shell scripts easier to write... (?)