crystal-ameba / github-action

A GitHub Action that lints Crystal code with Ameba
MIT License
29 stars 6 forks source link

Running locally this action #12

Closed dinkopehar closed 1 year ago

dinkopehar commented 3 years ago

From the README.md:

Build the docker image:

docker build . -t crystal-ameba/github-action Run it:

docker run -it crystal-ameba/github-action

But it fails with stack trace:

Unhandled exception: Missing ENV key: "GITHUB_WORKSPACE" (KeyError)
  from /usr/share/crystal/src/env.cr:53:7 in 'fetch'
  from /usr/share/crystal/src/env.cr:22:5 in '[]'
  from src/ameba-github_action/runner.cr:8:20 in 'initialize'
  from src/ameba-github_action/runner.cr:7:5 in 'new'
  from src/ameba-github_action.cr:4:1 in '__crystal_main'
  from /usr/share/crystal/src/crystal/main.cr:110:5 in 'main_user_code'
  from /usr/share/crystal/src/crystal/main.cr:96:7 in 'main'
  from /usr/share/crystal/src/crystal/main.cr:119:3 in 'main'
  from __libc_start_main
  from _start
  from ???

Any way to run this locally ? I'm contributing to closed source project written in Crystal and using this action in GitHub on pull request, it passed the checks while running ameba locally as dependency, it failed (on purpose introduced fail):


[W] Lint/UselessAssign: Useless assignment to variable `p`
> p = 3
  ^

Finished in 8.93 seconds
30 inspected, 1 failure

EDIT:

Also, this is ameba jobs in our workflow:

# AMEBA
  ameba-test:
    runs-on: ubuntu-latest
    container:
      image: crystallang/crystal:1.0.0
    steps:
      - name: Checkout
        uses: actions/checkout@v1
      - name: Crystal Ameba Linter
        id: crystal-ameba
        uses: crystal-ameba/github-action@v0.2.12
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
veelenga commented 3 years ago

Hey. Thanks for the heads up.

I don't think it is possible to run this action locally. The doc is outdated, i will remove those instructions.

To be able to test locally you need to use the same Ameba version as your GitHub action uses.

Also is there any .ameba.yml configuration in the repo?

dinkopehar commented 3 years ago

Yes, at the root of the project there is .ameba.yml containing:

Metrics/CyclomaticComplexity:
  Description: Disallows methods with a cyclomatic complexity higher than `MaxComplexity`
  Enabled: false

The ameba version is 0.14.3

veelenga commented 3 years ago

Is the UselessAssign correctly detected by the action or is it false positives?

dinkopehar commented 3 years ago

This is the output of container when it's run: image

So I don't see nothing executed, but the UselessAssign isn't detected.

veelenga commented 3 years ago

Sorry, i didn't get what is the problem. Does github action miss the introduced on purpose fail?

dinkopehar commented 3 years ago

Yes, that's the problem.

greenbigfrog commented 2 years ago

Hey, anyone actually able to get this to run? What's the state of this? Appears to be failing to detect "introduced on purpose fails".

veelenga commented 2 years ago

I was not able to reproduce this on my end. @greenbigfrog do you have an open-sourced example of the failure?