Skip to content
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

Github action for emscripten nightly builds #30

Merged
merged 1 commit into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/workflows/nightly-emscripten.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Emscripten nightly build + push to solc-bin

on:
schedule:
# Run once a day, at midnight
- cron: '0 0 * * *'

env:
TARGET_BRANCH: gh-pages
COMMITTER_NAME: emscripten nightly action
COMMITTER_EMAIL: builds@ethereum.org
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build-emscripten-nightly:
runs-on: ubuntu-latest
outputs:
solidity-version: ${{ env.SOLIDITY_VERSION }}
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}"
cameel marked this conversation as resolved.
Show resolved Hide resolved

echo "::set-env name=SOLIDITY_VERSION::${solidity_version}"
echo "::set-env name=NIGHTLY_VERSION::${nightly_version}"

# There's no way to just stop a job without failing and that would spam everyone with
# spurious e-mail notifications about the failure. Instead we have to make do with `if`s.
echo "::set-env name=MATCHING_NIGHTLIES_IN_THE_REPO::${matching_nightlies_in_the_repo}"
cameel marked this conversation as resolved.
Show resolved Hide resolved

- 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

cameel marked this conversation as resolved.
Show resolved Hide resolved
- 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


test-emscripten-nightly:
runs-on: ubuntu-latest
needs: build-emscripten-nightly

env:
SOLIDITY_VERSION: ${{ needs.build-emscripten-nightly.outputs.solidity-version }}

if: "!needs.build-emscripten-nightly.outputs.matching-nightlies-in-the-repo"
steps:
- uses: actions/checkout@v2
with:
repository: 'ethereum/solidity'

- name: Download soljson.js artifact
uses: actions/download-artifact@v2
with:
name: soljson.js

- name: Run solc-js tests
run: |
test/externalTests/solc-js/solc-js.sh "${PWD}/soljson.js" "$SOLIDITY_VERSION"


add-nightly-and-push:
runs-on: ubuntu-latest
needs:
- build-emscripten-nightly
- test-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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add this script to solidity repo but then I'd have to either clone the repo in this job just to get access to it or pass it from the previous job as an artifact. For now I put it in the root dir of solc-bin.

53 changes: 53 additions & 0 deletions add-nightly-and-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/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.
#------------------------------------------------------------------------------
Comment on lines +3 to +13
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I add the license boilerplate here? Other scripts in this repo don't have it. And it might need to be reworded slightly (not sure).


set -e

die() {
echo
>&2 echo "ERROR: $@" && false
}

nightly_binary="$1"
nightly_version="$2"
(( $# == 2 )) || die "Expected exactly 2 parameters."

if [[ $(git status --porcelain) != "" ]]; then
>&2 git status
die "Uncommitted and/or untracked files present. This script must be executed in a clean working copy of the repository."
fi

echo "Adding bin/soljson-${nightly_version}.js"
[[ ! -e "bin/soljson-${nightly_version}.js" ]] || die "File bin/soljson-${nightly_version}.js already exists."
cp "$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 --message "Nightly build ${nightly_version}"

if [[ $(git status --porcelain) != "" ]]; then
>&2 git status
die "Unexpected file modifications found. This should never happen and might be the result of a bug."
fi

git push origin HEAD