From 94083a91fd69220caf51f7c25d9b0b734ab3b9c6 Mon Sep 17 00:00:00 2001 From: Omer Zuarets Date: Sun, 22 Sep 2024 12:04:55 +0300 Subject: [PATCH] fix PDP CI not being compatible with the vanilla PDP and not downloading the datasync on the tests job --- .github/workflows/pdp_cicd.yml | 14 ++++++ .github/workflows/pdp_cicd_manual.yml | 68 --------------------------- Dockerfile | 31 ++++++++++-- Makefile | 2 +- 4 files changed, 41 insertions(+), 74 deletions(-) delete mode 100644 .github/workflows/pdp_cicd_manual.yml diff --git a/.github/workflows/pdp_cicd.yml b/.github/workflows/pdp_cicd.yml index 85a74e01..3f6c6735 100644 --- a/.github/workflows/pdp_cicd.yml +++ b/.github/workflows/pdp_cicd.yml @@ -32,12 +32,22 @@ jobs: cd ./permit-opa find * -name '*go*' -print0 | xargs -0 tar -czf "$build_root"/custom/custom_opa.tar.gz --exclude '.*' + - uses: robinraju/release-downloader@v1 + with: + repository: permitio/datasync + latest: true + fileName: factstore_server* + token: ${{ secrets.CLONE_REPO_TOKEN }} + out-file-path: "datasync" + - name: Build and load image for PDP E2E tests uses: docker/build-push-action@v5 with: push: false load: true context: . + build-args: | + ALLOW_MISSING_FACTSTORE=false platforms: linux/amd64 tags: permitio/pdp-v2:test cache-from: type=gha @@ -164,6 +174,8 @@ jobs: push: true context: . platforms: linux/amd64,linux/arm64 + build-args: | + ALLOW_MISSING_FACTSTORE=false tags: permitio/pdp-v2:${{ github.event.release.tag_name }} cache-from: type=gha cache-to: type=gha,mode=max @@ -175,6 +187,8 @@ jobs: push: true context: . platforms: linux/amd64,linux/arm64 + build-args: | + ALLOW_MISSING_FACTSTORE=false tags: permitio/pdp-v2:${{ github.event.release.tag_name }},permitio/pdp-v2:latest cache-from: type=gha cache-to: type=gha,mode=max diff --git a/.github/workflows/pdp_cicd_manual.yml b/.github/workflows/pdp_cicd_manual.yml deleted file mode 100644 index 6d7cc8ff..00000000 --- a/.github/workflows/pdp_cicd_manual.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Build and Push PDP Docker Image Manually - -on: - workflow_dispatch: - inputs: - tag: - required: true - description: 'The tag for the image' - type: string - -jobs: - build-and-push-pdp: - runs-on: ubuntu-latest - env: - IMAGE_TAG: ${{ inputs.tag }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - uses: actions/checkout@v3 - with: - repository: permitio/permit-opa - ref: main - path: './permit-opa' - token: ${{ secrets.CLONE_REPO_TOKEN }} - - - name: Pre build PDP - run: | - echo "${IMAGE_TAG}" | cut -d '-' -f 1 > permit_pdp_version - rm -rf custom - mkdir custom - build_root="$PWD" - cd ./permit-opa - find * -name '*go*' -print0 | xargs -0 tar -czf "$build_root"/custom/custom_opa.tar.gz --exclude '.*' - if [[ "${IMAGE_TAG}" != *alpha* ]]; then - echo "Alpha version not detected, exiting..." - exit 1 - fi - - - uses: robinraju/release-downloader@v1 - with: - repository: permitio/datasync - latest: true - fileName: factstore_server* - token: ${{ secrets.CLONE_REPO_TOKEN }} - out-file-path: "datasync" - - - name: Build and push PDP image - (pre-release) - uses: docker/build-push-action@v5 - with: - push: true - context: . - platforms: linux/amd64,linux/arm64 - tags: permitio/pdp-v2:${{ inputs.tag }} - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index b547ba86..05261824 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ COPY horizon setup.py MANIFEST.in ./ RUN python setup.py install --user FROM golang:bullseye as BinariesBuildStage - +ARG ALLOW_MISSING_FACTSTORE=true COPY custom* /custom COPY datasync* /datasync @@ -52,18 +52,39 @@ RUN if [ -f /datasync/datasync.tar.gz ]; \ else \ case $(uname -m) in \ x86_64) \ - cp datasync/factstore_server-linux-amd64 /factstore \ + if [ -f /datasync/factstore_server-linux-amd64 ]; then \ + cp /datasync/factstore_server-linux-amd64 /factstore; \ + else \ + echo "factstore_server-linux-amd64 not found." ; \ + if [ "$ALLOW_MISSING_FACTSTORE" = "false" ]; then \ + echo "Missing Factstore is not allowed, exiting..."; exit 1; \ + else \ + echo "Missing Factstore is allowed, continuing..."; \ + touch /factstore ; \ + fi \ + fi \ ;; \ aarch64) \ - cp datasync/factstore_server-linux-arm64 /factstore \ + if [ -f /datasync/factstore_server-linux-arm64 ]; then \ + cp /datasync/factstore_server-linux-arm64 /factstore; \ + else \ + echo "factstore_server-linux-arm64 not found." ; \ + if [ "$ALLOW_MISSING_FACTSTORE" = "false" ]; then \ + echo "Missing Factstore is not allowed, exiting..."; exit 1; \ + else \ + echo "Missing Factstore is allowed, continuing..."; \ + touch /factstore ; \ + fi \ + fi \ ;; \ *) \ - echo "Unknown architecture." ; \ - exit 1 ; \ + echo "Unknown architecture." ; \ + exit 1 ; \ ;; \ esac ; \ fi + # MAIN IMAGE ---------------------------------------- # most of the time only this image should be built # --------------------------------------------------- diff --git a/Makefile b/Makefile index 4cf8e62b..6fff9191 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ build-amd64: prepare @docker buildx build --platform linux/amd64 -t permitio/pdp-v2:$(VERSION) . --load build-arm64: prepare - @docker buildx build --platform linux/arm64 -t permitio/pdp-v2:$(VERSION) . --load + @docker buildx build --build-arg ALLOW_MISSING_FACTSTORE=false --platform linux/arm64 -t permitio/pdp-v2:$(VERSION) . --load run: run-prepare @docker run -p 7766:7000 --env PDP_API_KEY=$(API_KEY) --env PDP_DEBUG=true permitio/pdp-v2:$(VERSION)