florence / cover

a code coverage tool for racket
MIT License
38 stars 7 forks source link

GitHub Action #149

Closed dannypsnl closed 2 years ago

dannypsnl commented 3 years ago

I'm trying to create coverage CI with this on GitHub Action

name: Coverage

on:
  push:
    branches:
    - '*'
    paths:
    - '**.rkt'
  pull_request:
    branches:
    - '*'
    paths:
    - '**.rkt'
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  cover:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Setup Racket
      uses: Bogdanp/setup-racket@v1.1
      with:
        architecture: 'x64' # (x64 or x86), ignored on Linux
        variant: 'CS'
        version: '8.0'
        packages: 'cover'
    - run: raco pkg install --auto
    - run: raco cover -f codecov .

But raco cover -f codecov . reports cover: given unknown coverage output format: "codecov", any ideas?

dannypsnl commented 3 years ago

After change packages: 'cover' to packages: 'cover, cover-codecov', I get:

Failed to find a service.
cover: instrumenting: /home/runner/work/racket-project/racket-project/info.rkt
cover: instrumenting: /home/runner/work/racket-project/racket-project/main.rkt
cover: instrumenting: /home/runner/work/racket-project/racket-project/scribblings/racket-project.scrbl
cover: running file: /home/runner/work/racket-project/racket-project/info.rkt
cover: running file: /home/runner/work/racket-project/racket-project/main.rkt
cover: running file: /home/runner/work/racket-project/racket-project/scribblings/racket-project.scrbl
  context...:
   /home/runner/.local/share/racket/8.0/pkgs/cover-codecov/cover/private/codecov.rkt:23:0: generate-codecov-coverage
   /home/runner/.local/share/racket/8.0/pkgs/cover-lib/cover/raco.rkt:95:3: temp4
   /usr/share/racket/collects/racket/logging.rkt:43:0: with-intercepted-logging
   body of (submod "/home/runner/.local/share/racket/8.0/pkgs/cover-lib/cover/raco.rkt" main)
   /usr/share/racket/collects/raco/raco.rkt:41:0
   body of "/usr/share/racket/collects/raco/raco.rkt"
cover: dumping coverage info into "coverage"
   body of "/usr/share/racket/collects/raco/main.rkt"
countvajhula commented 3 years ago

@dannypsnl I'm not sure, but I noticed your error message in the source code here which seems to suggest that it is looking for an environment variable to indicate which CI provider is being used -- I see GitLab and Travis there, so maybe GitHub isn't supported yet?

FWIW I've written up another way to get coverage working in this blog post. Try it out if you're still having issues.

dannypsnl commented 3 years ago

New config

jobs:
  coverage:
    runs-on: ubuntu-latest
    environment: test-env
    env:
      COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
    steps:
      - uses: actions/checkout@master
      - name: Setup Racket
        uses: Bogdanp/setup-racket@v1.3.1
        with:
          architecture: 'x64'
          distribution: 'minimal'
          variant: 'CS'
          version: '8.1'
          packages: 'cover, cover-coveralls'
      - run: raco pkg install --auto --batch
      - run: |
          make test
          raco cover -b -n dev -f coveralls .

Seems like there has some new error XD.

* Connection #0 to host coveralls.io left intact
curl: (22) The requested URL returned error: 422 
coveralls: request to coveralls failed
  context...:
   /home/runner/.local/share/racket/8.1/pkgs/cover-lib/cover/raco.rkt:95:3
   /usr/share/racket/collects/racket/logging.rkt:43:0: with-intercepted-logging
   body of (submod "/home/runner/.local/share/racket/8.1/pkgs/cover-lib/cover/raco.rkt" main)
   /usr/share/racket/collects/raco/raco.rkt:41:0
   body of "/usr/share/racket/collects/raco/raco.rkt"
   body of "/usr/share/racket/collects/raco/main.rkt"
countvajhula commented 3 years ago

@dannypsnl I've seen that error when I had the wrong repo token, mixed up with another repo - maybe double check that your token in the test environment is the same as the one for that specific repo in Coveralls.

If that doesn't work, to understand what is going on, you could set the environment variable and upload coverage locally from your machine:

export COVERALLS_REPO_TOKEN="<your token>"
raco cover -b -f coveralls .

[you don't need -n dev -- that was specific to my config and I've removed it from the post]

Btw, did you switch to coveralls because the instructions didn't work for CodeCov? I believe they should work for both.

dannypsnl commented 3 years ago

I would try again and as you guess, the setup didn't work for CodeCov.

update

I get the point, I forgot to add secret into environment...XD. I would try codecov later.

Worked setup:

jobs:
  coverage:
    runs-on: ubuntu-latest
    environment: test-env
    env:
      COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
    steps:
      - uses: actions/checkout@master
      - name: Setup Racket
        uses: Bogdanp/setup-racket@v1.3.1
        with:
          architecture: 'x64'
          distribution: 'minimal'
          variant: 'CS'
          version: '8.1'
          packages: 'cover, cover-coveralls'
      - run: raco pkg install --auto
      - run: |
          make test
          raco cover -b -f coveralls .

CodeCov

Still didn't work

* Connection #0 to host coveralls.io left intact
cover: instrumenting: /home/runner/work/racket-project/racket-project/main.rkt
cover: instrumenting: /home/runner/work/racket-project/racket-project/scribblings/racket-project.scrbl
cover: running file: /home/runner/work/racket-project/racket-project/info.rkt
cover: running file: /home/runner/work/racket-project/racket-project/main.rkt
cover: running file: /home/runner/work/racket-project/racket-project/scribblings/racket-project.scrbl
cover: dumping coverage info into "coverage"
Failed to find a service.
cover: instrumenting: /home/runner/work/racket-project/racket-project/main.rkt
cover: instrumenting: /home/runner/work/racket-project/racket-project/scribblings/racket-project.scrbl
cover: running file: /home/runner/work/racket-project/racket-project/info.rkt
cover: running file: /home/runner/work/racket-project/racket-project/main.rkt
cover: running file: /home/runner/work/racket-project/racket-project/scribblings/racket-project.scrbl
cover: dumping coverage info into "coverage"
  context...:
   /home/runner/.local/share/racket/8.1/pkgs/cover-codecov/cover/private/codecov.rkt:23:0: generate-codecov-coverage
   /home/runner/.local/share/racket/8.1/pkgs/cover-lib/cover/raco.rkt:95:3
   /usr/share/racket/collects/racket/logging.rkt:43:0: with-intercepted-logging
   body of (submod "/home/runner/.local/share/racket/8.1/pkgs/cover-lib/cover/raco.rkt" main)
   /usr/share/racket/collects/raco/raco.rkt:41:0
   body of "/usr/share/racket/collects/raco/raco.rkt"
   body of "/usr/share/racket/collects/raco/main.rkt"
countvajhula commented 3 years ago

Glad to hear it! Re: CodeCov, maybe someone who knows more about the codecov package could chime in here, but if it didn't work locally with the environment variable set, then it could be a bug where the package expects to be run on a (known) CI service even if a token is available. If a token is available that should in principle be agnostic to / portable across CI providers.

dannypsnl commented 2 years ago

codecov drop their support for racket, so close