-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Github action for emscripten nightly builds
- Loading branch information
Showing
2 changed files
with
151 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,96 @@ | ||
name: Emscripten nightly build + solc-bin push | ||
|
||
on: | ||
schedule: | ||
# Run once a day, at midnight | ||
- cron: '0 0 * * *' | ||
|
||
env: | ||
TARGET_BRANCH: master | ||
COMMITTER_NAME: pull-soljson action | ||
COMMITTER_EMAIL: builds@ethereum.org | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
build-emscripten-nightly: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
nightly-version: ${{ env.NIGHTLY_VERSION }} | ||
matching-nightlies-in-the-repo: ${{ env.MATCHING_NIGHTLIES_IN_THE_REPO }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
repository: 'ethereum/solidity' | ||
ref: 'develop' | ||
path: 'solidity/' | ||
|
||
- name: Clone solc-bin repository without checking out a working copy | ||
run: | | ||
git clone --no-checkout --branch "$TARGET_BRANCH" "https://github.com/${GITHUB_REPOSITORY}.git" solc-bin/ | ||
# For some reason git stages all files for deletion when you use --no-checkout | ||
cd solc-bin/ | ||
git reset HEAD --quiet | ||
- name: Check if there's already a nightly with the same date or commit ID | ||
run: | | ||
cd solidity/ | ||
solidity_version=$("scripts/get_version.sh") | ||
last_commit_timestamp=$(git log -1 --date=iso --format=%ad HEAD) | ||
last_commit_date=$(date --date="$last_commit_timestamp" --utc +%Y.%-m.%-d) | ||
last_commit_hash=$(git rev-parse --short=8 HEAD) | ||
cd ../solc-bin/ | ||
matching_nightlies_in_the_repo="$( | ||
git ls-files "bin/soljson-v${solidity_version}-nightly.${last_commit_date}+commit.*.js"; | ||
git ls-files "bin/soljson-v${solidity_version}-nightly.*+commit.${last_commit_hash}.js" | ||
)" | ||
nightly_version="v${solidity_version}-nightly.${last_commit_date}+commit.${last_commit_hash}" | ||
echo "::set-env name=NIGHTLY_VERSION::${nightly_version}" | ||
echo "::set-env name=MATCHING_NIGHTLIES_IN_THE_REPO::${matching_nightlies_in_the_repo}" | ||
- name: Build soljson.js | ||
if: "!env.MATCHING_NIGHTLIES_IN_THE_REPO" | ||
run: | | ||
cd solidity/ | ||
# Note that this script will spawn and build inside a docker image (which works just fine in github actions). | ||
scripts/build_emscripten.sh | ||
- name: Upload soljson.js as an artifact | ||
if: "!env.MATCHING_NIGHTLIES_IN_THE_REPO" | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: soljson.js | ||
path: solidity/upload/soljson.js | ||
|
||
add-nightly-and-push: | ||
runs-on: ubuntu-latest | ||
needs: build-emscripten-nightly | ||
|
||
env: | ||
NIGHTLY_VERSION: ${{ needs.build-emscripten-nightly.outputs.nightly-version }} | ||
|
||
if: "!needs.build-emscripten-nightly.outputs.matching-nightlies-in-the-repo" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ env.TARGET_BRANCH }} | ||
path: 'solc-bin' | ||
|
||
- name: Download soljson.js artifact | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: soljson.js | ||
|
||
- name: Set committer name and e-mail | ||
run: | | ||
cd solc-bin/ | ||
git config --local user.name "$COMMITTER_NAME" | ||
git config --local user.email "$COMMITTER_EMAIL" | ||
- name: Run add-nightly-and-push.sh | ||
run: | | ||
cd solc-bin/ | ||
./add-nightly-and-push.sh ../soljson.js "$NIGHTLY_VERSION" |
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,55 @@ | ||
#!/usr/bin/env bash | ||
|
||
#------------------------------------------------------------------------------ | ||
# Adds a nightly binary to a local checkout of solc-bin repository, updates | ||
# file lists, commits and pushes the changes to the remote repository. | ||
# | ||
# The script expects to find the working copy in its working directory with | ||
# the right branch already checked out and all the details necessary to make | ||
# a commit and push it (committer name, `origin` remote, etc.) configured. | ||
# | ||
# The script fails if the specified version is already present in the | ||
# repository. | ||
#------------------------------------------------------------------------------ | ||
|
||
set -e | ||
|
||
nightly_binary="$1" | ||
nightly_version="$2" | ||
|
||
if [[ $# != 2 ]]; then | ||
>&2 echo "ERROR: Expected exactly 2 parameters." | ||
exit 1 | ||
fi | ||
|
||
if [[ $(git status --porcelain) != "" ]]; then | ||
>&2 git status | ||
>&2 echo | ||
>&2 echo "ERROR: Uncommitted and/or untracked files present. This script must be executed in a clean working copy of the repository." | ||
exit 1 | ||
fi | ||
|
||
echo "Adding bin/soljson-${nightly_version}.js" | ||
cp --no-clobber "$nightly_binary" "bin/soljson-${nightly_version}.js" | ||
|
||
# Stage the new nightly before running the list update to be able to detect any unintended changes caused by the script. | ||
git add --verbose "bin/soljson-$nightly_version.js" | ||
|
||
npm config set package-lock false | ||
npm install | ||
npm run update | ||
rm -r node_modules/ | ||
|
||
git add --verbose bin/soljson-nightly.js | ||
git add --verbose bin/list.* | ||
|
||
git commit -m "Nightly build ${nightly_version}" | ||
|
||
if [[ $(git status --porcelain) != "" ]]; then | ||
>&2 git status | ||
>&2 echo | ||
>&2 echo "ERROR: Unexpected file modifications found. This should never happen and might be the result of a bug." | ||
exit 1 | ||
fi | ||
|
||
git push origin HEAD |