From 9d3e01b564a108ec166592198b55fc80d30f3999 Mon Sep 17 00:00:00 2001
From: Robert Pirtle <astropirtle@gmail.com>
Date: Wed, 8 Nov 2023 12:52:30 -0800
Subject: [PATCH] prep test of docker image tags

---
 .github/workflows/ci-docker.yml  | 146 +++++++++++++++++--------------
 .github/workflows/ci-master.yml  |   1 +
 .github/workflows/ci-testing.yml |  86 +++++-------------
 3 files changed, 103 insertions(+), 130 deletions(-)

diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml
index 1e4c4d1999..b4275068cf 100644
--- a/.github/workflows/ci-docker.yml
+++ b/.github/workflows/ci-docker.yml
@@ -6,6 +6,15 @@ on:
       dockerhub-username:
         required: true
         type: string
+      # this workflow publishes a rocksdb & goleveldb docker image.
+      # it publishes the following tags:
+      # - <commit-hash>-goleveldb
+      # - <extra-image-tag>-goleveldb
+      # - <commit-hash>-rocksdb
+      # - <extra-image-tag>-rocksdb
+      extra-image-tag:
+        required: true
+        type: string
     secrets:
       CI_DOCKERHUB_TOKEN:
         required: true
@@ -14,81 +23,88 @@ on:
 # you can use images built by this action in future jobs.
 # https://docs.docker.com/build/ci/github-actions/examples/#share-built-image-between-jobs
 jobs:
-  docker-goleveldb:
-    # https://github.com/marketplace/actions/build-and-push-docker-images
+  test-image-tag:
     runs-on: ubuntu-latest
     steps:
-      # ensure working with latest code
-      - name: Checkout
-        uses: actions/checkout@v4
+      - name: Output tag we would deploy
+        env:
+          IMAGE_TAGS: kava/kava:${{ steps.commit-hash.outputs.short }}-goleveldb,kava/kava:${{ inputs.extra-image-tag }}-goleveldb
+        run: echo $IMAGE_TAGS
+  # docker-goleveldb:
+  #   # https://github.com/marketplace/actions/build-and-push-docker-images
+  #   runs-on: ubuntu-latest
+  #   steps:
+  #     # ensure working with latest code
+  #     - name: Checkout
+  #       uses: actions/checkout@v4
 
-      # generate a git commit hash to be used as image tag
-      - name: Generate short hash
-        id: commit-hash
-        run: echo "short=$( git rev-parse --short $GITHUB_SHA )" >> $GITHUB_OUTPUT
+  #     # generate a git commit hash to be used as image tag
+  #     - name: Generate short hash
+  #       id: commit-hash
+  #       run: echo "short=$( git rev-parse --short $GITHUB_SHA )" >> $GITHUB_OUTPUT
 
-      # qemu is used to emulate different platform architectures
-      - name: Set up QEMU
-        uses: docker/setup-qemu-action@v3
+  #     # qemu is used to emulate different platform architectures
+  #     - name: Set up QEMU
+  #       uses: docker/setup-qemu-action@v3
 
-      # cross-platform build of the image
-      - name: Set up Docker Buildx
-        uses: docker/setup-buildx-action@v3
+  #     # cross-platform build of the image
+  #     - name: Set up Docker Buildx
+  #       uses: docker/setup-buildx-action@v3
 
-      # authenticate for publish to docker hub
-      - name: Login to Docker Hub
-        uses: docker/login-action@v3
-        with:
-          username: ${{ inputs.dockerhub-username }}
-          password: ${{ secrets.CI_DOCKERHUB_TOKEN }}
+  #     # authenticate for publish to docker hub
+  #     - name: Login to Docker Hub
+  #       uses: docker/login-action@v3
+  #       with:
+  #         username: ${{ inputs.dockerhub-username }}
+  #         password: ${{ secrets.CI_DOCKERHUB_TOKEN }}
 
-      # publish to docker hub, tag with short git hash
-      - name: Build and push (goleveldb)
-        uses: docker/build-push-action@v5
-        with:
-          context: .
-          cache-from: type=gha
-          cache-to: type=gha,mode=max
-          platforms: linux/amd64,linux/arm64
-          push: true
-          tags: kava/kava:${{ steps.commit-hash.outputs.short }}-goleveldb,kava/kava:master-goleveldb
+  #     # publish to docker hub, tag with short git hash
+  #     - name: Build and push (goleveldb)
+  #       uses: docker/build-push-action@v5
+  #       with:
+  #         context: .
+  #         cache-from: type=gha
+  #         cache-to: type=gha,mode=max
+  #         platforms: linux/amd64,linux/arm64
+  #         push: true
+  #         tags: kava/kava:${{ steps.commit-hash.outputs.short }}-goleveldb,kava/kava:master-goleveldb
 
-  docker-rocksdb:
-    # https://github.com/marketplace/actions/build-and-push-docker-images
-    runs-on: ubuntu-latest
-    steps:
-      # ensure working with latest code
-      - name: Checkout
-        uses: actions/checkout@v4
+  # docker-rocksdb:
+  #   # https://github.com/marketplace/actions/build-and-push-docker-images
+  #   runs-on: ubuntu-latest
+  #   steps:
+  #     # ensure working with latest code
+  #     - name: Checkout
+  #       uses: actions/checkout@v4
 
-      # generate a git commit hash to be used as image tag
-      - name: Generate short hash
-        id: commit-hash
-        run: echo "short=$( git rev-parse --short $GITHUB_SHA )" >> $GITHUB_OUTPUT
+  #     # generate a git commit hash to be used as image tag
+  #     - name: Generate short hash
+  #       id: commit-hash
+  #       run: echo "short=$( git rev-parse --short $GITHUB_SHA )" >> $GITHUB_OUTPUT
 
-      # qemu is used to emulate different platform architectures
-      - name: Set up QEMU
-        uses: docker/setup-qemu-action@v3
+  #     # qemu is used to emulate different platform architectures
+  #     - name: Set up QEMU
+  #       uses: docker/setup-qemu-action@v3
 
-      # cross-platform build of the image
-      - name: Set up Docker Buildx
-        uses: docker/setup-buildx-action@v3
+  #     # cross-platform build of the image
+  #     - name: Set up Docker Buildx
+  #       uses: docker/setup-buildx-action@v3
 
-      # authenticate for publish to docker hub
-      - name: Login to Docker Hub
-        uses: docker/login-action@v3
-        with:
-          username: ${{ inputs.dockerhub-username }}
-          password: ${{ secrets.CI_DOCKERHUB_TOKEN }}
+  #     # authenticate for publish to docker hub
+  #     - name: Login to Docker Hub
+  #       uses: docker/login-action@v3
+  #       with:
+  #         username: ${{ inputs.dockerhub-username }}
+  #         password: ${{ secrets.CI_DOCKERHUB_TOKEN }}
 
-      # publish to docker hub, tag with short git hash
-      - name: Build and push (rocksdb)
-        uses: docker/build-push-action@v5
-        with:
-          context: .
-          file: Dockerfile-rocksdb
-          cache-from: type=gha
-          cache-to: type=gha,mode=max
-          platforms: linux/amd64,linux/arm64
-          push: true
-          tags: kava/kava:${{ steps.commit-hash.outputs.short }}-rocksdb,kava/kava:master-rocksdb
+  #     # publish to docker hub, tag with short git hash
+  #     - name: Build and push (rocksdb)
+  #       uses: docker/build-push-action@v5
+  #       with:
+  #         context: .
+  #         file: Dockerfile-rocksdb
+  #         cache-from: type=gha
+  #         cache-to: type=gha,mode=max
+  #         platforms: linux/amd64,linux/arm64
+  #         push: true
+  #         tags: kava/kava:${{ steps.commit-hash.outputs.short }}-rocksdb,kava/kava:master-rocksdb
diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml
index 0cdc0fa149..6aad87ce17 100644
--- a/.github/workflows/ci-master.yml
+++ b/.github/workflows/ci-master.yml
@@ -46,6 +46,7 @@ jobs:
     uses: ./.github/workflows/ci-docker.yml
     with:
       dockerhub-username: kavaops
+      extra-image-tag: master
     secrets: inherit
   post-pipeline-metrics:
     uses: ./.github/workflows/metric-pipeline.yml
diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml
index 4f47d62a57..047732efdf 100644
--- a/.github/workflows/ci-testing.yml
+++ b/.github/workflows/ci-testing.yml
@@ -4,70 +4,26 @@ on:
     branches:
       - rp-ci-updates
 jobs:
-  docker:
-    # https://github.com/marketplace/actions/build-and-push-docker-images
+  test-docker-master:
+    uses: ./.github/workflows/ci-docker.yml
+    with:
+      dockerhub-username: kavaops
+      extra-image-tag: master
+    secrets: inherit
+
+  get-git-tag:
     runs-on: ubuntu-latest
+    outputs:
+      git-tag: ${{ steps.git-tag.outputs.tag }}
     steps:
-      # ensure working with latest code
-      - name: Checkout
-        uses: actions/checkout@v4
-
-      # generate a git commit hash to be used as image tag
-      - name: Generate short hash
-        id: commit-hash
-        run: echo "short=$( git rev-parse --short $GITHUB_SHA )" >> $GITHUB_OUTPUT
-
-      # qemu is used to emulate different platform architectures
-      - name: Set up QEMU
-        uses: docker/setup-qemu-action@v3
-
-      # cross-platform build of the image
-      - name: Set up Docker Buildx
-        uses: docker/setup-buildx-action@v3
-
-      # authenticate for publish to docker hub
-      - name: Login to Docker Hub
-        uses: docker/login-action@v3
-        with:
-          username: kavaops # TODO set from inputs
-          password: ${{ secrets.CI_DOCKERHUB_TOKEN }}
-
-      # publish to docker hub, tag with short git hash
-      - name: Build and push (rocksdb)
-        uses: docker/build-push-action@v5
-        with:
-          context: .
-          file: Dockerfile-rocksdb
-          cache-from: type=gha
-          cache-to: type=gha,mode=max
-          platforms: linux/amd64,linux/arm64
-          push: false #TODO set to true
-          tags: kava/kava:${{ steps.commit-hash.outputs.short }}-rocksdb # TODO add master tag back in
-
-
-  # test:
-  #   runs-on: ubuntu-latest
-  #   steps:
-  #     - name: checkout repo from current commit
-  #       uses: actions/checkout@v4
-  #       with:
-  #         submodules: true
-
-  #     - name: Set up Go
-  #       uses: actions/setup-go@v4
-  #       with:
-  #         go-version-file: go.mod
-  #         cache-dependency-path: |
-  #           go.sum
-  #           tests/e2e/kvtool/go.sum
-
-  #     - name: Configure docker to use go build cache
-  #       uses: reproducible-containers/buildkit-cache-dance@v2.1.2
-  #       with:
-  #         cache-source: go-build-cache
-
-  #     - name: run unit tests
-  #       run: make test
-
-  #     - name: run e2e tests
-  #       run: make docker-build test-e2e
+      - id: git-tag
+        # TODO: change me to git command to find version tag
+        run: echo "tag=v0.25.0" >> $GITHUB_OUTPUT
+
+  test-docker-release:
+    needs: get-git-tag
+    uses: ./.github/workflows/ci-docker.yml
+    with:
+      dockerhub-username: kavaops
+      extra-image-tag: ${{ needs.get-git-tag.outputs.git-tag }}
+    secrets: inherit