Emscripten nightly build + push to solc-bin #1200
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
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: [email protected] | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
build-emscripten-nightly: | |
runs-on: ubuntu-latest | |
outputs: | |
solidity-version: ${{ env.SOLIDITY_VERSION }} | |
nightly-version: ${{ env.NIGHTLY_VERSION }} | |
nightly-already-exists: ${{ env.NIGHTLY_ALREADY_EXISTS }} | |
steps: | |
- name: Remove unused software to free up space | |
run: | | |
# These are quick to delete and large enough to make a difference | |
rm -rf /usr/share/swift/ # 1.3 GB in 80 subdirs | |
rm -rf /usr/local/lib/android/sdk/build-tools/ # 2.1 GB in 450 subdirs | |
rm -rf /usr/share/dotnet/shared/ # 5.3 GB in 350 subdirs | |
rm -rf /usr/local/lib/android/sdk/ndk/ # 7.6 GB in 1500 subdirs | |
- uses: actions/checkout@v3 | |
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: Determine Solidity version | |
run: | | |
cd solidity/ | |
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) | |
solidity_version=$("scripts/get_version.sh") | |
nightly_version="v${solidity_version}-nightly.${last_commit_date}+commit.${last_commit_hash}" | |
echo "LAST_COMMIT_DATE=${last_commit_date}" >> $GITHUB_ENV | |
echo "LAST_COMMIT_HASH=${last_commit_hash}" >> $GITHUB_ENV | |
echo "SOLIDITY_VERSION=${solidity_version}" >> $GITHUB_ENV | |
echo "NIGHTLY_VERSION=${nightly_version}" >> $GITHUB_ENV | |
- name: Check if there's already a nightly with the same date or commit ID | |
run: | | |
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_already_exists="$(test -n "$matching_nightlies_in_the_repo" && echo true || echo false)" | |
# 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 "NIGHTLY_ALREADY_EXISTS=${nightly_already_exists}" >> $GITHUB_ENV | |
- name: Build soljson.js | |
if: "env.NIGHTLY_ALREADY_EXISTS == 'false'" | |
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 --prerelease-source "nightly" | |
- name: Upload soljson.js as an artifact | |
if: "env.NIGHTLY_ALREADY_EXISTS == 'false'" | |
uses: actions/upload-artifact@v3 | |
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.nightly-already-exists == 'false'" | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
repository: 'ethereum/solidity' | |
- name: Download soljson.js artifact | |
uses: actions/download-artifact@v3 | |
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.nightly-already-exists == 'false'" | |
steps: | |
# TODO: remove when https://github.com/axic/keccakjs/issues/13 got fixed | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Remove unused software to free up space | |
run: | | |
# These are quick to delete and large enough to make a difference | |
rm -rf /usr/share/swift/ # 1.3 GB in 80 subdirs | |
rm -rf /usr/local/lib/android/sdk/build-tools/ # 2.1 GB in 450 subdirs | |
rm -rf /usr/share/dotnet/shared/ # 5.3 GB in 350 subdirs | |
rm -rf /usr/local/lib/android/sdk/ndk/ # 7.6 GB in 1500 subdirs | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ env.TARGET_BRANCH }} | |
path: 'solc-bin' | |
- name: Download soljson.js artifact | |
uses: actions/download-artifact@v3 | |
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" |