barecheck / code-coverage-action

GitHub Action that generates code coverage reports
https://barecheck.com
MIT License
57 stars 14 forks source link

is barecheck still alive? #248

Open chicco785 opened 1 year ago

chicco785 commented 1 year ago
  1. login in the web site is not possible

    image

  2. the github action, despite passing the token fails:

    0s
    ##[debug]Evaluating condition for step: 'Generate Code Coverage report'
    ##[debug]Evaluating: success()
    ##[debug]Evaluating success:
    ##[debug]=> true
    ##[debug]Result: true
    ##[debug]Starting: Generate Code Coverage report
    ##[debug]Loading inputs
    ##[debug]Evaluating: secrets.BARECHECK_GITHUB_APP_TOKEN
    ##[debug]Evaluating Index:
    ##[debug]..Evaluating secrets:
    ##[debug]..=> Object
    ##[debug]..Evaluating String:
    ##[debug]..=> 'BARECHECK_GITHUB_APP_TOKEN'
    ##[debug]=> null
    ##[debug]Result: null
    ##[debug]Loading env
    Run barecheck/code-coverage-action@v[1](https://github.com/zaphiro-technologies/go-template/actions/runs/6081044542/job/16496057540#step:7:1)
    lcov-file: ./coverage/lcov.info
    Current code coverage: [10](https://github.com/zaphiro-technologies/go-template/actions/runs/6081044542/job/16496057540#step:7:10)0%
    base-lcov-file: ./coverage/base-lcov.info
    Base branch code coverage: 100%
    Code coverage diff: 0.00%
    Code coverage diff: 0.00%
    Error: Either Application or Github token is required to create Octokit client
    Error: Either Application or Github token is required to create Octokit client
    ##[debug]Node Action run completed with exit code 1
    ##[debug]Finishing: Generate Code Coverage report
vitaliimelnychuk commented 1 year ago

Hello @chicco785 !

thanks for reaching out. It's alive and a few companies that I know personally use it.

Can you send your configuration of the action?

Also, any chance you can reinstall app?

chicco785 commented 1 year ago

hi @vitaliimelnychuk the issue in the github action self solved, still I can't login in the ui using my github account, I will ask a colleague to try it as well.

PierekEast commented 11 months ago

Hey, could this tool be used to create code coverage in golang? Or is it specifically for node/js? I see that some files are expected to this barecheck action, but does it contain some generic interface? I am playing with go test + go tool cover to get the coverage number, but not sure whether this could be used with this app.

chicco785 commented 11 months ago

We are using it for golang at the time being

PierekEast commented 11 months ago

Do you have any examples that you could share?

chicco785 commented 11 months ago
name: Golang

concurrency:
  group: ${{ github.ref_name }}-go
  cancel-in-progress: true

permissions:
  # Give the default GITHUB_TOKEN write permission to commit and push the 
  # updated CHANGELOG back to the repository.
  # https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
  contents: write

on:
  workflow_dispatch:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main
    paths:
      - ".github/workflows/**"
      - "go.mod"
      - "go.sum"
      - "internal/**"
      - "pkg/**"
      - ".golangci.yaml"

jobs:
  lint:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go-version: ["1.21"]
    env:
      GOPRIVATE: github.com/zaphiro-technologies/*
      GH_ACCESS_TOKEN: ${{ secrets.REPO_PRIVATE_READ_PAT }}
    steps:
      - uses: actions/checkout@v4
        if: ${{ github.event_name == 'pull_request' }}
        with:
          ref: ${{github.event.pull_request.head.ref}}
      - uses: actions/checkout@v4
        if: ${{ github.event_name != 'pull_request' }}
      - run: git config --global url.https://$GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/
      - name: Set up Go
        uses: actions/setup-go@v4
        with:
          go-version: ${{ matrix.go-version }}
      - name: Golines
        if: ${{ github.event_name == 'pull_request' }}
        run: |
          go install github.com/segmentio/golines@latest
          golines . -w

      - name: golangci-lint
        uses: golangci/golangci-lint-action@v3
        with:
          args: --fix
          version: latest
          skip-pkg-cache: true
      - name: Commit golines & golangci-lint changes
        if: ${{ github.event_name == 'pull_request' }}
        run: |
          git config --global user.name 'Bot'
          git config --global user.email 'bot@zaphiro.ch'
          git commit -am "Automated lint fixes" || echo "No changes to commit"
          git push
  test:
    needs: lint
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go-version: ["1.21"]
    env:
      GOPRIVATE: github.com/zaphiro-technologies/*
      GH_ACCESS_TOKEN: ${{ secrets.REPO_PRIVATE_READ_PAT }}
    steps:
      - uses: actions/checkout@v4
      - run: git config --global url.https://$GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/
      - name: Set up Go
        uses: actions/setup-go@v4
        with:
          go-version: ${{ matrix.go-version }}
      - name: Install gcov2lcov
        run: |
            go install github.com/jandelgado/gcov2lcov@latest
      - name: Test
        run: |
            mkdir coverage 
            go test ./... -coverprofile=./coverage/coverage.out && \
            gcov2lcov -infile=./coverage/coverage.out -outfile=./coverage/lcov.info
      - name: Test main
        run: |
            git fetch origin main --depth 1
            git checkout origin/main
            export myarray=(`find ./ -maxdepth 3 -name "*.go"`)
            if [ ${#myarray[@]} -gt 0 ]; then 
                go test ./... -coverprofile=./coverage/base-coverage.out && \
                gcov2lcov -infile=./coverage/base-coverage.out -outfile=./coverage/base-lcov.info
            else 
                touch ./coverage/base-lcov.info
                echo "end_of_record" >> ./coverage/base-lcov.info
            fi
      - name: Generate Code Coverage report
        id: code-coverage
        uses: barecheck/code-coverage-action@v1
        with:
          barecheck-github-app-token: ${{ secrets.BARECHECK_GITHUB_APP_TOKEN }}
          lcov-file: "./coverage/lcov.info"
          base-lcov-file: "./coverage/base-lcov.info"
          minimum-ratio: 70
          send-summary-comment: true
          show-annotations: "warning"
  benchmark:
    needs: test
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go-version: ["1.21"]
    env:
      GOPRIVATE: github.com/zaphiro-technologies/*
      GH_ACCESS_TOKEN: ${{ secrets.REPO_PRIVATE_READ_PAT }}
    steps:
      - uses: actions/checkout@v4
      - run: git config --global url.https://$GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/
      - uses: actions/setup-go@v4
        with:
          go-version: ${{ matrix.go-version }}
      # Run benchmark with `go test -bench` and stores the output to a file
      - name: Run benchmark
        run: go test ./... -bench 'Benchmark' | tee output.txt
      # Download previous benchmark result from cache (if exists)
      - name: Download previous benchmark data
        uses: actions/cache@v3
        with:
          path: ./cache
          key: ${{ runner.os }}-benchmark
      # Run `github-action-benchmark` action
      - name: Store benchmark result
        uses: benchmark-action/github-action-benchmark@v1
        with:
          # What benchmark tool the output.txt came from
          tool: 'go'
          # Where the output from the benchmark tool is stored
          output-file-path: output.txt
          # Where the previous data file is stored
          external-data-json-path: ./cache/benchmark-data.json
          # Workflow will fail when an alert happens
          fail-on-alert: true
          # Enable alert commit comment
          comment-on-alert: true
          github-token: ${{ secrets.GITHUB_TOKEN }}
          alert-threshold: 150%
          summary-always: true
vitaliimelnychuk commented 11 months ago

So nice to see people using it ;)

Yes, it's not language-related - all you need is to have lcov file generated 🎉

Maybe we can create some docs as examples of how to use it with different test runners

vitaliimelnychuk commented 11 months ago

@chicco785 were you able to login into the Barecheck UI account?

PierekEast commented 11 months ago

I also came up with using gcov2lcov as @chicco785 did - nice to see that other programmers have similar ideas;)

chicco785 commented 11 months ago

@chicco785 were you able to login into the Barecheck UI account?

unfortunately not :/