Skip to content

Commit 153c763

Browse files
committed
Github action for emscripten nightly builds
1 parent 93f4e51 commit 153c763

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed
+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Emscripten nightly build + solc-bin push
2+
3+
on:
4+
schedule:
5+
# Run once a day, at midnight
6+
- cron: '0 0 * * *'
7+
8+
env:
9+
TARGET_BRANCH: master
10+
COMMITTER_NAME: pull-soljson action
11+
COMMITTER_EMAIL: builds@ethereum.org
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
14+
jobs:
15+
build-emscripten-nightly:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
nightly-version: ${{ env.NIGHTLY_VERSION }}
19+
matching-nightlies-in-the-repo: ${{ env.MATCHING_NIGHTLIES_IN_THE_REPO }}
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
with:
24+
repository: 'ethereum/solidity'
25+
ref: 'develop'
26+
path: 'solidity/'
27+
28+
- name: Clone solc-bin repository without checking out a working copy
29+
run: |
30+
git clone --no-checkout --branch "$TARGET_BRANCH" "https://github.com/${GITHUB_REPOSITORY}.git" solc-bin/
31+
32+
# For some reason git stages all files for deletion when you use --no-checkout
33+
cd solc-bin/
34+
git reset HEAD --quiet
35+
36+
- name: Check if there's already a nightly with the same date or commit ID
37+
run: |
38+
cd solidity/
39+
solidity_version=$("scripts/get_version.sh")
40+
last_commit_timestamp=$(git log -1 --date=iso --format=%ad HEAD)
41+
last_commit_date=$(date --date="$last_commit_timestamp" --utc +%Y.%-m.%-d)
42+
last_commit_hash=$(git rev-parse --short=8 HEAD)
43+
44+
cd ../solc-bin/
45+
matching_nightlies_in_the_repo="$(
46+
git ls-files "bin/soljson-v${solidity_version}-nightly.${last_commit_date}+commit.*.js";
47+
git ls-files "bin/soljson-v${solidity_version}-nightly.*+commit.${last_commit_hash}.js"
48+
)"
49+
nightly_version="v${solidity_version}-nightly.${last_commit_date}+commit.${last_commit_hash}"
50+
51+
echo "::set-env name=NIGHTLY_VERSION::${nightly_version}"
52+
echo "::set-env name=MATCHING_NIGHTLIES_IN_THE_REPO::${matching_nightlies_in_the_repo}"
53+
54+
- name: Build soljson.js
55+
if: "!env.MATCHING_NIGHTLIES_IN_THE_REPO"
56+
run: |
57+
cd solidity/
58+
# Note that this script will spawn and build inside a docker image (which works just fine in github actions).
59+
scripts/build_emscripten.sh
60+
61+
- name: Upload soljson.js as an artifact
62+
if: "!env.MATCHING_NIGHTLIES_IN_THE_REPO"
63+
uses: actions/upload-artifact@v2
64+
with:
65+
name: soljson.js
66+
path: solidity/upload/soljson.js
67+
68+
add-nightly-and-push:
69+
runs-on: ubuntu-latest
70+
needs: build-emscripten-nightly
71+
72+
env:
73+
NIGHTLY_VERSION: ${{ needs.build-emscripten-nightly.outputs.nightly-version }}
74+
75+
if: "!needs.build-emscripten-nightly.outputs.matching-nightlies-in-the-repo"
76+
steps:
77+
- uses: actions/checkout@v2
78+
with:
79+
ref: ${{ env.TARGET_BRANCH }}
80+
path: 'solc-bin'
81+
82+
- name: Download soljson.js artifact
83+
uses: actions/download-artifact@v2
84+
with:
85+
name: soljson.js
86+
87+
- name: Set committer name and e-mail
88+
run: |
89+
cd solc-bin/
90+
git config --local user.name "$COMMITTER_NAME"
91+
git config --local user.email "$COMMITTER_EMAIL"
92+
93+
- name: Run add-nightly-and-push.sh
94+
run: |
95+
cd solc-bin/
96+
./add-nightly-and-push.sh ../soljson.js "$NIGHTLY_VERSION"

add-nightly-and-push.sh

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
#------------------------------------------------------------------------------
4+
# Adds a nightly binary to a local checkout of solc-bin repository, updates
5+
# file lists, commits and pushes the changes to the remote repository.
6+
#
7+
# The script expects to find the working copy in its working directory with
8+
# the right branch already checked out and all the details necessary to make
9+
# a commit and push it (committer name, `origin` remote, etc.) configured.
10+
#
11+
# The script fails if the specified version is already present in the
12+
# repository.
13+
#------------------------------------------------------------------------------
14+
15+
set -e
16+
17+
nightly_binary="$1"
18+
nightly_version="$2"
19+
20+
if [[ $# != 2 ]]; then
21+
>&2 echo "ERROR: Expected exactly 2 parameters."
22+
exit 1
23+
fi
24+
25+
if [[ $(git status --porcelain) != "" ]]; then
26+
>&2 git status
27+
>&2 echo
28+
>&2 echo "ERROR: Uncommitted and/or untracked files present. This script must be executed in a clean working copy of the repository."
29+
exit 1
30+
fi
31+
32+
echo "Adding bin/soljson-${nightly_version}.js"
33+
cp --no-clobber "$nightly_binary" "bin/soljson-${nightly_version}.js"
34+
35+
# Stage the new nightly before running the list update to be able to detect any unintended changes caused by the script.
36+
git add --verbose "bin/soljson-$nightly_version.js"
37+
38+
npm config set package-lock false
39+
npm install
40+
npm run update
41+
rm -r node_modules/
42+
43+
git add --verbose bin/soljson-nightly.js
44+
git add --verbose bin/list.*
45+
46+
git commit --message "Nightly build ${nightly_version}"
47+
48+
if [[ $(git status --porcelain) != "" ]]; then
49+
>&2 git status
50+
>&2 echo
51+
>&2 echo "ERROR: Unexpected file modifications found. This should never happen and might be the result of a bug."
52+
exit 1
53+
fi
54+
55+
git push origin HEAD

0 commit comments

Comments
 (0)