From df6a37f84ae1467df662e61ed560e8052ff1af88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Wed, 3 Mar 2021 12:56:15 +0100 Subject: [PATCH 1/3] Move publishing of Go client to GH Actions As described in RFC-18, there is a need for a refactorization of Keep and tBTC release processes in order to reduce human involvment and make the processes faster and less error prone. A part of this task is migration from CircleCI jobs to GitHub Actions. This commit enhances the GitHub Action `client.yml` workflow with step that publishes built docker image to `keep-test` Google Container Registry. --- .circleci/config.yml | 2 ++ .github/workflows/client.yml | 36 +++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5a15ff50f..5c27bcf89 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -215,6 +215,8 @@ jobs: # Publish to npm. echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc npm publish --access=public + # GitHub Actions equivalent of this job (.github/workflows/client.yml) + # has been created as part of work on RFC-18 publish_client: executor: gcp-gcr/default steps: diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 63a249a46..d23a5afff 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -14,7 +14,7 @@ on: workflow_dispatch: jobs: - build-and-test: + build-test-publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -29,6 +29,7 @@ jobs: key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- + # TODO: This step was left here intentionally so we can track disk space # usage for a while. We were trying to fight problems with out of disk space # that happened due to the size of data restored from cache. The cache size @@ -43,7 +44,7 @@ jobs: target: gobuild tags: go-build-env build-args: | - # REVISION=${{ github.sha }} TODO: set revision only when we want to publish the image + REVISION=${{ github.sha }} # VERSION= ? TODO: Configure version, sample: 1.7.6 load: true # load image to local registry to use it in next steps cache-from: type=local,src=/tmp/.buildx-cache @@ -69,14 +70,27 @@ jobs: check_name: Go Test Results # name under which test results will be presented in GitHub (optional) comment_on_pr: false # turns off commenting on Pull Requests - # This step is executed after the tests as we want to configure it eventually - # as image publication step. - - name: Build Docker Runtime Image + - name: Login to Google Container Registry + if: | + startsWith(github.ref, 'refs/heads/releases/ropsten') + || startsWith(github.ref, 'refs/heads/rfc-18/ropsten') + uses: docker/login-action@v1 + with: + registry: ${{ secrets.GCR_REGISTRY_URL }} + username: _json_key + password: ${{ secrets.KEEP_TEST_GCR_JSON_KEY }} + + - name: Build and publish Docker Runtime Image uses: docker/build-push-action@v2 + env: + IMAGE_NAME: 'keep-ecdsa-wip' # TODO: change later to 'keep-ecdsa' + GOOGLE_PROJECT_ID: ${{ secrets.KEEP_TEST_GOOGLE_PROJECT_ID }} with: - tags: keep-ecdsa - labels: | - revision=${{ github.sha }} - # TODO: Check branch name and publish to a registry accordingly to the - # environment. - # push: true # publish to registry \ No newline at end of file + # GCR image should be named according to following convention: + # HOSTNAME/PROJECT-ID/IMAGE:TAG + # We don't use TAG yet, will be added at later stages of work on RFC-18. + tags: ${{ secrets.GCR_REGISTRY_URL }}/${{ env.GOOGLE_PROJECT_ID }}/${{ env.IMAGE_NAME }} + labels: revision=${{ github.sha }} + push: | + ${{ startsWith(github.ref, 'refs/heads/releases') + || startsWith(github.ref, 'refs/heads/rfc-18/ropsten') }} \ No newline at end of file From 9fe88148564f31778bfe592e05c9916de4347f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Thu, 4 Mar 2021 14:00:59 +0100 Subject: [PATCH 2/3] Moving REVISION and VERSION args to different Docker iamge As mentioned by @nkuba in https://github.com/keep-network/keep-ecdsa/pull/715#discussion_r587408720, we need `REVISION` and `VERSION` arguments to be configured not for the `go-build-env` image, but for the final image built in ` Build and publish Docker Runtime Image` step. --- .github/workflows/client.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index d23a5afff..ef00867d9 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -43,9 +43,6 @@ jobs: with: target: gobuild tags: go-build-env - build-args: | - REVISION=${{ github.sha }} - # VERSION= ? TODO: Configure version, sample: 1.7.6 load: true # load image to local registry to use it in next steps cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache @@ -91,6 +88,9 @@ jobs: # We don't use TAG yet, will be added at later stages of work on RFC-18. tags: ${{ secrets.GCR_REGISTRY_URL }}/${{ env.GOOGLE_PROJECT_ID }}/${{ env.IMAGE_NAME }} labels: revision=${{ github.sha }} + build-args: | + REVISION=${{ github.sha }} + # VERSION= ? TODO: Configure version, sample: 1.7.6 push: | ${{ startsWith(github.ref, 'refs/heads/releases') || startsWith(github.ref, 'refs/heads/rfc-18/ropsten') }} \ No newline at end of file From fc96d56419c2a1af2ad7ca85924986dd14ec80c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Thu, 4 Mar 2021 15:20:06 +0100 Subject: [PATCH 3/3] No longer use `publish-unit-test-result-action` We are no longer using EnricoMi/publish-unit-test-result-action for publishing of tests results, due to a known bug in the action, causing wrong association of tests results with workflows (https://github.com/EnricoMi/publish-unit-test-result-action/issues/12). Failing tests still will cause the job to be reported as failed. --- .github/workflows/client.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index ef00867d9..edb96e9b7 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -47,25 +47,12 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - - name: Create test results directory - run: mkdir test-results - - name: Run Go tests run: | docker run \ - --volume $GITHUB_WORKSPACE/test-results:/mnt/test-results \ --workdir /go/src/github.com/keep-network/keep-ecdsa \ go-build-env \ - gotestsum --junitfile /mnt/test-results/unit-tests.xml - - - name: Publish unit test results - uses: EnricoMi/publish-unit-test-result-action@v1 - if: always() - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - files: ./test-results/unit-tests.xml - check_name: Go Test Results # name under which test results will be presented in GitHub (optional) - comment_on_pr: false # turns off commenting on Pull Requests + gotestsum - name: Login to Google Container Registry if: |