From 8535ab797eb3cae175de3370e121389bab166b09 Mon Sep 17 00:00:00 2001 From: youben11 Date: Thu, 7 Oct 2021 12:57:59 +0100 Subject: [PATCH] ci: compatibility check workflows concretelib/llvm --- .../workflows/concrete-lib-compatibility.yml | 73 +++++++++++++++++++ .github/workflows/llvm-compatibility.yml | 47 ++++++++++++ .../scripts/container_timestamp_check.sh | 67 +++++++++++++++++ 3 files changed, 187 insertions(+) create mode 100644 .github/workflows/concrete-lib-compatibility.yml create mode 100644 .github/workflows/llvm-compatibility.yml create mode 100755 .github/workflows/scripts/container_timestamp_check.sh diff --git a/.github/workflows/concrete-lib-compatibility.yml b/.github/workflows/concrete-lib-compatibility.yml new file mode 100644 index 000000000..4c93ff489 --- /dev/null +++ b/.github/workflows/concrete-lib-compatibility.yml @@ -0,0 +1,73 @@ +name: Concrete-lib Compatibility + +on: + workflow_dispatch: + schedule: + - cron: '0 00 * * 1-5' # Everyday @ 00:00 from Monday to Friday + +jobs: + build_publish: + name: Test the Docker image with latest concrete-ffi + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Compare image timestamps + continue-on-error: true + run: | + ./.github/workflows/scripts/container_timestamp_check.sh \ + --base_img_url \ + https://api.github.com/orgs/zama-ai/packages/container/concrete-api-env/versions \ + --env_img_url \ + https://api.github.com/orgs/zama-ai/packages/container/zamalang-compiler/versions \ + --token ${{ secrets.BOT_TOKEN }} + + - name: Send Slack Notification + if: ${{ failure() }} + continue-on-error: true + uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 + env: + SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} + SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png + SLACK_COLOR: success + SLACK_MESSAGE: "No new update on Concrete-FFI, skipping compatibility check" + SLACK_USERNAME: ${{ secrets.BOT_USERNAME }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + + - name: Get the concrete CAPI release + if: ${{ success() }} + uses: addnab/docker-run-action@v3 + with: + registry: ghcr.io + image: ghcr.io/zama-ai/concrete-api-env:latest + username: ${{ secrets.GHCR_LOGIN }} + password: ${{ secrets.GHCR_PASSWORD }} + options: -v ${{ github.workspace }}:/workspace + run: mkdir -p /workspace/concrete/target && cp -r /target/release /workspace/concrete/target + + - name: Test compiler with latest concrete-ffi + if: ${{ success() }} + uses: addnab/docker-run-action@v3 + with: + image: ghcr.io/zama-ai/zamalang-compiler + options: -v /workspace/concrete:/concrete + run: | + cd /compiler + pip install pytest + export CONCRETE_PROJECT=/concrete + make -B BUILD_DIR=/build build + make BUILD_DIR=/build test + + - name: Send Slack Notification + if: ${{ always() }} + continue-on-error: true + uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 + env: + SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} + SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png + SLACK_COLOR: ${{ job.status }} + SLACK_MESSAGE: "Compatibility check with Concrete-FFI finished with status ${{ job.status }} \ + (${{ env.ACTION_RUN_URL }})" + SLACK_USERNAME: ${{ secrets.BOT_USERNAME }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} diff --git a/.github/workflows/llvm-compatibility.yml b/.github/workflows/llvm-compatibility.yml new file mode 100644 index 000000000..912e956fd --- /dev/null +++ b/.github/workflows/llvm-compatibility.yml @@ -0,0 +1,47 @@ +name: LLVM Compatibility + +on: + workflow_dispatch: + schedule: + - cron: '0 00 * * 1-5' # Everyday @ 00:00 from Monday to Friday + +jobs: + build_test: + name: Build & test the Docker image with latest LLVM + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Update LLVM + run: git submodule update --remote + + - name: Log LLVM commit + run: echo "LLVM commit" && cd ${{ github.workspace }}/llvm-project && git log -1 + + - name: Build + run: docker image build --no-cache -t compiler-latest-llvm -f builders/Dockerfile.zamalang-env . + + - name: Test compiler with latest LLVM + uses: addnab/docker-run-action@v3 + with: + image: compiler-latest-llvm + run: | + cd /compiler + pip install pytest + make BUILD_DIR=/build test + + - name: Send Slack Notification + if: ${{ always() }} + continue-on-error: true + uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 + env: + SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} + SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png + SLACK_COLOR: ${{ job.status }} + SLACK_MESSAGE: "Compatibility check with latest LLVM finished with status ${{ job.status }} \ + (${{ env.ACTION_RUN_URL }})" + SLACK_USERNAME: ${{ secrets.BOT_USERNAME }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} diff --git a/.github/workflows/scripts/container_timestamp_check.sh b/.github/workflows/scripts/container_timestamp_check.sh new file mode 100755 index 000000000..45c1dc69c --- /dev/null +++ b/.github/workflows/scripts/container_timestamp_check.sh @@ -0,0 +1,67 @@ +#!/bin/bash -e + +set -e + +BASE_IMG_ENDPOINT_URL= +ENV_IMG_ENDPOINT_URL= +TOKEN= + +while [ -n "$1" ] +do + case "$1" in + "--base_img_url" ) + shift + BASE_IMG_ENDPOINT_URL="$1" + ;; + + "--env_img_url" ) + shift + ENV_IMG_ENDPOINT_URL="$1" + ;; + + "--token" ) + shift + TOKEN="$1" + ;; + + *) + echo "Unknown param : $1" + exit 1 + ;; + esac + shift +done + +BASE_JSON=$(curl \ +-X GET \ +-H "Accept: application/vnd.github.v3+json" \ +-H "Authorization: token ${TOKEN}" \ +"${BASE_IMG_ENDPOINT_URL}") + +BASE_IMG_TIMESTAMP=$(echo "${BASE_JSON}" | jq -r 'sort_by(.updated_at)[-1].updated_at') + +ENV_JSON=$(curl \ +-X GET \ +-H "Accept: application/vnd.github.v3+json" \ +-H "Authorization: token ${TOKEN}" \ +"${ENV_IMG_ENDPOINT_URL}") + +ENV_IMG_TIMESTAMP=$(echo "${ENV_JSON}" | \ +jq -rc '.[] | select(.metadata.container.tags[] | contains("latest")).updated_at') + +echo "Base timestamp: ${BASE_IMG_TIMESTAMP}" +echo "Env timestamp: ${ENV_IMG_TIMESTAMP}" + +BASE_IMG_DATE=$(date -d "${BASE_IMG_TIMESTAMP}" +%s) +ENV_IMG_DATE=$(date -d "${ENV_IMG_TIMESTAMP}" +%s) + +echo "Base epoch: ${BASE_IMG_DATE}" +echo "Env epoch: ${ENV_IMG_DATE}" + +if [[ "${BASE_IMG_DATE}" -ge "${ENV_IMG_DATE}" ]]; then + echo "Env image out of date, sending rebuild request." + exit 0 +else + echo "Image up to date, nothing to do." + exit 1 +fi