From a296948e960bbf72709362abc65493d0090cc276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Dan?= Date: Fri, 16 Jun 2023 15:00:04 -0400 Subject: [PATCH 1/6] test: trigger frontend e2e tests --- .github/workflows/docker_build_push.yml | 57 ++++++----------------- .github/workflows/docker_utils.yml | 62 +++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/docker_utils.yml diff --git a/.github/workflows/docker_build_push.yml b/.github/workflows/docker_build_push.yml index 8894fa9..3845878 100644 --- a/.github/workflows/docker_build_push.yml +++ b/.github/workflows/docker_build_push.yml @@ -8,54 +8,27 @@ on: types: [created] workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} jobs: docker: - name: Build and push docker image to GitHub Container Registry + uses: ./.github/workflows/docker_utils.yml + e2e: + needs: docker runs-on: ubuntu-latest-16-core steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Inject slug/short variables - uses: rlespinasse/github-slug-action@v4 - with: - short-length: 7 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=raw,value=test,enable={{is_default_branch}} - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - - name: Push to GitHub Container Registry - uses: docker/build-push-action@v3 + - uses: convictional/trigger-workflow-and-wait@v1.6.1 with: - context: . - push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: | - type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}:build-cache-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.workflow }} - type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}:build-cache-main-${{ github.workflow }} - cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}:build-cache-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.workflow }},mode=max + owner: topos-network + repo: e2e-tests + github_token: ${{ secrets.ROBOT_PAT_TRIGGER_E2E_WORKFLOWS }} + workflow_file_name: frontend:erc20-messaging.yml + ref: main + wait_interval: 60 + client_payload: '{ "topos-smart-contracts-docker-tag": "${{ needs.docker.outputs.tags }}" }' diff --git a/.github/workflows/docker_utils.yml b/.github/workflows/docker_utils.yml new file mode 100644 index 0000000..609c022 --- /dev/null +++ b/.github/workflows/docker_utils.yml @@ -0,0 +1,62 @@ +name: template - Docker + +on: + workflow_call: + outputs: + tags: + description: 'Docker tags' + value: ${{ jobs.docker.outputs.tags }} + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + docker: + name: Build and push docker image to GitHub Container Registry + runs-on: ubuntu-latest-16-core + outputs: + tags: ${{ steps.meta.outputs.tags }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v4 + with: + short-length: 7 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=raw,value=test,enable={{is_default_branch}} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Push to GitHub Container Registry + uses: docker/build-push-action@v3 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: | + type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}:build-cache-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.workflow }} + type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}:build-cache-main-${{ github.workflow }} + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}:build-cache-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.workflow }},mode=max From 7d0b9c22e05f9fb21b4f866d37ac0dc5b7e87d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Dan?= Date: Fri, 16 Jun 2023 15:04:55 -0400 Subject: [PATCH 2/6] chore: remove unecessary job name --- .github/workflows/docker_utils.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker_utils.yml b/.github/workflows/docker_utils.yml index 609c022..112b875 100644 --- a/.github/workflows/docker_utils.yml +++ b/.github/workflows/docker_utils.yml @@ -13,7 +13,6 @@ env: jobs: docker: - name: Build and push docker image to GitHub Container Registry runs-on: ubuntu-latest-16-core outputs: tags: ${{ steps.meta.outputs.tags }} From 9c2a8e5619343aa6808ccc52e817aa243005a1f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Dan?= Date: Fri, 16 Jun 2023 15:06:31 -0400 Subject: [PATCH 3/6] chore: rename util job --- .github/workflows/docker_utils.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_utils.yml b/.github/workflows/docker_utils.yml index 112b875..37dfa1a 100644 --- a/.github/workflows/docker_utils.yml +++ b/.github/workflows/docker_utils.yml @@ -12,7 +12,7 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - docker: + docker-build-push: runs-on: ubuntu-latest-16-core outputs: tags: ${{ steps.meta.outputs.tags }} From 19c2c7c3665410faf9ab5ab0cb0fbd20ebe91d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Dan?= Date: Fri, 16 Jun 2023 15:24:51 -0400 Subject: [PATCH 4/6] fix: revert the rename to get same job on both files --- .github/workflows/docker_utils.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_utils.yml b/.github/workflows/docker_utils.yml index 37dfa1a..112b875 100644 --- a/.github/workflows/docker_utils.yml +++ b/.github/workflows/docker_utils.yml @@ -12,7 +12,7 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - docker-build-push: + docker: runs-on: ubuntu-latest-16-core outputs: tags: ${{ steps.meta.outputs.tags }} From 9bea32d5a750d4b965afe948fa1ac068ba4f5a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Dan?= Date: Fri, 16 Jun 2023 15:30:21 -0400 Subject: [PATCH 5/6] fix: format docker tag --- .github/workflows/docker_build_push.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker_build_push.yml b/.github/workflows/docker_build_push.yml index 3845878..677e6a2 100644 --- a/.github/workflows/docker_build_push.yml +++ b/.github/workflows/docker_build_push.yml @@ -23,6 +23,13 @@ jobs: needs: docker runs-on: ubuntu-latest-16-core steps: + - name: Set environment + run: | + # It's fine to assume a single tag. Our tagging strategy follows a 1:1 mapping of image:tag + tags=${{ needs.docker.outputs.tags }} + echo "docker_tag=${tags#*:}" >> $GITHUB_ENV + shell: bash + - uses: convictional/trigger-workflow-and-wait@v1.6.1 with: owner: topos-network @@ -31,4 +38,4 @@ jobs: workflow_file_name: frontend:erc20-messaging.yml ref: main wait_interval: 60 - client_payload: '{ "topos-smart-contracts-docker-tag": "${{ needs.docker.outputs.tags }}" }' + client_payload: '{ "topos-smart-contracts-docker-tag": "${{ env.docker_tag }}" }' From 656ee62b2e6274d4155cd3ddb730097fb56d09ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Dan?= Date: Fri, 16 Jun 2023 16:12:43 -0400 Subject: [PATCH 6/6] chore: remove unused env var --- .github/workflows/docker_build_push.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/docker_build_push.yml b/.github/workflows/docker_build_push.yml index 677e6a2..86e7766 100644 --- a/.github/workflows/docker_build_push.yml +++ b/.github/workflows/docker_build_push.yml @@ -12,10 +12,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - jobs: docker: uses: ./.github/workflows/docker_utils.yml