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

Fix "reference not found" error #433

Merged
merged 4 commits into from Jan 12, 2021
Merged

Conversation

lufia
Copy link
Contributor

@lufia lufia commented Nov 30, 2020

If an action uses the branch to pin the major version, for example - use: 8398a7/action-slack@v3
will stop with an error: "v3: reference not found."

In this case act should use refs/remotes/origin/v1 as a name to resolve v1 revision.

#311

I checked:

  • In b3299ec (current master) stopped by - use: 8398a7/action-slack@v3
  • This patch fixed the above error.

If an action uses the branch to pin the major version, `- use: user/action@v1`
will stop with an error: "v1: reference not found."

In this case `act` should use refs/remotes/origin/v1 as a name to resolve v1 revision.
@lufia lufia requested a review from cplee as a code owner November 30, 2020 07:42
@alfredodeza
Copy link
Contributor

I'm very interested in getting this fixed as well, thanks for providing a pr @lufia . Testing locally, I'm still seeing failures. In this case I'm trying to use the main branch:

jobs:
  image:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - uses: anchore/scan-action@main
      with:
        image: "python:3.8"
        debug: true

This fails in the same way as before:

[[Demo] Run Scan Action/image] ⭐  Run anchore/scan-action@main
[[Demo] Run Scan Action/image]   ☁  git clone 'https://github.com/anchore/scan-action' # ref=main
[[Demo] Run Scan Action/image]   cloning https://github.com/anchore/scan-action to /Users/alfredo/.cache/act/anchore-scan-action@main
[[Demo] Run Scan Action/image] Provided ref is not a sha. Checking out branch before pulling changes
[[Demo] Run Scan Action/image] Unable to checkout refs/heads/main: reference not found
DEBU[0004] reference not found
DEBU[0004] reference not found
[[Demo] Run Scan Action/image]   ❌  Failure - anchore/scan-action@main
DEBU[0004] reference not found
Error: reference not found

@lufia
Copy link
Contributor Author

lufia commented Dec 3, 2020

@alfredodeza Thanks for your testing! I will check this case.

@patrickelectric
Copy link

I'm having the same problem with jurplel/install-qt-action@v2

@lufia
Copy link
Contributor Author

lufia commented Dec 29, 2020

Hi. @alfredodeza

I'm trying to represent the error. Unfortunately, I got success with above configuration.

% cd src/nektos/act
% go build -o test-act
% cat testdata/scan.yml
name: testtest
on:
  pull_request:
  push:
jobs:
  (snip)
% ./test-act -W testdata pull_request

Could I get the steps to reproduce?

@alfredodeza
Copy link
Contributor

@lufia I'm not sure why I'm seeing @main work now. I created a new branch, pushed it, and now it fails as before.

Here is the yaml to reproduce:

name: "Reproduce issue 433"

on: [push]

jobs:
  image:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - uses: anchore/scan-action@act-fails
      with:
        image: "python:3.8"
        debug: true

Save that as workflows/reproduce.yaml and then run with act:

$  act -j image -W workflows
WARN[0000] unable to get git repo: unable to find git repo
WARN[0000] unable to get git revision: unable to find git repo
WARN[0000] unable to get git ref: unable to find git repo
[Reproduce issue 433/image] 🚀  Start image=node:12.6-buster-slim
WARN[0000] unable to get git repo: unable to find git repo
WARN[0000] unable to get git revision: unable to find git repo
WARN[0000] unable to get git ref: unable to find git repo
[Reproduce issue 433/image]   🐳  docker run image=node:12.6-buster-slim entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Reproduce issue 433/image]   🐳  docker cp src=/tmp/. dst=/github/workspace
WARN[0015] unable to get git repo: unable to find git repo
WARN[0015] unable to get git revision: unable to find git repo
WARN[0015] unable to get git ref: unable to find git repo
WARN[0015] unable to get git repo: unable to find git repo
WARN[0015] unable to get git revision: unable to find git repo
WARN[0015] unable to get git ref: unable to find git repo
[Reproduce issue 433/image] ⭐  Run actions/checkout@v2
WARN[0015] unable to get git repo: unable to find git repo
WARN[0015] unable to get git revision: unable to find git repo
WARN[0015] unable to get git ref: unable to find git repo
[Reproduce issue 433/image]   ✅  Success - actions/checkout@v2
WARN[0015] unable to get git repo: unable to find git repo
WARN[0015] unable to get git revision: unable to find git repo
WARN[0015] unable to get git ref: unable to find git repo
WARN[0015] unable to get git repo: unable to find git repo
WARN[0015] unable to get git revision: unable to find git repo
WARN[0015] unable to get git ref: unable to find git repo
[Reproduce issue 433/image] ⭐  Run anchore/scan-action@act-fails
[Reproduce issue 433/image]   ☁  git clone 'https://github.com/anchore/scan-action' # ref=act-fails
[Reproduce issue 433/image] Unable to checkout refs/heads/act-fails: reference not found
[Reproduce issue 433/image]   ❌  Failure - anchore/scan-action@act-fails
Error: reference not found

@cplee cplee merged commit 1b38d5c into nektos:master Jan 12, 2021
@lufia
Copy link
Contributor Author

lufia commented Jan 12, 2021

@alfredodeza Thank you, I understand the problem. Act should checkout refs/remotes/origin/act-fails instead of refs/heads/act-fails.

I will create a new pull request.

@lufia lufia deleted the fix-resolving-branch branch January 12, 2021 09:46
lufia added a commit to lufia/act that referenced this pull request Jan 14, 2021
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

Successfully merging this pull request may close these issues.

None yet

4 participants