diff --git a/.circleci/config.yml b/.circleci/config.yml index d17f13baadd4..288749974fb3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,26 +33,11 @@ defaults: - run_build: &run_build name: Build - command: | - set -ex - if [ "$CIRCLE_BRANCH" = release -o -n "$CIRCLE_TAG" -o -n "$FORCE_RELEASE" ]; then echo -n > prerelease.txt; else date -u +"nightly.%Y.%-m.%-d" > prerelease.txt; fi - echo -n "$CIRCLE_SHA1" > commit_hash.txt - mkdir -p build - cd build - [ -n "$COVERAGE" -a "$CIRCLE_BRANCH" != release -a -z "$CIRCLE_TAG" ] && CMAKE_OPTIONS="$CMAKE_OPTIONS -DCOVERAGE=ON" - cmake .. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} $CMAKE_OPTIONS -G "Unix Makefiles" - make -j4 + command: scripts/ci/build.sh - run_build_ossfuzz: &run_build_ossfuzz name: Build_ossfuzz - command: | - mkdir -p build - cd build - protoc --proto_path=../test/tools/ossfuzz yulProto.proto --cpp_out=../test/tools/ossfuzz - protoc --proto_path=../test/tools/ossfuzz abiV2Proto.proto --cpp_out=../test/tools/ossfuzz - protoc --proto_path=../test/tools/ossfuzz solProto.proto --cpp_out=../test/tools/ossfuzz - cmake .. -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release} $CMAKE_OPTIONS - make ossfuzz ossfuzz_proto ossfuzz_abiv2 -j4 + command: scripts/ci/build_ossfuzz.sh - run_proofs: &run_proofs name: Correctness proofs for optimization rules diff --git a/.github/workflows/buildpack-emscripten.yml b/.github/workflows/buildpack-emscripten.yml new file mode 100644 index 000000000000..7f22b6554bb2 --- /dev/null +++ b/.github/workflows/buildpack-emscripten.yml @@ -0,0 +1,34 @@ +name: buildpack:emscripten + +on: + pull_request: + paths: + - '.github/workflows/buildpack-emscripten.yml' + - 'scripts/docker/buildpack/Dockerfile.emscripten' + +jobs: + build: + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_REPOSITORY: docker.pkg.github.com/${{ github.repository }} + IMAGE_NAME: buildpack + IMAGE_VARIANT: emscripten + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Upgrade ${{ env.IMAGE_NAME }}-${{ env.IMAGE_VARIANT }} + run: | + echo "${GITHUB_TOKEN}" | docker login docker.pkg.github.com -u "${GITHUB_ACTOR}" --password-stdin + scripts/ci/docker_upgrade.sh + docker logout docker.pkg.github.com + + - name: comment PR + uses: aarlt/comment-on-pr@v1.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`." + check_for_duplicate_msg: false # OPTIONAL diff --git a/.github/workflows/buildpack-ubuntu1604.clang.ossfuzz.yml b/.github/workflows/buildpack-ubuntu1604.clang.ossfuzz.yml new file mode 100644 index 000000000000..1ca2f1c858bd --- /dev/null +++ b/.github/workflows/buildpack-ubuntu1604.clang.ossfuzz.yml @@ -0,0 +1,34 @@ +name: buildpack:ubuntu1604.clang.ossfuzz + +on: + pull_request: + paths: + - '.github/workflows/buildpack-ubuntu1604.clang.ossfuzz.yml' + - 'scripts/docker/buildpack/Dockerfile.ubuntu1604.clang.ossfuzz' + +jobs: + build: + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_REPOSITORY: docker.pkg.github.com/${{ github.repository }} + IMAGE_NAME: buildpack + IMAGE_VARIANT: ubuntu1604.clang.ossfuzz + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Upgrade ${{ env.IMAGE_NAME }}-${{ env.IMAGE_VARIANT }} + run: | + echo "${GITHUB_TOKEN}" | docker login docker.pkg.github.com -u "${GITHUB_ACTOR}" --password-stdin + scripts/ci/docker_upgrade.sh + docker logout docker.pkg.github.com + + - name: comment PR + uses: aarlt/comment-on-pr@v1.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`." + check_for_duplicate_msg: false # OPTIONAL diff --git a/.github/workflows/buildpack-ubuntu1804.yml b/.github/workflows/buildpack-ubuntu1804.yml new file mode 100644 index 000000000000..e0c85ffa1e0f --- /dev/null +++ b/.github/workflows/buildpack-ubuntu1804.yml @@ -0,0 +1,34 @@ +name: buildpack:ubuntu1804 + +on: + pull_request: + paths: + - '.github/workflows/buildpack-ubuntu1804.yml' + - 'scripts/docker/buildpack/Dockerfile.ubuntu1804' + +jobs: + build: + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_REPOSITORY: docker.pkg.github.com/${{ github.repository }} + IMAGE_NAME: buildpack + IMAGE_VARIANT: ubuntu1804 + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Upgrade ${{ env.IMAGE_NAME }}-${{ env.IMAGE_VARIANT }} + run: | + echo "${GITHUB_TOKEN}" | docker login docker.pkg.github.com -u "${GITHUB_ACTOR}" --password-stdin + scripts/ci/docker_upgrade.sh + docker logout docker.pkg.github.com + + - name: comment PR + uses: aarlt/comment-on-pr@v1.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`." + check_for_duplicate_msg: false # OPTIONAL diff --git a/.github/workflows/buildpack-ubuntu2004.clang.yml b/.github/workflows/buildpack-ubuntu2004.clang.yml new file mode 100644 index 000000000000..22164e6f2b32 --- /dev/null +++ b/.github/workflows/buildpack-ubuntu2004.clang.yml @@ -0,0 +1,36 @@ +name: buildpack:ubuntu2004.clang + +on: + pull_request: + paths: + - '.github/workflows/buildpack-ubuntu2004.clang.yml' + - 'scripts/docker/buildpack/Dockerfile.ubuntu2004.clang' + +jobs: + build: + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_REPOSITORY: docker.pkg.github.com/${{ github.repository }} + IMAGE_NAME: buildpack + IMAGE_VARIANT: ubuntu2004.clang + CC: clang + CXX: clang++ + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Upgrade ${{ env.IMAGE_NAME }}-${{ env.IMAGE_VARIANT }} + run: | + echo "${GITHUB_TOKEN}" | docker login docker.pkg.github.com -u "${GITHUB_ACTOR}" --password-stdin + scripts/ci/docker_upgrade.sh + docker logout docker.pkg.github.com + + - name: comment PR + uses: aarlt/comment-on-pr@v1.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`." + check_for_duplicate_msg: false # OPTIONAL diff --git a/.github/workflows/buildpack-ubuntu2004.yml b/.github/workflows/buildpack-ubuntu2004.yml new file mode 100644 index 000000000000..4ad03a407c11 --- /dev/null +++ b/.github/workflows/buildpack-ubuntu2004.yml @@ -0,0 +1,33 @@ +name: buildpack:ubuntu2004 + +on: + pull_request: + paths: + - '.github/workflows/buildpack-ubuntu2004.yml' + - 'scripts/docker/buildpack/Dockerfile.ubuntu2004' +jobs: + build: + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_REPOSITORY: docker.pkg.github.com/${{ github.repository }} + IMAGE_NAME: buildpack + IMAGE_VARIANT: ubuntu2004 + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Upgrade ${{ env.IMAGE_NAME }}-${{ env.IMAGE_VARIANT }} + run: | + echo "${GITHUB_TOKEN}" | docker login docker.pkg.github.com -u "${GITHUB_ACTOR}" --password-stdin + scripts/ci/docker_upgrade.sh + docker logout docker.pkg.github.com + + - name: comment PR + uses: aarlt/comment-on-pr@v1.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`." + check_for_duplicate_msg: false # OPTIONAL diff --git a/.gitignore b/.gitignore index 67e4507591ab..749860301975 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,7 @@ prerelease.txt # Build directory build/ -build*/ +/build*/ emscripten_build/ docs/_build __pycache__ diff --git a/scripts/build.sh b/scripts/build.sh index 6edd60bd9b07..12f7d2e7a04c 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -2,6 +2,11 @@ set -e ROOTDIR="$(dirname "$0")/.." +if [[ "$( cd "$(dirname "$0")" ; pwd -P )" == *".github"* ]] +then + ROOTDIR="/root/project" +fi + BUILDDIR="${ROOTDIR}/build" if [[ $# -eq 0 ]]; then diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh new file mode 100755 index 000000000000..a731402ff4b0 --- /dev/null +++ b/scripts/ci/build.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -ex + +ROOTDIR="$(dirname "$0")/../.." +cd "${ROOTDIR}" + +# shellcheck disable=SC2166 +if [ "$CIRCLE_BRANCH" = release -o -n "$CIRCLE_TAG" -o -n "$FORCE_RELEASE" ]; then echo -n >prerelease.txt; else date -u +"nightly.%Y.%-m.%-d" >prerelease.txt; fi +if [ -n "$CIRCLE_SHA1" ] +then + echo -n "$CIRCLE_SHA1" >commit_hash.txt +fi + +mkdir -p build +cd build + +# shellcheck disable=SC2166 +[ -n "$COVERAGE" -a "$CIRCLE_BRANCH" != release -a -z "$CIRCLE_TAG" ] && CMAKE_OPTIONS="$CMAKE_OPTIONS -DCOVERAGE=ON" + +# shellcheck disable=SC2086 +cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" $CMAKE_OPTIONS -G "Unix Makefiles" +make -j4 diff --git a/scripts/ci/build_ossfuzz.sh b/scripts/ci/build_ossfuzz.sh new file mode 100755 index 000000000000..cdfb141f0a83 --- /dev/null +++ b/scripts/ci/build_ossfuzz.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -e + +ROOTDIR="$(dirname "$0")/../.." +BUILDDIR="${ROOTDIR}/build" + +mkdir -p "${BUILDDIR}" +cd "${BUILDDIR}" + +protoc --proto_path=../test/tools/ossfuzz yulProto.proto --cpp_out=../test/tools/ossfuzz +protoc --proto_path=../test/tools/ossfuzz abiV2Proto.proto --cpp_out=../test/tools/ossfuzz +protoc --proto_path=../test/tools/ossfuzz solProto.proto --cpp_out=../test/tools/ossfuzz +cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/libfuzzer.cmake +make ossfuzz ossfuzz_proto ossfuzz_abiv2 -j4 diff --git a/scripts/ci/docker_test_emscripten.sh b/scripts/ci/docker_test_emscripten.sh new file mode 120000 index 000000000000..6e838fba7fb3 --- /dev/null +++ b/scripts/ci/docker_test_emscripten.sh @@ -0,0 +1 @@ +../../scripts/travis-emscripten/build_emscripten.sh \ No newline at end of file diff --git a/scripts/ci/docker_test_ubuntu1604.clang.ossfuzz.sh b/scripts/ci/docker_test_ubuntu1604.clang.ossfuzz.sh new file mode 120000 index 000000000000..86beda7dd2c3 --- /dev/null +++ b/scripts/ci/docker_test_ubuntu1604.clang.ossfuzz.sh @@ -0,0 +1 @@ +build_ossfuzz.sh \ No newline at end of file diff --git a/scripts/ci/docker_test_ubuntu1804.sh b/scripts/ci/docker_test_ubuntu1804.sh new file mode 120000 index 000000000000..c07a74de4fb4 --- /dev/null +++ b/scripts/ci/docker_test_ubuntu1804.sh @@ -0,0 +1 @@ +build.sh \ No newline at end of file diff --git a/scripts/ci/docker_test_ubuntu2004.clang.sh b/scripts/ci/docker_test_ubuntu2004.clang.sh new file mode 120000 index 000000000000..c07a74de4fb4 --- /dev/null +++ b/scripts/ci/docker_test_ubuntu2004.clang.sh @@ -0,0 +1 @@ +build.sh \ No newline at end of file diff --git a/scripts/ci/docker_test_ubuntu2004.sh b/scripts/ci/docker_test_ubuntu2004.sh new file mode 120000 index 000000000000..c07a74de4fb4 --- /dev/null +++ b/scripts/ci/docker_test_ubuntu2004.sh @@ -0,0 +1 @@ +build.sh \ No newline at end of file diff --git a/scripts/ci/docker_upgrade.sh b/scripts/ci/docker_upgrade.sh new file mode 100755 index 000000000000..65021387a118 --- /dev/null +++ b/scripts/ci/docker_upgrade.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +set -e + +check_parameters() { + echo "-- check_parameters" + + if [ -z "${IMAGE_NAME}" ] || [ -z "${IMAGE_VARIANT}" ] || [ -z "${DOCKER_REPOSITORY}" ]; then + echo "\${IMAGE_NAME}, \${IMAGE_VARIANT} and \${DOCKER_REPOSITORY} need to be defined." + + false + fi +} + +check_version() { + echo "-- check_version" + + git fetch + git branch + DOCKERFILE="scripts/docker/${IMAGE_NAME}/Dockerfile.${IMAGE_VARIANT}" + PREV_VERSION=$(git diff origin/develop HEAD -- "${DOCKERFILE}" | grep -e "-LABEL version=\".*\"" | awk -F"\"" '{ print $2 }') + NEXT_VERSION=$(git diff origin/develop HEAD -- "${DOCKERFILE}" | grep -e "+LABEL version=\".*\"" | awk -F"\"" '{ print $2 }') + + if [ -z "${NEXT_VERSION}" ]; then + echo "" + echo "ERROR: No version label defined in Dockerfile. You may need to add 'LABEL version' in '${DOCKERFILE}'. Aborting." + echo "" + + false + fi + + if [ -z "${PREV_VERSION}" ]; then + PREV_VERSION=0 + echo "" + echo "WARNING: no previous version found. Will set \$PREV_VERSION = 0." + echo "" + fi + + if [[ $((PREV_VERSION + 1)) != $((NEXT_VERSION)) ]]; then + echo "" + echo "ERROR: Version label in Dockerfile was not incremented. You may need to change 'LABEL version' in '${DOCKERFILE}'. Aborting." + echo "" + + false + fi +} + +build_docker() { + echo "-- build_docker" + + docker build "scripts/docker/${IMAGE_NAME}" --file "scripts/docker/${IMAGE_NAME}/Dockerfile.${IMAGE_VARIANT}" --tag "${IMAGE_NAME}" +} + +test_docker() { + echo "-- test_docker @ '${PWD}'" + + docker run -v "${PWD}:/root/project" "${IMAGE_NAME}" "/root/project/scripts/ci/docker_test_${IMAGE_VARIANT}.sh" +} + +push_docker() { + echo "-- push_docker" + + VERSION=$(docker inspect --format='{{.Config.Labels.version}}' "${IMAGE_NAME}") + DOCKER_IMAGE_ID="${DOCKER_REPOSITORY}/${IMAGE_NAME}-${IMAGE_VARIANT}" + + docker tag "${IMAGE_NAME}" "${DOCKER_IMAGE_ID}:${VERSION}" + docker push "${DOCKER_IMAGE_ID}:${VERSION}" + + REPO_DIGEST=$(docker inspect --format='{{.RepoDigests}}' "${DOCKER_IMAGE_ID}:${VERSION}") + + docker tag "${IMAGE_NAME}" "${DOCKER_IMAGE_ID}:latest" + docker push "${DOCKER_IMAGE_ID}:latest" + + echo "::set-env name=DOCKER_IMAGE::${DOCKER_IMAGE_ID}:${VERSION}" + echo "::set-env name=DOCKER_REPO_DIGEST::${REPO_DIGEST}" +} + +check_parameters +check_version +build_docker +test_docker +push_docker diff --git a/.circleci/docker/Dockerfile.emscripten b/scripts/docker/buildpack/Dockerfile.emscripten similarity index 99% rename from .circleci/docker/Dockerfile.emscripten rename to scripts/docker/buildpack/Dockerfile.emscripten index d2456bb2ae0b..4285e0d30d59 100644 --- a/.circleci/docker/Dockerfile.emscripten +++ b/scripts/docker/buildpack/Dockerfile.emscripten @@ -29,6 +29,7 @@ # make version=1.39.15 build # FROM emscripten/emsdk:1.39.15 AS base +LABEL version="1" ADD emscripten.jam /usr/src RUN set -ex; \ diff --git a/.circleci/docker/Dockerfile.ubuntu1604.clang.ossfuzz b/scripts/docker/buildpack/Dockerfile.ubuntu1604.clang.ossfuzz similarity index 99% rename from .circleci/docker/Dockerfile.ubuntu1604.clang.ossfuzz rename to scripts/docker/buildpack/Dockerfile.ubuntu1604.clang.ossfuzz index f7dfc7001bdf..cb8a5f56d609 100644 --- a/.circleci/docker/Dockerfile.ubuntu1604.clang.ossfuzz +++ b/scripts/docker/buildpack/Dockerfile.ubuntu1604.clang.ossfuzz @@ -22,6 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM gcr.io/oss-fuzz-base/base-clang as base +LABEL version="1" ARG DEBIAN_FRONTEND=noninteractive diff --git a/.circleci/docker/Dockerfile.ubuntu1804 b/scripts/docker/buildpack/Dockerfile.ubuntu1804 similarity index 99% rename from .circleci/docker/Dockerfile.ubuntu1804 rename to scripts/docker/buildpack/Dockerfile.ubuntu1804 index fa651900b873..a50d7c612f50 100644 --- a/.circleci/docker/Dockerfile.ubuntu1804 +++ b/scripts/docker/buildpack/Dockerfile.ubuntu1804 @@ -22,6 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:bionic AS base +LABEL version="1" ARG DEBIAN_FRONTEND=noninteractive diff --git a/.circleci/docker/Dockerfile.ubuntu2004 b/scripts/docker/buildpack/Dockerfile.ubuntu2004 similarity index 98% rename from .circleci/docker/Dockerfile.ubuntu2004 rename to scripts/docker/buildpack/Dockerfile.ubuntu2004 index a021b6533486..f3fa4031dd21 100644 --- a/.circleci/docker/Dockerfile.ubuntu2004 +++ b/scripts/docker/buildpack/Dockerfile.ubuntu2004 @@ -22,6 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:focal AS base +LABEL version="1" ARG DEBIAN_FRONTEND=noninteractive @@ -58,5 +59,7 @@ RUN set -ex; \ FROM base COPY --from=libraries /usr/lib /usr/lib +RUN true COPY --from=libraries /usr/bin /usr/bin +RUN true COPY --from=libraries /usr/include /usr/include diff --git a/.circleci/docker/Dockerfile.ubuntu2004.clang b/scripts/docker/buildpack/Dockerfile.ubuntu2004.clang similarity index 98% rename from .circleci/docker/Dockerfile.ubuntu2004.clang rename to scripts/docker/buildpack/Dockerfile.ubuntu2004.clang index c8d057eb11a0..c0d474648068 100644 --- a/.circleci/docker/Dockerfile.ubuntu2004.clang +++ b/scripts/docker/buildpack/Dockerfile.ubuntu2004.clang @@ -22,6 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:focal AS base +LABEL version="1" ARG DEBIAN_FRONTEND=noninteractive @@ -60,5 +61,7 @@ RUN set -ex; \ FROM base COPY --from=libraries /usr/lib /usr/lib +RUN true COPY --from=libraries /usr/bin /usr/bin +RUN true COPY --from=libraries /usr/include /usr/include diff --git a/.circleci/docker/emscripten.jam b/scripts/docker/buildpack/emscripten.jam similarity index 100% rename from .circleci/docker/emscripten.jam rename to scripts/docker/buildpack/emscripten.jam