From 535733d5548097c47f83e7bbd304bea53c225458 Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Wed, 18 Oct 2023 15:33:49 +0200 Subject: [PATCH] Combine all CI into a single file and generate the matrix dynamically --- .github/workflows/ci.yml | 62 +++++++++++++++++++++++++++++++++ .github/workflows/reviewdog.yml | 21 ----------- .github/workflows/test.yml | 21 ----------- 3 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..e0d4f7ea2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,62 @@ +name: CI + +on: [pull_request] + +jobs: + prep-test: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set matrix + id: set-matrix + run: | + echo "::set-output name=matrix::[$(find . -name 'go.mod' -exec dirname {} \; | sort -u | sed 's|^\./||' | sed 's/.*/"&"/' | tr '\n' ',' | sed 's/,$//')]" + + go-test: + needs: prep-test + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + module: ${{fromJson(needs.prep-test.outputs.matrix)}} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: "1.21" + - name: Run tests core + working-directory: ./${{ matrix.module }} + run: go test ./... -tags rocksdb,stacktrace -count=1 -timeout 10m + + golangci-lint: + needs: prep-test + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + module: ${{fromJson(needs.prep-test.outputs.matrix)}} + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: golangci-lint + uses: reviewdog/action-golangci-lint@v2 + with: + workdir: ./${{ matrix.module }} + github_token: ${{ secrets.GITHUB_TOKEN }} + golangci_lint_flags: "--timeout=10m" + reviewdog_flags: "-name=golangci-${{ matrix.module }}" + reporter: github-pr-check + filter_mode: nofilter + fail_on_error: true diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 6ebfc37ea..d339afb89 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -2,25 +2,4 @@ name: CI on: [pull_request] jobs: - golangci-lint: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - module: [ ads, crypto, serializer, core, logger, app, constraints, ds, web, stringify, runtime, codegen, kvstore, ierrors, apputils, log, lo ] - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: golangci-lint - uses: reviewdog/action-golangci-lint@v2 - with: - workdir: ./${{ matrix.module }} - github_token: ${{ secrets.GITHUB_TOKEN }} - golangci_lint_flags: "--timeout=10m" - reviewdog_flags: "-name=golangci-${{ matrix.module }}" - reporter: github-pr-check - filter_mode: nofilter - fail_on_error: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 01f36710d..000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: CI - -on: [pull_request] - -jobs: - go-test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - module: [ ads, crypto, serializer, core, logger, app, constraints, ds, web, stringify, runtime, codegen, kvstore, ierrors, apputils, log, lo ] - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: "1.21" - - name: Run tests core - working-directory: ./${{ matrix.module }} - run: go test ./... -tags rocksdb,stacktrace -count=1 -timeout 10m