nektos / act

Run your GitHub Actions locally šŸš€
https://nektosact.com
MIT License
54.22k stars 1.35k forks source link

act failes to parse .git/config #2378

Open tim-janik opened 3 months ago

tim-janik commented 3 months ago

Bug report info

$ act --bug-report
act version:            0.2.63-9-g935e4c3
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 16
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
    /var/run/docker.sock
Config files:           
    /home/timj/.config/act/actrc:
        -P ubuntu-latest=catthehacker/ubuntu:act-latest
        -P ubuntu-22.04=catthehacker/ubuntu:act-22.04
        -P ubuntu-20.04=catthehacker/ubuntu:act-20.04
        -P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
    Go version:            go1.22.2
    Module path:           command-line-arguments
    Main version:          
    Main path:             
    Main checksum:         
    Build settings:
        -buildmode:           exe
        -compiler:            gc
        -ldflags:             -X main.version=0.2.63-9-g935e4c3
        DefaultGODEBUG:       httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
        CGO_ENABLED:          1
        CGO_CFLAGS:           
        CGO_CPPFLAGS:         
        CGO_CXXFLAGS:         
        CGO_LDFLAGS:          
        GOARCH:               amd64
        GOOS:                 linux
        GOAMD64:              v1
Docker Engine:
    Engine version:        24.0.7
    Engine runtime:        runc
    Cgroup version:        2
    Cgroup driver:         systemd
    Storage driver:        btrfs
    Registry URI:          https://index.docker.io/v1/
    OS:                    Ubuntu 22.04.4 LTS
    OS type:               linux
    OS version:            22.04
    OS arch:               x86_64
    OS kernel:             6.5.0-41-generic
    OS CPU:                16
    OS memory:             64036 MB
    Security options:
        name=apparmor
        name=seccomp,profile=builtin
        name=cgroupns

Command used with act

$ act --artifact-server-path /tmp/artifacts/
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'

Describe issue

My .git/config contains the following setting:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = git@github.com:tim-janik/gh-testing.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

[mergetool.emacsdiff]
    # use git mergetool ediff to resolve conflicts
    cmd = emacs -nw -Q --eval \"(progn (setq ediff-quit-hook 'kill-emacs) (if (file-readable-p \\\"$BASE\\\") (ediff-merge-files-with-ancestor \\\"$LOCAL\\\" \\\"$REMOTE\\\" \\\"$BASE\\\" nil \\\"$MERGED\\\") (ediff-merge-files \\\"$LOCAL\\\" \\\"$REMOTE\\\" nil \\\"$MERGED\\\")))\"

act fails to correctly parse the .git/config file, it produces errors such as illegal character U+002E '.' and then fails to set GITHUB_REPOSITORY which leads to other errors, such as artifact upload not working.

Link to GitHub repository

No response

Workflow content

on:
  push:
    branches: ['master', 'trunk', 'wip/**']
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+*'

jobs:

  Focal-CI:
    runs-on: ubuntu-latest
    container: { image: 'ghcr.io/tim-janik/anklang-ci:focal-latest' }
    steps:
    - run: |
        echo "SEE: $GITHUB_REPOSITORY"                                                                                                                                                                              
        env                                                                                                                                                                                                         
    - { uses: actions/checkout@v4.1.1, with: { fetch-depth: 0, submodules: recursive, github-server-url: 'https://github.com' } }
    - run: |
        sed 's,git@github.com:,https://github.com/,' -i .git/config     ; # fetch without ssh creds                                                                                                                 
        git fetch -f --tags && git describe --always                    ; # Fix actions/checkout#290                                                                                                                
    - run: |
        git describe | tee git-describe && ls -al
        git -P log -1 --oneline                                                                                                                                                                                     
    - uses: actions/upload-artifact@v4
      with: { name: assets, path: git-describe }

Relevant log output

$ act --artifact-server-path /tmp/artifacts/
INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' 
INFO[0000] Start server on http://10.111.3.51:34567     
WARN[0000] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.' 
[testing.yml/Focal-CI] šŸš€  Start image=ghcr.io/tim-janik/anklang-ci:focal-latest
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI] ā­ Run Main echo "SEE: $GITHUB_REPOSITORY"
env
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI]   šŸ³  docker exec cmd=[sh -e /var/run/act/workflow/0.sh] user= workdir=
| SEE: 
| GITHUB_WORKSPACE=/opt/src/gh-testing
| GITHUB_ACTION_PATH=
| GITHUB_SERVER_URL=https://github.com
| SHLVL=1
| RUNNER_TOOL_CACHE=/opt/hostedtoolcache
| GITHUB_REF_NAME=master
| GITHUB_JOB=Focal-CI
| GITHUB_REPOSITORY=
| GITHUB_RETENTION_DAYS=0
| GITHUB_ACTION_REPOSITORY=
| PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
| RUNNER_PERFLOG=/dev/null
| GITHUB_BASE_REF=
| CI=true
| ImageOS=ubuntu20
| GITHUB_REPOSITORY_OWNER=
| GITHUB_HEAD_REF=
| GITHUB_ACTION_REF=
| GITHUB_WORKFLOW=testing.yml
| DEBIAN_FRONTEND=noninteractive
| GITHUB_OUTPUT=/var/run/act/workflow/outputcmd.txt
| _=/usr/bin/env
[testing.yml/Focal-CI]   āœ…  Success - Main echo "SEE: $GITHUB_REPOSITORY"
env
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI] ā­ Run Main git describe | tee git-describe && ls -al
git -P log -1 --oneline
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI] ā­ Run Main actions/upload-artifact@v4
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
[testing.yml/Focal-CI]   šŸ³  docker cp src=/home/timj/.cache/act/actions-upload-artifact@v4/ dst=/var/run/act/actions/actions-upload-artifact@v4/
[testing.yml/Focal-CI]   šŸ³  docker exec cmd=[chown -R 1001:127 /var/run/act/actions/actions-upload-artifact@v4/] user=0 workdir=
[testing.yml/Focal-CI]   šŸ³  docker exec cmd=[node /var/run/act/actions/actions-upload-artifact@v4/dist/upload/index.js] user= workdir=
[testing.yml/Focal-CI]   šŸ’¬  ::debug::followSymbolicLinks 'true'
[testing.yml/Focal-CI]   šŸ’¬  ::debug::implicitDescendants 'true'
[testing.yml/Focal-CI]   šŸ’¬  ::debug::omitBrokenSymbolicLinks 'true'
[testing.yml/Focal-CI]   šŸ’¬  ::debug::followSymbolicLinks 'true'
[testing.yml/Focal-CI]   šŸ’¬  ::debug::implicitDescendants 'true'
[testing.yml/Focal-CI]   šŸ’¬  ::debug::matchDirectories 'true'
[testing.yml/Focal-CI]   šŸ’¬  ::debug::omitBrokenSymbolicLinks 'true'
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Search path '/opt/src/gh-testing/git-describe'
[testing.yml/Focal-CI]   šŸ’¬  ::debug::File:/opt/src/gh-testing/git-describe was found using the provided searchPath
| With the provided path, there will be 1 file uploaded
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Root artifact directory is /opt/src/gh-testing
| Artifact name is valid!
| Root directory input is valid!
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Workflow Run Backend ID: 1
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Workflow Job Run Backend ID: 1
[testing.yml/Focal-CI]   šŸ’¬  ::debug::[Request] CreateArtifact http://10.111.3.51:34567/twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact
[testing.yml/Focal-CI]   šŸ’¬  ::debug::[Response] - 200
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Headers: {%0A  "content-type": "application/json;charset=utf-8",%0A  "date": "Tue, 25 Jun 2024 10:48:37 GMT",%0A  "content-length": "257"%0A}
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Body: {%0A  "ok": true,%0A  "signedUploadUrl": "http://10.111.3.51:34567/twirp/github.actions.results.api.v1.ArtifactService/UploadArtifact?sig=1KdRkxxsk7EQlZXBS7RncO_CDqhU5UGDCsb-5hCwHzw=&expires=2024-06-25+13%253A48%253A37.103492393+%252B0200+CEST&artifactName=assets&taskID=1"%0A}
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Creating Artifact archive with compressionLevel: 6
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Zip write high watermark value 8388608
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Zip read high watermark value 8388608
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Uploading artifact zip to blob storage with maxConcurrency: 256, bufferSize: 8388608
| Beginning upload of artifact content to blob storage
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Zip stream for upload has ended.
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Zip stream for upload has finished.
| Uploaded bytes 159
| Finished uploading artifact content to blob storage!
| SHA256 hash of uploaded artifact zip is 0a4194a2aeceba1646ea10cb9919b4e3565a5c6635f59d6866607596d9aabe1a
| Finalizing artifact upload
[testing.yml/Focal-CI]   šŸ’¬  ::debug::[Request] FinalizeArtifact http://10.111.3.51:34567/twirp/github.actions.results.api.v1.ArtifactService/FinalizeArtifact
[testing.yml/Focal-CI]   šŸ’¬  ::debug::[Response] - 200
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Headers: {%0A  "content-type": "application/json;charset=utf-8",%0A  "date": "Tue, 25 Jun 2024 10:48:37 GMT",%0A  "content-length": "29"%0A}
[testing.yml/Focal-CI]   šŸ’¬  ::debug::Body: {%0A  "ok": true,%0A  "artifactId": "1"%0A}
| Artifact assets.zip successfully finalized. Artifact ID 1
| Artifact assets has been successfully uploaded! Final size is 159 bytes. Artifact ID is 1
[testing.yml/Focal-CI]   ā—  ::error::context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'
[testing.yml/Focal-CI]   āŒ  Failure - Main actions/upload-artifact@v4
[testing.yml/Focal-CI]   āš™  ::set-output:: artifact-id=1
[testing.yml/Focal-CI] exitcode '1': failure
[testing.yml/Focal-CI] šŸ  Job failed
[testing.yml/Focal-CI] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /opt/src/gh-testing): 14:11: illegal character U+002E '.'
Error: Job 'Focal-CI' failed

Additional information

As a workaround, removing the [mergetool.emacsdiff] section fixes the issue.

theusner-thing commented 2 months ago

Hey,

I've seen the same issue with branches in the .git/config. After removing all local branches except the main branch the artifact upload was working again.