From 601ea1db508539795a27f47455a2dd8abbb43c48 Mon Sep 17 00:00:00 2001 From: aya Date: Sun, 1 Dec 2024 13:04:45 +0200 Subject: [PATCH] Add PR image to new nwaku workflow --- .github/workflows/container-image.yml | 99 +++++++++++++++++++++++++++ .github/workflows/nim_nwaku_pr.yml | 27 ++++++++ 2 files changed, 126 insertions(+) create mode 100644 .github/workflows/container-image.yml create mode 100644 .github/workflows/nim_nwaku_pr.yml diff --git a/.github/workflows/container-image.yml b/.github/workflows/container-image.yml new file mode 100644 index 00000000..7e993bfa --- /dev/null +++ b/.github/workflows/container-image.yml @@ -0,0 +1,99 @@ +name: container-image-build + +on: + workflow_call: + inputs: + image_tag: + type: string + default: ${{ github.event.number }} + outputs: + image: + description: The resulting image link + value: ${{ jobs.build-docker-image.outputs.image }} + +env: + NPROC: 2 + MAKEFLAGS: "-j${NPROC}" + NIMFLAGS: "--parallelBuild:${NPROC}" + +# This workflow should not run for outside contributors +# If org secrets are not available, we'll avoid building and publishing the docker image and we'll pass the workflow +jobs: + build-docker-image: + strategy: + matrix: + os: [ubuntu-22.04] + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + + name: docker-build-${{ matrix.os }} + outputs: + image: ${{ steps.build.outputs.image }} + steps: + - name: Check secrets + id: secrets + continue-on-error: true + run: | + if [[ -z "$QUAY_PASSWORD" || -z "$QUAY_USER" ]]; then + echo "User does not have access to secrets, skipping workflow" + exit 1 + fi + env: + QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + QUAY_USER: ${{ secrets.QUAY_USER }} + + - name: Checkout code + if: ${{ steps.secrets.outcome == 'success' }} + uses: actions/checkout@v3 + + - name: Get submodules hash + id: submodules + if: ${{ steps.secrets.outcome == 'success' }} + run: | + echo "hash=$(git submodule status | awk '{print $1}' | sort | shasum -a 256 | sed 's/[ -]*//g')" >> $GITHUB_OUTPUT + + - name: Cache submodules + if: ${{ steps.secrets.outcome == 'success' }} + uses: actions/cache@v3 + with: + path: | + vendor/ + .git/modules + key: ${{ runner.os }}-vendor-modules-${{ steps.submodules.outputs.hash }} + + - name: Build binaries + id: build + if: ${{ steps.secrets.outcome == 'success' }} + run: | + + make -j${NPROC} V=1 QUICK_AND_DIRTY_COMPILER=1 NIMFLAGS="-d:disableMarchNative -d:postgres -d:chronicles_colors:none" wakunode2 + + SHORT_REF=$(git rev-parse --short HEAD) + + TAG=$([ "${PR_NUMBER}" == "" ] && echo "${SHORT_REF}" || echo "${PR_NUMBER}") + IMAGE=quay.io/wakuorg/nwaku-pr:${TAG} + + echo "image=${IMAGE}" >> $GITHUB_OUTPUT + echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + docker login -u ${QUAY_USER} -p ${QUAY_PASSWORD} quay.io + docker build -t ${IMAGE} -f docker/binaries/Dockerfile.bn.amd64 --label quay.expires-after=30d . + docker push ${IMAGE} + env: + QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + QUAY_USER: ${{ secrets.QUAY_USER }} + PR_NUMBER: ${{ inputs.image_tag}} + + - name: Comment PR + uses: thollander/actions-comment-pull-request@v2 + if: ${{ github.event_name == 'pull_request' && steps.secrets.outcome == 'success' }} + with: + message: | + You can find the image built from this PR at + + ``` + ${{steps.build.outputs.image}} + ``` + + Built from ${{ steps.build.outputs.commit_hash }} + comment_tag: execution-rln-v${{ matrix.rln_version }} diff --git a/.github/workflows/nim_nwaku_pr.yml b/.github/workflows/nim_nwaku_pr.yml new file mode 100644 index 00000000..32ef32db --- /dev/null +++ b/.github/workflows/nim_nwaku_pr.yml @@ -0,0 +1,27 @@ +name: Nim -> Nim Waku Interop Tests + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: false + +on: + schedule: + - cron: '0 5 * * *' + workflow_dispatch: + +jobs: + + build-docker-image: + needs: changes + uses: waku-org/nwaku/.github/workflows/container-image.yml@master + secrets: inherit + + test-common: + needs: build-docker-image + uses: ./.github/workflows/test_common.yml + secrets: inherit + with: + node1: ${{ needs.build-docker-image.outputs.image }} + node2: ${{ needs.build-docker-image.outputs.image }} + additional_nodes: ${{ needs.build-docker-image.outputs.image }} + caller: "nim"