From 6456367c4562193364fdd7ae55b8b8e37b6a9d7e Mon Sep 17 00:00:00 2001 From: Dhiraj Bokde Date: Fri, 26 Jan 2024 19:20:46 -0800 Subject: [PATCH] fix: update image build and push to handle tags, fixes RHOAIENG-2300 (#276) * chore: rename directory doc to docs * fix: update image build and push to handle tags, fixes RHOAIENG-2300 * fix: fix links to docs --- .github/workflows/build-and-push-image.yml | 71 ++++++++++++++++++ .github/workflows/build-image-main.yml | 53 ------------- CONTRIBUTING.md | 4 +- README.md | 4 +- .../Model Registry Testing areas.drawio | 0 .../Model Registry Testing areas.png | Bin .../Screenshot 2023-11-29 at 14.08.12.png | Bin .../Screenshot 2023-11-29 at 14.10.14.png | Bin {doc => docs}/mr_go_library.md | 0 ...emote_only_packaging_of_MLMD_Python_lib.md | 0 10 files changed, 75 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/build-and-push-image.yml delete mode 100644 .github/workflows/build-image-main.yml rename {doc => docs}/Model Registry Testing areas.drawio (100%) rename {doc => docs}/Model Registry Testing areas.png (100%) rename {doc => docs}/Screenshot 2023-11-29 at 14.08.12.png (100%) rename {doc => docs}/Screenshot 2023-11-29 at 14.10.14.png (100%) rename {doc => docs}/mr_go_library.md (100%) rename {doc => docs}/remote_only_packaging_of_MLMD_Python_lib.md (100%) diff --git a/.github/workflows/build-and-push-image.yml b/.github/workflows/build-and-push-image.yml new file mode 100644 index 000000000..0648b3e88 --- /dev/null +++ b/.github/workflows/build-and-push-image.yml @@ -0,0 +1,71 @@ +name: Container image build and tag + +on: + push: + branches: + - 'main' + tags: + - 'v*' + paths-ignore: + - 'LICENSE*' + - '**.gitignore' + - '**.md' + - '**.txt' + - '.github/ISSUE_TEMPLATE/**' + - '.github/dependabot.yml' + - 'docs/**' + +env: + QUAY_ORG: opendatahub + QUAY_IMG_REPO: model-registry + QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} + QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + PUSH_IMAGE: true + +jobs: + build-image: + runs-on: ubuntu-latest + steps: + # Assign context variable for various action contexts (tag, main, CI) + - name: Assigning tag context + if: github.head_ref == '' && startsWith(github.ref, 'refs/tags/v') + run: echo "BUILD_CONTEXT=tag" >> $GITHUB_ENV + - name: Assigning main context + if: github.head_ref == '' && github.ref == 'refs/heads/main' + run: echo "BUILD_CONTEXT=main" >> $GITHUB_ENV + # checkout branch + - uses: actions/checkout@v4 + # set image version + - name: Set main-branch environment + if: env.BUILD_CONTEXT == 'main' + run: | + commit_sha=${{ github.event.after }} + tag=main-${commit_sha:0:7} + echo "VERSION=${tag}" >> $GITHUB_ENV + - name: Set tag environment + if: env.BUILD_CONTEXT == 'tag' + run: | + echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV + - name: Build and Push Image + shell: bash + run: ./scripts/build_deploy.sh + - name: Tag Latest + if: env.BUILD_CONTEXT == 'main' + shell: bash + env: + IMG: quay.io/${{ env.QUAY_ORG }}/${{ env.QUAY_IMG_REPO }} + BUILD_IMAGE: false + run: | + docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:latest + # BUILD_IMAGE=false skip the build + ./scripts/build_deploy.sh + - name: Tag Main + if: env.BUILD_CONTEXT == 'main' + shell: bash + env: + IMG: quay.io/${{ env.QUAY_ORG }}/${{ env.QUAY_IMG_REPO }} + BUILD_IMAGE: false + run: | + docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:main + # BUILD_IMAGE=false skip the build + ./scripts/build_deploy.sh diff --git a/.github/workflows/build-image-main.yml b/.github/workflows/build-image-main.yml deleted file mode 100644 index dcf443692..000000000 --- a/.github/workflows/build-image-main.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Main container image build and tag - -on: - push: - branches: - - 'main' - -env: - QUAY_ORG: opendatahub - QUAY_IMG_REPO: model-registry - QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} - QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} - PUSH_IMAGE: true - -jobs: - build-image: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Generate Tag - shell: bash - id: tags - run: | - commit_sha=${{ github.event.after }} - tag=main-${commit_sha:0:7} - echo "tag=${tag}" >> $GITHUB_OUTPUT - - name: Build and Push Image - shell: bash - env: - VERSION: ${{ steps.tags.outputs.tag }} - run: ./scripts/build_deploy.sh - - name: Tag Latest - shell: bash - env: - IMG: quay.io/${{ env.QUAY_ORG }}/${{ env.QUAY_IMG_REPO }} - BUILD_IMAGE: false - NEWEST_TAG: ${{ steps.tags.outputs.tag }} - VERSION: latest - run: | - docker tag ${{ env.IMG }}:${{ env.NEWEST_TAG }} ${{ env.IMG }}:${{ env.VERSION }} - # BUILD_IMAGE=false skip the build - ./scripts/build_deploy.sh - - name: Tag Main - shell: bash - env: - IMG: quay.io/${{ env.QUAY_ORG }}/${{ env.QUAY_IMG_REPO }} - BUILD_IMAGE: false - NEWEST_TAG: ${{ steps.tags.outputs.tag }} - VERSION: main - run: | - docker tag ${{ env.IMG }}:${{ env.NEWEST_TAG }} ${{ env.IMG }}:${{ env.VERSION }} - # BUILD_IMAGE=false skip the build - ./scripts/build_deploy.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index faab737af..f7caf3eb0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -170,11 +170,11 @@ As all the wheels are x86 specific: https://pypi.org/project/ml-metadata/1.14.0/ So it's not even possible to receive code assists. However, after clicking to re-open the project inside an (emulated) DevContainer: -![](doc/Screenshot%202023-11-29%20at%2014.08.12.png) +![](docs/Screenshot%202023-11-29%20at%2014.08.12.png) Then with the given setup MLMD is already installed inside the DevContainer: -![](doc/Screenshot%202023-11-29%20at%2014.10.14.png) +![](docs/Screenshot%202023-11-29%20at%2014.10.14.png) At this point Poetry is already installed as well and can be used to build and run test of the Model Registry Python client. diff --git a/README.md b/README.md index 65006b63f..275c03487 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ It provides a model registry domain-specific [api](internal/core/api.go) that is ### Model registry library -For more background on Model Registry Go core library and instructions on using it, please check [getting started guide](./doc/mr_go_library.md). +For more background on Model Registry Go core library and instructions on using it, please check [getting started guide](./docs/mr_go_library.md). ## Development @@ -114,7 +114,7 @@ When shutting down the docker compose, you might want to clean-up the SQLite db The following diagram illustrate testing strategy for the several components in Model Registry project: -![](/doc/Model%20Registry%20Testing%20areas.png) +![](/docs/Model%20Registry%20Testing%20areas.png) Go layers components are tested with Unit Tests written in Go, as well as Integration Tests leveraging Testcontainers. This allows to verify the expected "Core layer" of logical data mapping developed implemented in Go, matches technical expectations. diff --git a/doc/Model Registry Testing areas.drawio b/docs/Model Registry Testing areas.drawio similarity index 100% rename from doc/Model Registry Testing areas.drawio rename to docs/Model Registry Testing areas.drawio diff --git a/doc/Model Registry Testing areas.png b/docs/Model Registry Testing areas.png similarity index 100% rename from doc/Model Registry Testing areas.png rename to docs/Model Registry Testing areas.png diff --git a/doc/Screenshot 2023-11-29 at 14.08.12.png b/docs/Screenshot 2023-11-29 at 14.08.12.png similarity index 100% rename from doc/Screenshot 2023-11-29 at 14.08.12.png rename to docs/Screenshot 2023-11-29 at 14.08.12.png diff --git a/doc/Screenshot 2023-11-29 at 14.10.14.png b/docs/Screenshot 2023-11-29 at 14.10.14.png similarity index 100% rename from doc/Screenshot 2023-11-29 at 14.10.14.png rename to docs/Screenshot 2023-11-29 at 14.10.14.png diff --git a/doc/mr_go_library.md b/docs/mr_go_library.md similarity index 100% rename from doc/mr_go_library.md rename to docs/mr_go_library.md diff --git a/doc/remote_only_packaging_of_MLMD_Python_lib.md b/docs/remote_only_packaging_of_MLMD_Python_lib.md similarity index 100% rename from doc/remote_only_packaging_of_MLMD_Python_lib.md rename to docs/remote_only_packaging_of_MLMD_Python_lib.md