nektos / act

Run your GitHub Actions locally 🚀
https://nektosact.com
MIT License
55.34k stars 1.38k forks source link

unable to get git repo #1242

Closed mrcnski closed 2 years ago

mrcnski commented 2 years ago

Bug report info

act version:            0.2.29
GOOS:                   darwin
GOARCH:                 amd64
NumCPU:                 16
Docker host:            DOCKER_HOST environment variable is unset/empty.
Sockets found:
    /var/run/docker.sock
Config files:           
    /Users/marcin/.actrc:
        -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest
        -P ubuntu-22.04=ghcr.io/catthehacker/ubuntu:act-22.04
        -P ubuntu-20.04=ghcr.io/catthehacker/ubuntu:act-20.04
        -P ubuntu-18.04=ghcr.io/catthehacker/ubuntu:act-18.04
Build info:
    Go version:            go1.18.3
    Module path:           command-line-arguments
    Main version:          
    Main path:             
    Main checksum:         
    Build settings:
        -compiler:            gc
        -ldflags:             -X main.version=0.2.29
        CGO_ENABLED:          1
        CGO_CFLAGS:           
        CGO_CPPFLAGS:         
        CGO_CXXFLAGS:         
        CGO_LDFLAGS:          
        GOARCH:               amd64
        GOOS:                 darwin
        GOAMD64:              v1
Docker Engine:
    Engine version:        20.10.10
    Engine runtime:        runc
    Cgroup version:        1
    Cgroup driver:         cgroupfs
    Storage driver:        overlay2
    Registry URI:          https://index.docker.io/v1/
    OS:                    Docker Desktop
    OS type:               linux
    OS version:            
    OS arch:               x86_64
    OS kernel:             5.10.47-linuxkit
    OS CPU:                4
    OS memory:             1985 MB
    Security options:
        name=seccomp,profile=default

Command used with act

act

Describe issue

Tons and tons of error message spam in the output.

Link to GitHub repository

https://github.com/SkynetLabs/skynet-js

Workflow content

name: "CI"

on:
  push:
    branches: [master]
  pull_request:

# For auto-approving/merging PRs.
permissions:
  pull-requests: write
  contents: write

jobs:
  check:
    name: "Checks and Tests"
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        portal: ["siasky.net", "skynetfree.net", "skynetpro.net"]
        node-version: [14.x, 16.x, 18.x]

    steps:
      - name: "Run Yarn Basic Checks"
        # This is needed because PRs from forks do not have access to secrets.
        #
        # TODO: We can change this to always run siasky later, but right now this portal
        #       is too unstable.
        if: "!github.event.pull_request.head.repo.fork || matrix.portal != 'siasky.net'"
        uses: SkynetLabs/.github/.github/actions/yarn-basic-checks@master
        with:
          node-version: ${{ matrix.node-version }}
          build: true
        env:
          SKYNET_JS_INTEGRATION_TEST_SERVER: "https://${{ matrix.portal }}"
          SKYNET_JS_INTEGRATION_TEST_SKYNET_API_KEY: ${{ secrets.SKYNET_API_KEY }}

  # Auto-merge Dependabot PRs. Requires also `.github/.kodiak.toml`.
  # See https://hackmd.io/@SkynetLabs/ryFfInNXc.
  dependabot:
    name: "Approve and Merge Dependabot PRs"
    # - Must be a PR.
    # - The latest actor must be Dependabot. This prevents other users from
    #   sneaking in changes into the PR.
    if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' }}
    runs-on: ubuntu-latest

    steps:
      - name: "Run Auto-Approval and Auto-Merge"
        uses: SkynetLabs/.github/.github/actions/dependabot-approve-and-merge@master
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

Relevant log output

[CI/Checks and Tests-6              ] unable to get git repo: unable to find git repo
[CI/Checks and Tests-6              ] unable to get git ref: unable to find git repo
[CI/Checks and Tests-6              ] unable to get git revision: unable to find git repo
[CI/Checks and Tests-6              ] unable to get git repo: unable to find git repo
[CI/Checks and Tests-6              ] unable to get git ref: unable to find git repo
[CI/Checks and Tests-6              ] unable to get git revision: unable to find git repo
[CI/Checks and Tests-6              ] unable to get git repo: unable to find git repo
[CI/Checks and Tests-6              ] unable to get git ref: unable to find git repo

etc.



### Additional information

_No response_
ZauberNerd commented 2 years ago

That's probably because you're executing act in a folder that doesn't contain a .git folder: https://github.com/nektos/act/blob/master/pkg/common/git/git.go#L226-L249

Also, these messages are warnings, not errors.

mrcnski commented 2 years ago

There is a .git file (not folder), my repo happens to be a worktree. That seems to be what's causing it, based on the linked code.

This might be easily fixed if you use the gitdir specified in the worktree file, though you'd have to test it. I can even give it a shot if you reopen the issue.

ZauberNerd commented 2 years ago

There was an attempt a few months ago to implement worktree support in act: https://github.com/nektos/act/pull/829 but unfortunately it was abandoned.

If you want to try to implement it, please go ahead :)

mrcnski commented 2 years ago

There was an attempt a few months ago to implement worktree support in act: #829 but unfortunately it was abandoned.

If you want to try to implement it, please go ahead :)

I guess it's not as simple as just changing that one function:

But it will still not work with the current implementation, as act is working on the root working copy. That need to be changed in this PR.

I don't have the inclination to dive into act internals; I barely use it, I just wanted to report a single issue.

It would be nice if at least the git error only displayed once instead of 1000s of times, but I likewise don't care to learn how act implements its error handling in order to fix that.

KnisterPeter commented 2 years ago

but I likewise don't care to learn how act implements its error handling in order to fix that

If you don't care, you don't deserve the fix :wink: Just joking.

mrcnski commented 2 years ago

but I likewise don't care to learn how act implements its error handling in order to fix that

If you don't care, you don't deserve the fix 😉 Just joking.

The maintainers could fix this really quickly as they already are familiar with the codebase.