opcotech/elemo

View on GitHub
.github/workflows/build-backend.yml

Summary

Maintainability
Test Coverage
name: Build backend

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  lint:
    runs-on: "ubuntu-latest"
    env:
      GO111MODULE: on
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: "^1.22"
      - name: Go CI Lint
        uses: golangci/golangci-lint-action@v6
        with:
          version: latest
          args: --timeout 5m

  unit-test:
    runs-on: "ubuntu-latest"
    needs:
      - lint
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: "^1.22"
      - name: Execute unit tests
        run: make test.backend.unit
      - name: Stash test results
        uses: actions/upload-artifact@v4
        with:
          name: "unit-test-results"
          path: .coverage.unit.out
          retention-days: 7

  benchmark-test:
    runs-on: "ubuntu-latest"
    needs:
      - lint
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: "^1.22"
      - name: Execute integration tests
        run: make test.backend.bench

  integration-test:
    runs-on: "ubuntu-latest"
    needs:
      - unit-test
      - benchmark-test
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: "^1.22"
      - name: Execute integration tests
        run: make test.backend.integration
      - name: Stash test results
        uses: actions/upload-artifact@v4
        with:
          name: "integration-test-results"
          path: .coverage.integration.out
          retention-days: 7

  coverage:
    name: coverage
    runs-on: ubuntu-latest
    needs:
      - integration-test
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: "^1.22"
      - name: Unstash unit test results
        uses: actions/download-artifact@v4
        with:
          name: "unit-test-results"
      - name: Unstash integration test results
        uses: actions/download-artifact@main
        with:
          name: "integration-test-results"
      - name: Upload test results
        uses: paambaati/codeclimate-action@v6.0.0
        env:
          CC_TEST_REPORTER_ID: 3fa16f73e6568d7742b05ed8dbdab71641c366c85def280983aa19f9ee732cf9
        with:
          coverageCommand: make test.backend.coverage
          prefix: github.com/${{github.repository}}
          coverageLocations: ${{github.workspace}}/.coverage.out:gocov