-
Notifications
You must be signed in to change notification settings - Fork 405
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
[WIP] Github action for pulling in nightly builds from CircleCI #29
Closed
Closed
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
name: Pull in latest soljson build from CircleCI | ||
|
||
on: | ||
schedule: | ||
# Run once a day, at midnight | ||
- cron: '0 0 * * *' | ||
|
||
jobs: | ||
pull-soljson: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
JOB_NAME: b_ems | ||
GIT_NAME: pull-soljson action | ||
# TODO: Set a proper e-mail address | ||
GIT_EMAIL: solidity@example.com | ||
TARGET_BRANCH: master | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- name: Clone the repository without checking out a working copy | ||
run: | | ||
repository_url="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | ||
git clone --no-checkout "$repository_url" "$GITHUB_WORKSPACE" --branch "$TARGET_BRANCH" | ||
git config --local user.name "$GIT_NAME" | ||
git config --local user.email "$GIT_EMAIL" | ||
|
||
- name: Unstage all files from local index | ||
run: | | ||
# For some reason git stages all files for deletion when you use --no-checkout | ||
git reset HEAD --quiet | ||
|
||
- name: Check out only the files we're going to actually use | ||
run: | | ||
git checkout -- update package.json | ||
git checkout -- bin/list.json | ||
git checkout -- bin/list.js | ||
git checkout -- bin/list.txt | ||
git checkout -- wasm/list.json | ||
git checkout -- wasm/list.js | ||
git checkout -- wasm/list.txt | ||
|
||
# FIXME: The update script crashes if there isn't at least one release already stored. | ||
git checkout -- update bin/soljson-latest.js | ||
git checkout -- update wasm/soljson-latest.js | ||
git checkout -- update bin/soljson-v0.3.6+commit.3fc68da5.js | ||
git checkout -- update wasm/soljson-v0.3.6+commit.3fc68da5.js | ||
|
||
- name: Get job info using CircleCI API | ||
run: | | ||
job_info_endpoint="https://circleci.com/api/v1.1/project/github/ethereum/solidity?filter=successful&limit=100" | ||
job_info=$( | ||
curl --silent --show-error "$job_info_endpoint" | | ||
jq '[ .[] | select (.workflows.job_name == "'${JOB_NAME}'") ] | sort_by(.build_num) | last' | ||
) | ||
|
||
build_num=$(echo "$job_info" | jq ".build_num") | ||
|
||
commit_hash=$(echo "$job_info" | jq --raw-output ".vcs_revision" | head --bytes 8) | ||
# FIXME: CircleCI API provides a tag name only if it's directly on the current commit. | ||
solidity_version="[version-placeholder]" | ||
nightly_version="${solidity_version}+commit.${commit_hash}" | ||
version_already_exists="$(test -f "bin/soljson-$nightly_version.js" && echo true || true)" | ||
|
||
echo "::set-env name=NIGHTLY_VERSION::${nightly_version}" | ||
echo "::set-env name=VERSION_ALREADY_EXISTS::${version_already_exists}" | ||
echo "::set-env name=BUILD_NUM::${build_num}" | ||
|
||
- name: Get artifact URL using CircleCI API | ||
if: "!env.VERSION_ALREADY_EXISTS" | ||
run: | | ||
artifacts_endpoint="https://circleci.com/api/v1.1/project/github/ethereum/solidity/${BUILD_NUM}/artifacts" | ||
artifact_url=$( | ||
curl --silent --show-error "$artifacts_endpoint" | | ||
jq --raw-output '.[].url' | ||
) | ||
|
||
echo "::set-env name=ARTIFACT_URL::${artifact_url}" | ||
|
||
- name: Download the binary from CircleCI | ||
if: "!env.VERSION_ALREADY_EXISTS" | ||
run: | | ||
# TMP: | ||
#curl --silent --show-error --location --create-dirs --output "$NIGHTLY_PATH" "$ARTIFACT_URL" | ||
curl --silent --show-error --location --remote-name "$ARTIFACT_URL" | ||
test -f soljson.js | ||
|
||
cp soljson.js "bin/soljson-$NIGHTLY_VERSION.js" | ||
mv soljson.js bin/soljson-nightly.js | ||
|
||
# TODO: Add a symlink under wasm/ if it's a tagged commit | ||
# [ "$TRAVIS_BRANCH" = release ] && ln -sf ../bin/"$NEWFILE" ./wasm/"$NEWFILE" | ||
cameel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Install dependencies of the update script using npm | ||
if: "!env.VERSION_ALREADY_EXISTS" | ||
run: | | ||
npm install | ||
|
||
- name: Run the script that updates the file lists | ||
if: "!env.VERSION_ALREADY_EXISTS" | ||
run: | | ||
# FIXME: Since we do no check out old binaries, the script will clear the lists. | ||
# Modify it to just append the new nightly instead. | ||
npm run update | ||
|
||
- name: Commit the nightly binary and updated lists | ||
if: "!env.VERSION_ALREADY_EXISTS" | ||
run: | | ||
# TODO: Commit any wasm and release changes too | ||
git add "bin/soljson-$NIGHTLY_VERSION.js" | ||
git add bin/soljson-nightly.js | ||
git add bin/list.json | ||
git add bin/list.js | ||
git add bin/list.txt | ||
git commit -m "Nightly build ${NIGHTLY_VERSION}" | ||
|
||
- name: Push the commit | ||
if: "!env.VERSION_ALREADY_EXISTS" | ||
run: | | ||
git push origin "$TARGET_BRANCH" |
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.
This will run once every night without oversight - are 5 minutes for a full checkout really worth avoiding?