From 23b7ed103aa29267a163bd203358c700e540a802 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Thu, 22 Jun 2023 15:53:37 +0200 Subject: [PATCH 01/17] add new test workflow --- .github/workflows/go-integration.yml | 73 ---------- .github/workflows/go.yml | 66 --------- .github/workflows/test.yml | 204 +++++++++++++++++++++++++++ .gitignore | 1 + makefile | 9 +- 5 files changed, 206 insertions(+), 147 deletions(-) delete mode 100644 .github/workflows/go-integration.yml delete mode 100644 .github/workflows/go.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/go-integration.yml b/.github/workflows/go-integration.yml deleted file mode 100644 index 9ddc2c254c3..00000000000 --- a/.github/workflows/go-integration.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Go End to End - -on: - push: - branches-ignore: - - master - pull_request: - branches-ignore: - - gh-pages - -jobs: - go-integration-tests: - if: github.repository_owner == 'armadaproject' - strategy: - fail-fast: false - matrix: - # WARN(JayF): If we begin attempting to support >1 golang version, - # we'll have to ensure that we don't use the same artifact name for - # both versions in the matrix -- this will lead to them overwriting - # each other. - go: [ '1.20' ] - # As of December 2022, using 8vcpu runners is slower overall, - # due to longer queue times. - runs-on: ubuntu-22.04 - env: - # Cache Docker layers in the Github actions cache. - # These variables are picked up by the goreleaser config. - DOCKER_BUILDX_CACHE_FROM: "type=gha" - DOCKER_BUILDX_CACHE_TO: "type=gha,mode=max" - DOCKER_BUILDX_BUILDER: "builder" - # Seems that for optimal performance, we need to set these - # explicitly - including GOBIN. - GOCACHE: "/home/runner/.cache/go-build" - GOPATH: "/home/runner/go" - GOBIN: "/home/runner/go/bin" - steps: - - uses: actions/checkout@v3 - - run: docker buildx create --name ${DOCKER_BUILDX_BUILDER} --driver docker-container --use - - run: docker buildx install - - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go }} - cache: false - - name: Setup Golang caches - uses: actions/cache@v3 - with: - path: | - /home/runner/.cache/go-build - /home/runner/go - /home/runner/go/bin - key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-golang- - - name: Setup and integration tests - run: | - # Manually create folders to ensure perms are correct. - mkdir -p .kube/internal - mkdir -p .kube/external - go run github.com/magefile/mage@v1.14.0 -v localdev minimal testsuite - - name: Upload JUnit report artifact - uses: actions/upload-artifact@v3.1.1 - with: - name: junit.xml - path: junit.xml - if-no-files-found: error - - name: Publish JUnit report - uses: mikepenz/action-junit-report@v3.6.1 - if: always() - with: - report_paths: junit.xml - fail_on_failure: true - require_tests: true - detailed_summary: true diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index 84c6b403229..00000000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Go Tests - -on: - push: - branches-ignore: - - master - pull_request: - branches-ignore: - - gh-pages - -jobs: - go-lint: - # TODO(JayF): Configure this to only run when golang code has changed - runs-on: ubuntu-22.04 - strategy: - fail-fast: false - matrix: - go: [ '1.20' ] - steps: - - uses: actions/checkout@v3 - - name: Install Protoc - uses: arduino/setup-protoc@v1 - with: - version: '3.17.3' - repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: ./.github/workflows/go-setup - - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: "v1.53.1" - skip-pkg-cache: true - skip-build-cache: true - args: "-c ./.golangci.yml --timeout=10m --issues-exit-code=1 --max-issues-per-linter=0 --sort-results ./..." - - # TODO(JayF): Consider moving this into its own job, that runs under a larger set of circumstances - # since it's possible for this to fail without any go changes being made. - - name: Validate no changes in generated proto files - run: | - make proto - make dotnet - git status -s -uno - git --no-pager diff - exit $(git status -s -uno | wc -l) - - go-unit-tests: - runs-on: ubuntu-22.04 - strategy: - fail-fast: false - matrix: - go: [ '1.20' ] - steps: - - uses: actions/checkout@v3 - - uses: ./.github/workflows/go-setup - - - name: make tests - run: make tests - - - name: make junit-report - run: make junit-report - - - name: Upload junit report - uses: actions/upload-artifact@v3.1.1 - with: - name: junit.xml - path: test_reports/junit.xml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000000..e61160837ad --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,204 @@ +name: Code Build and Tests + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + checks: write + +jobs: + unit-tests: + name: Unit Tests + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Golang with Cache + uses: magnetikonline/action-golang-cache@v4 + with: + go-version: "1.20" + + - name: Setup dependencies + shell: bash + run: make download + + - name: Unit Tests + id: unit_test + run: make tests + + - name: Publish JUnit Report + uses: mikepenz/action-junit-report@v3 + if: always() + with: + report_paths: test-reports/unit-tests.xml + fail_on_failure: true + require_tests: true + detailed_summary: true + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Test Reports Artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: unit-test-reports + path: test-reports/ + if-no-files-found: error + + - name: Send Coverage Report to Codecov + if: always() + uses: codecov/codecov-action@v3 + with: + file: ./test-reports/coverage.out + flags: unittests + name: codecov-armada-unit-tests + verbose: true + + integration-tests: + name: Integration Tests + runs-on: ubuntu-22.04 + + env: + ARMADA_EXECUTOR_INGRESS_URL: "http://localhost" + ARMADA_EXECUTOR_INGRESS_PORT: 5001 + # Cache Docker layers in the GitHub actions cache. + # These variables are picked up by the goreleaser config. + DOCKER_BUILDX_CACHE_FROM: "type=gha" + DOCKER_BUILDX_CACHE_TO: "type=gha,mode=max" + DOCKER_BUILDX_BUILDER: "builder" + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Create Docker Buildx Builder + run: docker buildx create --name ${DOCKER_BUILDX_BUILDER} --driver docker-container --use + + - name: Install Docker Buildx + run: docker buildx install + + - name: Setup Golang with Cache + uses: magnetikonline/action-golang-cache@v4 + with: + go-version: "1.20" + + - name: Setup dependencies + shell: bash + run: make download + + - name: Setup and Run Integration Tests + run: | + # Manually create folders to ensure perms are correct. + mkdir -p .kube/internal + mkdir -p .kube/external + go run github.com/magefile/mage@v1.14.0 -v CiIntegrationTests + + - name: Upload JUnit Report Artifact + uses: actions/upload-artifact@v3 + with: + name: integration-rest-reports + path: junit.xml + if-no-files-found: error + + - name: Publish JUnit Report + uses: mikepenz/action-junit-report@v3 + if: always() + with: + report_paths: junit.xml + fail_on_failure: true + require_tests: true + detailed_summary: true + token: ${{ secrets.GITHUB_TOKEN }} + + go-mod-up-to-date: + name: Go Mod Up To Date + runs-on: ubuntu-22.04 + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Golang with Cache + uses: magnetikonline/action-golang-cache@v4 + with: + go-version: "1.20" + + - name: Download all Go modules + run: go mod download + + - name: Check for tidyness of go.mod and go.sum + run: | + go mod tidy + + changed=$(git status -s -uno | wc -l) + + echo -e "### Git status" >> $GITHUB_STEP_SUMMARY + if [[ "$changed" -gt 0 ]]; then + echo -e "Go modules are not synchronized. Please run 'go mod tidy' and commit the changes." >> $GITHUB_STEP_SUMMARY + + git status -s -uno >> $GITHUB_STEP_SUMMARY + + echo -e >> $GITHUB_STEP_SUMMARY + echo -e "### Git diff" >> $GITHUB_STEP_SUMMARY + + git --no-pager diff >> $GITHUB_STEP_SUMMARY + else + echo -e "Go modules are synchronized." >> $GITHUB_STEP_SUMMARY + echo -e >> $GITHUB_STEP_SUMMARY + fi + + exit $changed + + proto-up-to-date: + name: Proto Up To Date + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Protoc + uses: arduino/setup-protoc@v1 + with: + version: '3.17.3' + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go }} + + - name: Setup dependencies + shell: bash + run: make download + + # TODO(JayF): Consider moving this into its own job, that runs under a larger set of circumstances + # since it's possible for this to fail without any go changes being made. + - name: Validate no changes in generated proto files + run: | + make proto + make dotnet + + changed=$(git status -s -uno | wc -l) + + echo -e "### Git status" >> $GITHUB_STEP_SUMMARY + if [[ "$changed" -gt 0 ]]; then + echo -e "Generated proto files are out of date. Please run 'make proto' and commit the changes." >> $GITHUB_STEP_SUMMARY + + git status -s -uno >> $GITHUB_STEP_SUMMARY + + echo -e >> $GITHUB_STEP_SUMMARY + echo -e "### Git diff" >> $GITHUB_STEP_SUMMARY + + git --no-pager diff >> $GITHUB_STEP_SUMMARY + else + echo -e "Generated proto files are up to date." >> $GITHUB_STEP_SUMMARY + echo -e >> $GITHUB_STEP_SUMMARY + fi + + exit $changed diff --git a/.gitignore b/.gitignore index 9394f082479..60f429425d7 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,7 @@ bin/ *.test # Output of the go coverage tool, specifically when used with LiteIDE +test-reports *.out # Dependency directories (remove the comment below to include it) diff --git a/makefile b/makefile index 28d16d7e25b..fed33d70a6e 100644 --- a/makefile +++ b/makefile @@ -402,14 +402,7 @@ tests: gotestsum docker run -d --name=postgres $(DOCKER_NET) -p 5432:5432 -e POSTGRES_PASSWORD=psw postgres:14.2 sleep 3 function tearDown { docker rm -f redis postgres; }; trap tearDown EXIT - $(GOTESTSUM) -- $(shell go list ./internal/... | grep -v 'jobservice/repository') \ - -coverprofile internal_coverage.xml -v 2>&1 | tee test_reports/internal.txt - env JSDBTYPE=sqlite $(GOTESTSUM) -- -v \ - ./internal/jobservice/repository/... 2>&1 | tee -a test_reports/internal.txt - env JSDBTYPE=postgres $(GOTESTSUM) -- -v \ - ./internal/jobservice/repository/... 2>&1 | tee -a test_reports/internal.txt - $(GOTESTSUM) -- -coverprofile pkg_coverage.xml -v ./pkg... 2>&1 | tee test_reports/pkg.txt - $(GOTESTSUM) -- -coverprofile cmd_coverage.xml -v ./cmd... 2>&1 | tee test_reports/cmd.txt + $(GOTESTSUM) --format short-verbose --junitfile test-reports/unit-tests.xml --jsonfile test-reports/unit-tests.json -- -coverprofile=test-reports/coverage.out -covermode=atomic ./... .ONESHELL: lint-fix: From 9f6acce67253c198a20a8b8032ba9e6fa11798e6 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Thu, 22 Jun 2023 16:04:38 +0200 Subject: [PATCH 02/17] fix integration test target --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e61160837ad..b5f19cd2fd3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -96,7 +96,7 @@ jobs: # Manually create folders to ensure perms are correct. mkdir -p .kube/internal mkdir -p .kube/external - go run github.com/magefile/mage@v1.14.0 -v CiIntegrationTests + go run github.com/magefile/mage@v1.14.0 -v localdev minimal testsuite - name: Upload JUnit Report Artifact uses: actions/upload-artifact@v3 From ec1aebd6a93398655f3ebb2183ad5c4247684c51 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Thu, 22 Jun 2023 20:58:50 +0200 Subject: [PATCH 03/17] fix unit test filter --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index fed33d70a6e..7e4ab036999 100644 --- a/makefile +++ b/makefile @@ -402,7 +402,7 @@ tests: gotestsum docker run -d --name=postgres $(DOCKER_NET) -p 5432:5432 -e POSTGRES_PASSWORD=psw postgres:14.2 sleep 3 function tearDown { docker rm -f redis postgres; }; trap tearDown EXIT - $(GOTESTSUM) --format short-verbose --junitfile test-reports/unit-tests.xml --jsonfile test-reports/unit-tests.json -- -coverprofile=test-reports/coverage.out -covermode=atomic ./... + $(GOTESTSUM) --format short-verbose --junitfile test-reports/unit-tests.xml --jsonfile test-reports/unit-tests.json -- -coverprofile=test-reports/coverage.out -covermode=atomic ./cmd/... ./pkg/... ./internal/... .ONESHELL: lint-fix: From c808cfabeed9112343d08d6057f0d270efa371fa Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Thu, 22 Jun 2023 21:18:42 +0200 Subject: [PATCH 04/17] exclude jobservice test --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index 7e4ab036999..81c86bbe1ef 100644 --- a/makefile +++ b/makefile @@ -402,7 +402,7 @@ tests: gotestsum docker run -d --name=postgres $(DOCKER_NET) -p 5432:5432 -e POSTGRES_PASSWORD=psw postgres:14.2 sleep 3 function tearDown { docker rm -f redis postgres; }; trap tearDown EXIT - $(GOTESTSUM) --format short-verbose --junitfile test-reports/unit-tests.xml --jsonfile test-reports/unit-tests.json -- -coverprofile=test-reports/coverage.out -covermode=atomic ./cmd/... ./pkg/... ./internal/... + $(GOTESTSUM) --format short-verbose --junitfile test-reports/unit-tests.xml --jsonfile test-reports/unit-tests.json -- -coverprofile=test-reports/coverage.out -covermode=atomic ./cmd/... ./pkg/... $(go list ./internal/... | grep -v 'jobservice/repository') .ONESHELL: lint-fix: From 60b75de8f187cf8540f75ff9ac712f0d43c06ea5 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Tue, 27 Jun 2023 14:47:10 +0200 Subject: [PATCH 05/17] add lint workflow --- .github/workflows/lint.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000000..b8282914fd1 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,34 @@ +name: "Lint" + +on: + push: + branches: + - master + pull_request: + +permissions: + contents: read + pull-requests: read + +jobs: + lint-go: + name: Lint Go + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Golang with Cache + uses: magnetikonline/action-golang-cache@v4 + with: + go-version: "1.20" + + - name: Lint using golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + skip-pkg-cache: true + skip-build-cache: true + version: v1.52.2 + only-new-issues: true + args: --timeout=10m --issues-exit-code=1 --sort-results ./... From 4d4082bdfa79562e524e093f4c4f5691ba86b982 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Tue, 27 Jun 2023 14:48:34 +0200 Subject: [PATCH 06/17] remove branches condition for test workflow on pr --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b5f19cd2fd3..4ee18a7bc55 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,6 @@ on: push: branches: [master] pull_request: - branches: [master] permissions: contents: read From 8984404729a4ca9133100cf9153d22cbcf89d542 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Wed, 28 Jun 2023 14:49:01 +0200 Subject: [PATCH 07/17] add aggregate workflow for CI --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ .github/workflows/lint.yml | 5 +---- .github/workflows/test.yml | 4 +--- 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..348b46afbb3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: CI + +on: + push: + pull_request: + schedule: + # Run daily at 01:34, so we get notified if CI is broken before a pull request + # is submitted. + - cron: "34 1 * * *" + +permissions: + contents: read + pull-requests: read + checks: write + +jobs: + lint: + uses: ./.github/workflows/lint.yml + test: + uses: ./.github/workflows/test.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b8282914fd1..cff9a3e0c72 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,10 +1,7 @@ name: "Lint" on: - push: - branches: - - master - pull_request: + workflow_call: permissions: contents: read diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4ee18a7bc55..3c7b0c920fb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,7 @@ name: Code Build and Tests on: - push: - branches: [master] - pull_request: + workflow_call: permissions: contents: read From be1ca4d408406c9a4ebe2882eb47b89b99737faf Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Wed, 28 Jun 2023 14:50:33 +0200 Subject: [PATCH 08/17] make test job after lint job --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 348b46afbb3..b0c1b26beff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,4 +17,5 @@ jobs: lint: uses: ./.github/workflows/lint.yml test: + needs: lint uses: ./.github/workflows/test.yml From 0ef06c0d7910d0292508841e241deff7ef822a55 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Wed, 28 Jun 2023 14:54:44 +0200 Subject: [PATCH 09/17] add codeql job to ci --- .github/workflows/ci.yml | 2 ++ .github/workflows/codeql-analysis.yml | 8 +------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0c1b26beff..f7801322b89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,8 @@ permissions: checks: write jobs: + codeql: + uses: ./.github/workflows/codeql-analysis.yml lint: uses: ./.github/workflows/lint.yml test: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1a6c5d01ed4..956160fa86b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -12,13 +12,7 @@ name: "CodeQL" on: - push: - branches: [ master ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ master ] - schedule: - - cron: '15 2 * * 4' + workflow_call: jobs: analyze: From 7ff9ec331967a412611e5be28cf17fbaf05e2888 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Wed, 28 Jun 2023 14:56:37 +0200 Subject: [PATCH 10/17] fix permissions in ci workflow --- .github/workflows/ci.yml | 2 ++ .github/workflows/codeql-analysis.yml | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7801322b89..b2b7251d511 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,8 @@ permissions: contents: read pull-requests: read checks: write + actions: read + security-events: write jobs: codeql: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 956160fa86b..cda45fd1ef3 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -14,6 +14,10 @@ name: "CodeQL" on: workflow_call: +permissions: + actions: read + security-events: write + jobs: analyze: name: Analyze From 4535fc7d51c5f65247fbfa68d5b8a0c0dcc139f4 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Wed, 28 Jun 2023 14:59:27 +0200 Subject: [PATCH 11/17] make codeql job run after lint job --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2b7251d511..ee88fcc044f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,10 +16,11 @@ permissions: security-events: write jobs: - codeql: - uses: ./.github/workflows/codeql-analysis.yml lint: uses: ./.github/workflows/lint.yml + codeql: + needs: lint + uses: ./.github/workflows/codeql-analysis.yml test: needs: lint uses: ./.github/workflows/test.yml From 5fb890fb08917a385e700253851e8b8f6faadca4 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Wed, 28 Jun 2023 15:08:17 +0200 Subject: [PATCH 12/17] remove needs from ci workflow jobs --- .github/workflows/ci.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee88fcc044f..fda8c5b22ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,8 +19,17 @@ jobs: lint: uses: ./.github/workflows/lint.yml codeql: - needs: lint uses: ./.github/workflows/codeql-analysis.yml test: - needs: lint uses: ./.github/workflows/test.yml + # Virtual job that can be configured as a required check before a PR can be merged. + all-required-checks-done: + name: All required checks done + needs: + - lint + - codeql + - test + runs-on: ubuntu-latest + steps: + - run: | + echo "All required checks done" From 397b12639e7fce150129c34712b8d14dfaf6ce5b Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Wed, 28 Jun 2023 15:08:39 +0200 Subject: [PATCH 13/17] run job on ubuntu 22.04 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fda8c5b22ec..582ff28eeeb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: - lint - codeql - test - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - run: | echo "All required checks done" From dcea1dac78c4cec825578fa36701a726660840e4 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Wed, 28 Jun 2023 18:01:32 +0200 Subject: [PATCH 14/17] move ts workflows to ci workflow --- .github/workflows/ci.yml | 9 ++++++++ .github/workflows/lint.yml | 24 ++++++++++++++++++- .github/workflows/test.yml | 24 +++++++++++++++++-- .github/workflows/ts.yml | 47 -------------------------------------- 4 files changed, 54 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/ts.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 582ff28eeeb..cb3a5723961 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,12 +2,20 @@ name: CI on: push: + branches-ignore: + - gh-pages pull_request: + branches-ignore: + - gh-pages schedule: # Run daily at 01:34, so we get notified if CI is broken before a pull request # is submitted. - cron: "34 1 * * *" +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + permissions: contents: read pull-requests: read @@ -33,3 +41,4 @@ jobs: steps: - run: | echo "All required checks done" + diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cff9a3e0c72..5572e4b9d99 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,7 +8,29 @@ permissions: pull-requests: read jobs: - lint-go: + ts-lint: + # TODO(JayF): Determine what nodejs versions we target, and setup matrix-based testing similar to what we do for go + name: Lint TypeScript + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16.14.2 + cache: yarn + cache-dependency-path: ./internal/lookout/ui/yarn.lock + + - name: Check TypeScript formatting + run: | + yarn install --frozen-lockfile && yarn run fmt || exit 1 + exit $(git status -s -uno | wc -l) + working-directory: ./internal/lookout/ui + + go-lint: name: Lint Go runs-on: ubuntu-22.04 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3c7b0c920fb..6ee6bc6223e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,27 @@ permissions: checks: write jobs: - unit-tests: + ts-unit-tests: + name: TypeScript Unit Tests + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16.14.2 + cache: yarn + cache-dependency-path: ./internal/lookout/ui/yarn.lock + + - name: Run Unit Tests + run: | + yarn install --frozen-lockfile && yarn run openapi && CI=true yarn run test + working-directory: ./internal/lookout/ui + + go-unit-tests: name: Unit Tests runs-on: ubuntu-22.04 @@ -56,7 +76,7 @@ jobs: name: codecov-armada-unit-tests verbose: true - integration-tests: + go-integration-tests: name: Integration Tests runs-on: ubuntu-22.04 diff --git a/.github/workflows/ts.yml b/.github/workflows/ts.yml deleted file mode 100644 index 52887248a84..00000000000 --- a/.github/workflows/ts.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Lookout - -on: - push: - branches-ignore: - - master - paths: - - 'internal/lookout/ui/**' - - 'build/lookout/**' - - '.github/workflows/ts.yml' - pull_request: - branches-ignore: - - gh-pages - paths: - - 'internal/lookout/ui/**' - - 'build/lookout/**' - - '.github/workflows/ts.yml' - -jobs: - ts-lint: - # TODO(JayF): Determine what nodejs versions we target, and setup matrix-based testing similar to what we do for go - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16.14.2 - - - name: Check TypeScript formatting - run: | - yarn install --frozen-lockfile && yarn run fmt || exit 1 - exit $(git status -s -uno | wc -l) - working-directory: ./internal/lookout/ui - ts-unit-tests: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16.14.2 - - - name: Run Unit Tests - run: | - yarn install --frozen-lockfile && yarn run openapi && CI=true yarn run test - working-directory: ./internal/lookout/ui - - From 9278fdf66f635906dfe4017bb66a474d9bb34f6e Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Wed, 28 Jun 2023 18:03:22 +0200 Subject: [PATCH 15/17] rename jobs in ci workflow --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ee6bc6223e..ce5859a97a2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: working-directory: ./internal/lookout/ui go-unit-tests: - name: Unit Tests + name: Golang Unit Tests runs-on: ubuntu-22.04 steps: @@ -77,7 +77,7 @@ jobs: verbose: true go-integration-tests: - name: Integration Tests + name: Golang Integration Tests runs-on: ubuntu-22.04 env: @@ -133,7 +133,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} go-mod-up-to-date: - name: Go Mod Up To Date + name: Golang Mod Up To Date runs-on: ubuntu-22.04 steps: From 18c2e3127fa6d117e797a98263d78ff021001287 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Wed, 28 Jun 2023 18:09:46 +0200 Subject: [PATCH 16/17] remove obsolete workflows --- .github/workflows/coverage.yml | 26 -------------------------- .github/workflows/not-ts.yml | 27 --------------------------- 2 files changed, 53 deletions(-) delete mode 100644 .github/workflows/coverage.yml delete mode 100644 .github/workflows/not-ts.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index 5e7d5d86aec..00000000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Code Coverage - -on: - push: - pull_request: - -jobs: - go-unit-coverage: - runs-on: ubuntu-22.04 - strategy: - fail-fast: false - matrix: - go: [ '1.20' ] - - steps: - - uses: actions/checkout@v3 - - uses: ./.github/workflows/go-setup - - - name: make tests - run: make tests - - - name: Go Test Coverage - uses: codecov/codecov-action@v3 - with: - files: ./internal_coverage.xml,./cmd_coverage.xml # optional - flags: armada-server diff --git a/.github/workflows/not-ts.yml b/.github/workflows/not-ts.yml deleted file mode 100644 index 19fe723f2c3..00000000000 --- a/.github/workflows/not-ts.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Lookout - -on: - push: - branches-ignore: - - master - paths-ignore: - - 'internal/lookout/ui/**' - - 'build/lookout/**' - - '.github/workflows/ts.yml' - pull_request: - branches-ignore: - - gh-pages - paths-ignore: - - 'internal/lookout/ui/**' - - 'build/lookout/**' - - '.github/workflows/ts.yml' - -jobs: - ts-lint: - runs-on: ubuntu-latest - steps: - - run: 'echo "No lookout code modified, not running lookout jobs"' - ts-unit-tests: - runs-on: ubuntu-latest - steps: - - run: 'echo "No lookout code modified, not running lookout jobs"' From 1050e31425b4aa03cd4376cc1e5de701a61df3a1 Mon Sep 17 00:00:00 2001 From: Dejan Pejchev Date: Wed, 28 Jun 2023 18:48:45 +0200 Subject: [PATCH 17/17] add junit report for ts tests --- .github/workflows/test.yml | 35 ++++++++++++++++++++++++++++---- internal/lookout/ui/package.json | 1 + internal/lookout/ui/yarn.lock | 20 ++++++++++++++++++ 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ce5859a97a2..ce0e9cf58c9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,9 +25,36 @@ jobs: - name: Run Unit Tests run: | - yarn install --frozen-lockfile && yarn run openapi && CI=true yarn run test + yarn install --frozen-lockfile && yarn run openapi && CI=true yarn run test --reporters=jest-junit working-directory: ./internal/lookout/ui + - name: Publish JUnit Report + uses: mikepenz/action-junit-report@v3 + if: always() + with: + report_paths: ./internal/lookout/ui/junit.xml + fail_on_failure: true + require_tests: true + detailed_summary: true + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Test Reports Artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: ts-unit-test-reports + path: ./internal/lookout/ui/junit.xml + if-no-files-found: error + + - name: Send Coverage Report to Codecov + if: always() + uses: codecov/codecov-action@v3 + with: + file: ./internal/lookout/ui/coverage/cobertura-coverage.xml + flags: unittests + name: codecov-armada-ts-unit-tests + verbose: true + go-unit-tests: name: Golang Unit Tests runs-on: ubuntu-22.04 @@ -63,7 +90,7 @@ jobs: if: always() uses: actions/upload-artifact@v3 with: - name: unit-test-reports + name: go-unit-test-reports path: test-reports/ if-no-files-found: error @@ -73,7 +100,7 @@ jobs: with: file: ./test-reports/coverage.out flags: unittests - name: codecov-armada-unit-tests + name: codecov-armada-go-unit-tests verbose: true go-integration-tests: @@ -118,7 +145,7 @@ jobs: - name: Upload JUnit Report Artifact uses: actions/upload-artifact@v3 with: - name: integration-rest-reports + name: go-integration-test-reports path: junit.xml if-no-files-found: error diff --git a/internal/lookout/ui/package.json b/internal/lookout/ui/package.json index 969aba79a98..34ee7b8898e 100644 --- a/internal/lookout/ui/package.json +++ b/internal/lookout/ui/package.json @@ -48,6 +48,7 @@ "eslint-plugin-import": "^2.23.3", "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-react": "^7.31.11", + "jest-junit": "^16.0.0", "js-yaml": "^4.0.0", "notistack": "^2.0.8", "prettier": "^2.3.0", diff --git a/internal/lookout/ui/yarn.lock b/internal/lookout/ui/yarn.lock index 2c5239df332..18267034938 100644 --- a/internal/lookout/ui/yarn.lock +++ b/internal/lookout/ui/yarn.lock @@ -7044,6 +7044,16 @@ jest-jasmine2@^27.5.1: pretty-format "^27.5.1" throat "^6.0.1" +jest-junit@^16.0.0: + version "16.0.0" + resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-16.0.0.tgz#d838e8c561cf9fdd7eb54f63020777eee4136785" + integrity sha512-A94mmw6NfJab4Fg/BlvVOUXzXgF0XIH6EmTgJ5NDPp4xoKq0Kr7sErb+4Xs9nZvu58pJojz5RFGpqnZYJTrRfQ== + dependencies: + mkdirp "^1.0.4" + strip-ansi "^6.0.1" + uuid "^8.3.2" + xml "^1.0.1" + jest-leak-detector@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-27.5.1.tgz#6ec9d54c3579dd6e3e66d70e3498adf80fde3fb8" @@ -7876,6 +7886,11 @@ mitt@^2.1.0: resolved "https://registry.yarnpkg.com/mitt/-/mitt-2.1.0.tgz#f740577c23176c6205b121b2973514eade1b2230" integrity sha512-ILj2TpLiysu2wkBbWjAmww7TkZb65aiQO+DkVdUTBpBXq+MHYiETENkKFMtsJZX1Lf4pe4QOrTSjIfUwN5lRdg== +mkdirp@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== + mkdirp@~0.5.1: version "0.5.6" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" @@ -10969,6 +10984,11 @@ xml-name-validator@^3.0.0: resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw== +xml@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" + integrity sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw== + xmlchars@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"