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

fatal: Not a git repository #131

Open
PaulDMendoza opened this issue Jul 13, 2021 · 14 comments
Open

fatal: Not a git repository #131

PaulDMendoza opened this issue Jul 13, 2021 · 14 comments

Comments

@PaulDMendoza
Copy link

I'm not sure why but I'm getting this error.

image

My build script is a bit long so copying and pasting it all of here seems uneeded.

name: Tests

on:
  - push
  - pull_request
jobs:  
  test:
    runs-on: ubuntu-latest
    container: node:10.18-jessie
    strategy:
      matrix:
        dotnet-version:
          - 2.1.x
    services:
      postgres:
        image: postgis/postgis:10-2.5
        env:
          POSTGRES_PASSWORD: '111+++'
          POSTGRES_DB: sigparser        
          POSTGRES_USER: postgres
        ports:
          - 5432:5432
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
    env:
      ...
    steps:
      - uses: actions/checkout@v2
      - name: 'Setup .NET Core SDK ${{ matrix.dotnet-version }}'
        uses: actions/setup-dotnet@v1.7.2
        with:
          dotnet-version: '${{ matrix.dotnet-version }}'
      - name: Install dependencies
        run: dotnet restore
      - name: Run Migrations
        run: > 
          dotnet run 
          --project ./DBUpgrader/DBUpgrader.csproj 
          -- migrate  
          --recreate true
          --fillconfigkeytable true 
          --trycreateifnotexists true 
      - name: What directory are we in?
        run: pwd
      - name: Test
        run: dotnet test --logger "trx;LogFileName=test-results.trx"
      - name: Publish Unit Test Results
        uses: dorny/test-reporter@v1.5.0
        if: always()
        with:
          name: Test Results
          path: ./**/TestResults/*.trx
          reporter: 'dotnet-trx'
  

@dorny
Copy link
Owner

dorny commented Jul 13, 2021

Well, this is really weird.

This action uses git to get a list of your tracked source files. For failed tests, it looks at the stack trace and the list of tracked files. The first row in the stack trace that points to any of tracked files is where the annotation will be created.

In your case, I see two possible errors:

  1. Working directory when test-reporter is executed doesn't point to the folder where your repository is checked out
  2. The .git folder got deleted somehow and your working directory is not a git repository.

I would recommend checking the working directory and the existence of the .git folder.
In case, the working directory is wrong, you could set it using working-directory input variable.

@PaulDMendoza
Copy link
Author

I figured it out. I had to add git init after I checked out the code.

steps:
      - uses: actions/checkout@v2
        with:
          token: '${{ secrets.GITHUB_TOKEN }}'
      - name: Run git init
        run: git init

@dorny
Copy link
Owner

dorny commented Jul 17, 2021

You found a workaround to make this action pass, but I'm not entirely sure it will work correctly.
Looks like the checkout action in some cases downloads the files using GitHub REST API instead of a git.
Honestly, I had no idea it could work like that. An example of this is here: actions/checkout#335

Could you please check if you have something similar in your logs from the checkout action?

The repository will be downloaded using the GitHub REST API
To create a local Git repository instead, add Git 2.18 or higher to the PATH

I already have a code that can list tracked files from GitHub REST API. However, it's used only when test results are received from artifacts. A proper solution would be to use the REST API also if the working folder is not a git repository.

@dorny dorny reopened this Jul 17, 2021
@nemad
Copy link

nemad commented Jul 26, 2021

Hi!

Can we have a flag to disable any usage of git? (eg: disableAnnotations: true)

The use case is: I have a job for deployment, where I only need build related artifacts. I run the tests after deployment on the given environment. Ideally I do not want to checkout the source code.

@dorny
Copy link
Owner

dorny commented Jul 29, 2021

Yes, I can add this option. Hopefully next week. Shouldn't be much work

@SebastianSchuetze
Copy link

@dorny did you have a chance to added this flag? I am also struggeling to just have a workaround git repo on my report summary job. Since I am only checking out code in a build stage but hand over all artifacts over the pipeline. I am doing integration tests I shouldn't need to checkout anything.

@alonashkenazi
Copy link

@SebastianSchuetze you can use working-directory to set the dir where you checkout your code

@rohde-januar
Copy link

I too would love this flag

Also it seems like a weird dependency to have on git. You're building a test-report, not performing git operations. In my process I also discovered it break on some build-images, because git is not installed (which can also explain the usage of the REST API). It's strange having to install an extra unrelated tool for this task

@antonandreyev
Copy link

For me this flag is crucial for use with e2e tests. I use Detox with React-Native and Jest runner. So the report is getting generated with failed tests. But since the test code is not attached to any real app code, annotations fail to generate. Disabling them would make it possible to include the e2e tests report into PR.

@conreaux
Copy link

@rohde-januar @antonandreyev
It's not well-documented, but setting max-annotations: '0' will disable annotations.

@gladykov
Copy link

I think the cause is being inside container:

container: node:10.18-jessie

Same for me with Alpine

@antonandreyev
Copy link

@rohde-januar @antonandreyev It's not well-documented, but setting max-annotations: '0' will disable annotations.

Thanks, that worked. Maybe would be nice to update the docs and suggest this until (if) the disableAnnotations: true or alike is implemented

@myzamaraev
Copy link

myzamaraev commented Oct 7, 2023

If anyone like me checkouts to subfolder, there is a solution, e.g. for a path ./backend/TestResults/*.trx, where git repository initialized by checkout action inside ./backend folder:

with:
   working-directory: backend
   path: ./TestResults/*.trx

It won't work with ./backend folder specified as a part of a path parameter though, as the action checks current working directory itself for being a git repository.

manxorist added a commit to OpenMPT/openmpt that referenced this issue Apr 29, 2024
[New] build: CI: GitHub: Add Fedora builder.
........
[Fix] build: CI: GitHub: Fedora: Fix xz dependency install.
........
[Fix] build: CI: GitHub: Fedora: Workaround GitHub quirks. See <dorny/test-reporter#131 (comment)> and <actions/runner#2033>.
........
[Imp] build: CI: GitHub: Fedora: Add matrix build for dependencies.
........
[New] build: CI: GitHub: Add Fedora Autotools builder.
........
[New] build: CI: GitHub: Add Fedora MinGW cross-compile builder.
........


git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.31@20689 56274372-70c3-4bfc-bfc3-4c3a0b034d27
@JojOatXGME
Copy link
Contributor

JojOatXGME commented May 3, 2024

Did I miss something? Doesn't this also break the recommended configuration for public repositories, as the Git repository is never cloned when using the configuration?

UPDATE: Looks like the recommended setup as documented isn't affected because there is a special case when the artifact option is provided:

const inputProvider = this.artifact
? new ArtifactProvider(
this.octokit,
this.artifact,
this.name,
pattern,
this.context.sha,
this.context.runId,
this.token
)
: new LocalFileProvider(this.name, pattern)

However, with Artifacts v4, we can no-longer use the artifact option right now. See #343 and #363.

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