Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review dog command is failing with .git not found error #31

Open
shrutijodevops opened this issue Dec 15, 2023 · 0 comments
Open

Review dog command is failing with .git not found error #31

shrutijodevops opened this issue Dec 15, 2023 · 0 comments

Comments

@shrutijodevops
Copy link

Hi,

I am trying to use review dog to add a comment/annotation on the PR for any tflint warnings/errors. I have a monorepo and once any PR is made, I am identifying the changed directories in PR and then perform tflint and review dog commands on those changed directories. I am using this action to install review dog and then add tflint warnings as annotations. However, when running the reviewdog command, I get.reviewdog git not founderror

name: tflint
on:
  pull_request:
    paths:
      - 'prod/**'
      - 'non-prod/**'
    branches: [ main ]

jobs:
  changed-files:   ##this is to get changed directories in the git repo via the PR
    name: Changed files
    runs-on: arc-runner-set
    outputs:
      matrix: ${{ steps.changed-files.outputs.all_changed_files }}
    steps:
    
      - name: Install Git
        run: |
          sudo apt update
          sudo apt install git -y

      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v37
        with:
          dir_names: true
          dir_names_exclude_current_dir: true
          files_ignore: .github/*
          json: true
          quotepath: false
          escape_json: false
          files_yaml: |
            prod:
              - prod/prod/**
            non-prod:
              - non-prod/qa/**
              - non-prod/dev/**

      - name: List changed files
        run: |
          echo "Changed files: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}"
          echo "Changed directories: ${{ steps.changed-files.outputs.all_changed_files }}"
    
  tflint:
    runs-on: arc-runner-set
    needs: changed-files
    strategy:
      fail-fast: false
      matrix:
        files:  ${{ fromJSON(needs.changed-files.outputs.matrix) }}
    defaults:
      run:
        working-directory: ${{ matrix.files }}
    steps:
    # - name: Print the current directory
    #   run: echo ${{ matrix.files }}
    - uses: actions/checkout@v3
      name: Checkout source code
    
    - uses: actions/cache@v3
      name: Cache plugin dir
      with:
        path: ~/.tflint.d/plugins
        key: tflint-${{ hashFiles('.tflint.hcl') }}

    - name: Install unzip
      run: |
        sudo apt update
        sudo apt install unzip
        sudo apt install curl -y
    
    - uses: terraform-linters/setup-tflint@v3
      name: Setup TFLint
      with:
        tflint_version: v0.49.0

    - name: Show version
      run: tflint --version

    - uses: reviewdog/action-setup@v1     #This works fine
      name: Install review dog
      with:
        reviewdog_version: latest 

    - name: Run TFLint
      id: tflint
      run: |
        tflint --format=json > tflint.json || true
        cat tflint.json
      continue-on-error: true

    - name: "Give detekt permissions"
      run: |
        sudo chown -R root:root $GITHUB_WORKSPACE

    - name: Post TFLint comments on PR
      env:
        REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: |
        cat tflint.json | reviewdog -efm="%f:%l:%c: %m" -name="tflint" -reporter=github-pr-check -level=warning
   
      

I am not sure what I am doing wrong here. Can you please suggest something?

Here is the logs:

Run cat tflint.json | reviewdog -efm="%f:%l:%c: %m" -name="tflint" -reporter=github-pr-check -level=warning
  cat tflint.json | reviewdog -efm="%f:%l:%c: %m" -name="tflint" -reporter=github-pr-check -level=warning
  shell: /usr/bin/bash -e {0}
  env:
    REVIEWDOG_GITHUB_API_TOKEN: ***
reviewdog: .git not found
Error: Process completed with exit code 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant