diff --git a/.github/workflows/build_llvm_runner.yml b/.github/workflows/build_llvm_runner.yml deleted file mode 100644 index c8f28af..0000000 --- a/.github/workflows/build_llvm_runner.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Test of build LLVM_runner image - -on: - pull_request: - paths: - - 'images/llvm_runner/Dockerfile' - - '.github/workflows/build_llvm_runner.yml' - -jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: [matterlabs-ci-runner] - steps: - - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and push Docker image - uses: docker/build-push-action@v5.0.0 - with: - push: false - tags: "matterlabs/llvm_runner:latest" - file: images/llvm_runner/Dockerfile - no-cache: true diff --git a/.github/workflows/handle_llvm_runner_image.yml b/.github/workflows/handle_llvm_runner_image.yml new file mode 100644 index 0000000..06d9398 --- /dev/null +++ b/.github/workflows/handle_llvm_runner_image.yml @@ -0,0 +1,76 @@ +name: Handle LLVM_runner docker image + +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + check_changes: + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + image_to_build: ${{ steps.determine_changes.outputs.image_to_build }} + steps: + - id: determine_changes + uses: tj-actions/changed-files@v39 + with: + files_yaml: | + llvm_runner: + - "images/llvm_runner/Dockerfile" + llvm_runner_jammy: + - "images/llvm_runner/jammy.Dockerfile" + both: + - ".github/workflows/build_llvm_runner.yml" + + - id: set_output + run: | + if [ "${{ steps.determine_changes.outputs.llvm_runner_any_changed }}" == "true" ]; then + echo "image_to_build=llvm_runner" >> "$GITHUB_OUTPUT" + elif [ "${{ steps.determine_changes.outputs.llvm_runner_jammy_any_changed }}" == "true" ]; then + echo "image_to_build=llvm_runner_jammy" >> "$GITHUB_OUTPUT" + elif [ "${{ steps.determine_changes.outputs.both_any_changed }}" == "true" ]; then + echo "image_to_build=both" >> "$GITHUB_OUTPUT" + else + echo "image_to_build=none" >> "$GITHUB_OUTPUT" + fi + + handle_image: + needs: check_changes + if: needs.check_changes.outputs.image_to_build != 'none' + runs-on: [matterlabs-ci-runner] + strategy: + matrix: + image_name: [llvm_runner, llvm_runner_jammy] + fail-fast: false + steps: + - uses: actions/checkout@v4 + + - name: Set outputs + id: set_output + run: echo "name=sha_short::$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + if: github.event_name == 'push' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and optionally push Docker image + if: matrix.image_name == needs.check_changes.outputs.image_to_build || needs.check_changes.outputs.image_to_build == 'both' + uses: docker/build-push-action@v5 + with: + push: ${{ github.event_name == 'push' }} + tags: | + matterlabs/${{ matrix.image_name }}:${{ steps.set_output.outputs.sha_short }} + matterlabs/${{ matrix.image_name }}:latest + file: images/llvm_runner/${{ matrix.image_name == 'llvm_runner_jammy' && 'jammy.' || '' }}Dockerfile + platforms: linux/amd64,linux/arm64 diff --git a/.github/workflows/publishing_llvm_runner.yml b/.github/workflows/publishing_llvm_runner.yml deleted file mode 100644 index d45fa12..0000000 --- a/.github/workflows/publishing_llvm_runner.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Publish LLVM_runner docker image - -on: - pull_request: - branches: - - main - types: [closed] - paths: - - "images/llvm_runner/Dockerfile" - - ".github/workflows/build_llvm_runner.yml" - workflow_dispatch: - branches: - - "main" - -jobs: - push_to_registry: - if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' - name: Push Docker image to Docker Hub - runs-on: [matterlabs-ci-runner] - steps: - - uses: actions/checkout@v4 - - - name: Set outputs - id: vars - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push Docker image on merged PR - if: github.event.pull_request.merged == true - uses: docker/build-push-action@v5 - with: - push: true - tags: | - matterlabs/llvm_runner:${{ steps.vars.outputs.sha_short }} - matterlabs/llvm_runner:latest - file: images/llvm_runner/Dockerfile - no-cache: true - - - name: Build and push Docker image on manual trigger - if: github.event_name == 'workflow_dispatch' - uses: docker/build-push-action@v5 - with: - push: true - tags: | - matterlabs/llvm_runner:${{ steps.vars.outputs.sha_short }} - file: images/llvm_runner/Dockerfile - no-cache: true diff --git a/images/llvm_runner/jammy.Dockerfile b/images/llvm_runner/jammy.Dockerfile new file mode 100644 index 0000000..08877d2 --- /dev/null +++ b/images/llvm_runner/jammy.Dockerfile @@ -0,0 +1,49 @@ +FROM ubuntu:22.04 + +WORKDIR /usr/src/zksync + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + apt-get install --yes --no-install-recommends \ + bash git openssl curl libssl-dev sudo ssh-client \ + cmake gcc g++ ninja-build \ + libpq-dev pkg-config \ + software-properties-common jq \ + openssh-client git \ + build-essential \ + libncurses5 xz-utils wget gnupg musl-tools && \ + rm -rf /var/lib/apt/lists/* + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + CARGO_NET_GIT_FETCH_WITH_CLI=true \ + PATH=/usr/local/cargo/bin:$PATH +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y + +RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && \ + apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" && \ + apt-get --yes update && \ + apt-get --yes install cmake clang-15 lld-15 + +RUN add-apt-repository ppa:deadsnakes/ppa && \ + apt-get update && \ + apt-get --yes install python3.12 python3.12-dev python3.12-distutils + +# Required to build solidity fork +RUN apt-get update && apt-get -y install -y \ + libboost-dev \ + libboost-filesystem-dev \ + libboost-test-dev \ + libboost-system-dev \ + libboost-program-options-dev \ + libcvc4-dev \ + libcln-dev \ + libboost-regex-dev \ + libboost-thread-dev \ + libboost-random-dev + +ENV PATH=/usr/lib/llvm-15/bin:$PATH \ + LD_LIBRARY_PATH=/usr/lib/llvm-15/lib:$LD_LIBRARY_PATH \ + LLVM_VERSION=15 \ + CI_RUNNING=true