From 8cc2e7edb54b01055466d00e0bd6dcfc61df2e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Thu, 4 Feb 2021 12:36:33 +0100 Subject: [PATCH 01/10] Create GH Actions workflow for build&test of Go client 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 creates a GitHub Action workfow for building and testing Go client. --- .github/workflows/client.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/client.yml diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml new file mode 100644 index 0000000000..ebc9ccb1cf --- /dev/null +++ b/.github/workflows/client.yml @@ -0,0 +1,30 @@ +name: Go + +#TODO: extend the conditions once workflow gets tested together with other workflows +on: [push, pull_request] + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: satackey/action-docker-layer-caching@v0.0.11 + continue-on-error: true # ignore the failure of a step and avoid terminating the job + - name: Create test results directory + run: | + mkdir -p /tmp/test-results/keep-core-go + - name: Run Docker build + run: | + docker build --target gobuild --tag go-build-env . + docker build --tag keep-client . + - name: Run Go tests + run: | + docker run --volume /tmp/test-results/keep-core-go:/mnt/test-results --workdir /go/src/github.com/keep-network/keep-core go-build-env gotestsum --junitfile /mnt/test-results/unit-tests.xml + docker run --volume /tmp/test-results/keep-core-go:/mnt/test-results --workdir /go/src/github.com/keep-network/keep-core go-build-env cat /mnt/test-results/unit-tests.xml > ./unit-tests.xml + - name: Publish Unit Test results + uses: EnricoMi/publish-unit-test-result-action@v1.7 + if: always() # guarantees that this action always runs, even if earlier steps fail + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + files: unit-tests.xml + check_name: Go Test Results # name under which test results will be presented in GitHub (optional) \ No newline at end of file From ab6fdea1363fd9ecce396bf5aeddea334bdd2068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Mon, 8 Feb 2021 16:10:27 +0100 Subject: [PATCH 02/10] Change in a way of accessing tests results, improved readability In order to improve workflow readability, notation of docker commands has been modified (long commands have been split to multiple lines). Also a way to access file containing unit tests results has been simplified (EnricoMi/publish-unit-test-result-action@v1.7 action requires access to file via a relative path). --- .github/workflows/client.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index ebc9ccb1cf..d412743eb1 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -10,17 +10,24 @@ jobs: - uses: actions/checkout@v1 - uses: satackey/action-docker-layer-caching@v0.0.11 continue-on-error: true # ignore the failure of a step and avoid terminating the job - - name: Create test results directory - run: | - mkdir -p /tmp/test-results/keep-core-go - name: Run Docker build run: | - docker build --target gobuild --tag go-build-env . - docker build --tag keep-client . + docker build \ + --target gobuild \ + --tag go-build-env . + docker build \ + --tag keep-client . + - name: Create and enter test results directory + run: | + mkdir -p /tmp/test-results/keep-core-go + cd /tmp/test-results/keep-core-go/ - name: Run Go tests run: | - docker run --volume /tmp/test-results/keep-core-go:/mnt/test-results --workdir /go/src/github.com/keep-network/keep-core go-build-env gotestsum --junitfile /mnt/test-results/unit-tests.xml - docker run --volume /tmp/test-results/keep-core-go:/mnt/test-results --workdir /go/src/github.com/keep-network/keep-core go-build-env cat /mnt/test-results/unit-tests.xml > ./unit-tests.xml + docker run \ + --volume /tmp/test-results/keep-core-go:/mnt/test-results \ + --workdir /go/src/github.com/keep-network/keep-core \ + go-build-env \ + gotestsum --junitfile /mnt/test-results/unit-tests.xml - name: Publish Unit Test results uses: EnricoMi/publish-unit-test-result-action@v1.7 if: always() # guarantees that this action always runs, even if earlier steps fail From e59dfd9c114bce141db0058cdccd7e872fe4cb9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Mon, 8 Feb 2021 17:09:08 +0100 Subject: [PATCH 03/10] Modified conditions for workflow kick-off Previous conditions for workflow kick-off [push, pull-request] were causing start of two simultaneous workflows when new commit was pushed to an already open pull request. After the change such situation should start only one workflow. --- .github/workflows/client.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index d412743eb1..bcd8b15604 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -1,7 +1,11 @@ name: Go #TODO: extend the conditions once workflow gets tested together with other workflows -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: jobs: build-and-test: From 5affb7869d131f8b5a06d046c375c5b3c5f30d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Mon, 8 Feb 2021 18:05:17 +0100 Subject: [PATCH 04/10] Added possibility to trigger workflow manually Each workflow should be malually triggerable and should trigger its downstream dependencies. This commit adresses the first part of that statement. Triggering of downstream dependencies is not yet developed, as downstream workflows aren't yet created. --- .github/workflows/client.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index bcd8b15604..816580f7a1 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -6,6 +6,7 @@ on: branches: - master pull_request: + workflow_dispatch: jobs: build-and-test: @@ -25,6 +26,18 @@ jobs: run: | mkdir -p /tmp/test-results/keep-core-go cd /tmp/test-results/keep-core-go/ + - name: DEBUG + run: | + pwd + - name: DEBUG + run: | + ls + - name: DEBUG + run: | + ls /tmp/test-results/keep-core-go/ + - name: DEBUG + run: | + ls /home/runner/work/keep-core/keep-core - name: Run Go tests run: | docker run \ @@ -32,6 +45,18 @@ jobs: --workdir /go/src/github.com/keep-network/keep-core \ go-build-env \ gotestsum --junitfile /mnt/test-results/unit-tests.xml + - name: DEBUG + run: | + pwd + - name: DEBUG + run: | + ls + - name: DEBUG + run: | + ls /tmp/test-results/keep-core-go/ + - name: DEBUG + run: | + ls /home/runner/work/keep-core/keep-core - name: Publish Unit Test results uses: EnricoMi/publish-unit-test-result-action@v1.7 if: always() # guarantees that this action always runs, even if earlier steps fail From 372333d204bd6dad0d38219822cad169d2b41f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 9 Feb 2021 11:42:41 +0100 Subject: [PATCH 05/10] Turned off publishing of test results in PR comments In order not to flood the PRs with lot of comments, publishing of test results to PR comments has been turned off. Results can be sill viewed by going to Checks tab. Commit also includes changes in the way test results are accessed (now GITHUB_WORKSPACE env variable is utilized). --- .github/workflows/client.yml | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 816580f7a1..48a007e552 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -24,43 +24,19 @@ jobs: --tag keep-client . - name: Create and enter test results directory run: | - mkdir -p /tmp/test-results/keep-core-go - cd /tmp/test-results/keep-core-go/ - - name: DEBUG - run: | - pwd - - name: DEBUG - run: | - ls - - name: DEBUG - run: | - ls /tmp/test-results/keep-core-go/ - - name: DEBUG - run: | - ls /home/runner/work/keep-core/keep-core + mkdir -p $GITHUB_WORKSPACE/test-results/ - name: Run Go tests run: | docker run \ - --volume /tmp/test-results/keep-core-go:/mnt/test-results \ + --volume $GITHUB_WORKSPACE/test-results:/mnt/test-results \ --workdir /go/src/github.com/keep-network/keep-core \ go-build-env \ gotestsum --junitfile /mnt/test-results/unit-tests.xml - - name: DEBUG - run: | - pwd - - name: DEBUG - run: | - ls - - name: DEBUG - run: | - ls /tmp/test-results/keep-core-go/ - - name: DEBUG - run: | - ls /home/runner/work/keep-core/keep-core - name: Publish Unit Test results uses: EnricoMi/publish-unit-test-result-action@v1.7 if: always() # guarantees that this action always runs, even if earlier steps fail with: github_token: ${{ secrets.GITHUB_TOKEN }} - files: unit-tests.xml - check_name: Go Test Results # name under which test results will be presented in GitHub (optional) \ No newline at end of file + 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 \ No newline at end of file From a368ae665eff4fffe88e21c079856bd8c0b2cbdd Mon Sep 17 00:00:00 2001 From: michalinacienciala <78352137+michalinacienciala@users.noreply.github.com> Date: Tue, 9 Feb 2021 16:22:14 +0100 Subject: [PATCH 06/10] Modified incorrect naming of a step Name of the step was incorrect - we do not enter the directory as part of the step. Co-authored-by: Jakub Nowakowski --- .github/workflows/client.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 48a007e552..081dedba2e 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -22,7 +22,7 @@ jobs: --tag go-build-env . docker build \ --tag keep-client . - - name: Create and enter test results directory + - name: Create test results directory run: | mkdir -p $GITHUB_WORKSPACE/test-results/ - name: Run Go tests @@ -39,4 +39,4 @@ jobs: 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 \ No newline at end of file + comment_on_pr: false # turns off commenting on Pull Requests From c41fb94823c3cb1ea1a9586ebdabb552b2f3ac4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 9 Feb 2021 17:03:04 +0100 Subject: [PATCH 07/10] Temporary change to test reporting of test failures Change introduced to deliberatly make the tests fail. Will be reverted soon. --- .github/workflows/client.yml | 1 + pkg/beacon/beacon_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 081dedba2e..277fbfecd0 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -40,3 +40,4 @@ jobs: 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 + # temporary comment diff --git a/pkg/beacon/beacon_test.go b/pkg/beacon/beacon_test.go index 14a32ac62b..293055d5f6 100644 --- a/pkg/beacon/beacon_test.go +++ b/pkg/beacon/beacon_test.go @@ -17,6 +17,7 @@ const ( ) func TestConfirmRelayRequestOnFirstAttempt(t *testing.T) { + t.Fatalf("TEST ERROR") expectedRequestStartBlock := 1888 onConfirmedExecuted := false onConfirmed := func() { From 1947d44ba2c850c7db55f1e73bc97b0e1891903d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 9 Feb 2021 18:20:23 +0100 Subject: [PATCH 08/10] Revert "Temporary change to test reporting of test failures" This reverts commit c41fb94823c3cb1ea1a9586ebdabb552b2f3ac4c. --- .github/workflows/client.yml | 1 - pkg/beacon/beacon_test.go | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 277fbfecd0..081dedba2e 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -40,4 +40,3 @@ jobs: 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 - # temporary comment diff --git a/pkg/beacon/beacon_test.go b/pkg/beacon/beacon_test.go index 293055d5f6..14a32ac62b 100644 --- a/pkg/beacon/beacon_test.go +++ b/pkg/beacon/beacon_test.go @@ -17,7 +17,6 @@ const ( ) func TestConfirmRelayRequestOnFirstAttempt(t *testing.T) { - t.Fatalf("TEST ERROR") expectedRequestStartBlock := 1888 onConfirmedExecuted := false onConfirmed := func() { From 0504b8cbd20f6815587835c1d6f987bb3889daf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Wed, 10 Feb 2021 08:49:09 +0100 Subject: [PATCH 09/10] Simplified creation of test results directory Command run in the step creating test results directory has been simplified. There is no need to use GITHUB_WORKSPACE env variable here as commands executed via 'run' keyword are executed in that location by default. --- .github/workflows/client.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 081dedba2e..a10ea09c23 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -24,7 +24,7 @@ jobs: --tag keep-client . - name: Create test results directory run: | - mkdir -p $GITHUB_WORKSPACE/test-results/ + mkdir test-results - name: Run Go tests run: | docker run \ @@ -32,7 +32,7 @@ jobs: --workdir /go/src/github.com/keep-network/keep-core \ go-build-env \ gotestsum --junitfile /mnt/test-results/unit-tests.xml - - name: Publish Unit Test results + - name: Publish unit test results uses: EnricoMi/publish-unit-test-result-action@v1.7 if: always() # guarantees that this action always runs, even if earlier steps fail with: From 8b9bd59c51fdaa30cabc045c9bd5e0e4bc72a4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Wed, 10 Feb 2021 13:53:55 +0100 Subject: [PATCH 10/10] Highlighting piece of code covered by GitHub Actions workflow Added comment highlighting piece of CircleCI config code for which a GitHub Actions workflow has been already created (as part of work on RFC-18 that requires migration of build processes from CircleCI to GitHub Actions). --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 15b89b3bb6..b5f0b10b2d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -36,6 +36,7 @@ jobs: root: /tmp/docs paths: - solidity/* + # GitHub Actions equivalent of this job (.github/workflows/client.yml) has been created as part of work on RFC-18 build_client_and_test_go: executor: docker-git steps: