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 result file path issues #1428

Merged
merged 2 commits into from
Aug 12, 2024
Merged

Conversation

spencerschrock
Copy link
Member

@spencerschrock spencerschrock commented Aug 11, 2024

There were two issues at play that prevented the binary from reading the correct results file:

  1. The paths were not joined with a separator during the refactor in use Scorecard library entrypoint instead of Cobra hooking #1423. This led to file not found errors, as the file was saved in the wrong directory, with the wrong name.
  2. The signing code tried to read the file from the working directory instead of the GitHub workspace directory.

I was able to test this code after modifying the testing command in the Dockerfile to use a different GITHUB_WORKSPACE directory. The signing portion of the code will need to wait until the e2e test to confirm the fix.

We should eventually improve the testing instructions, but at least the e2e test we have now caught this (via #1426 and #1427):

docker run -e GITHUB_REF=refs/heads/main \
     -e GITHUB_EVENT_NAME=branch_protection_rule \
    -e INPUT_RESULTS_FORMAT=json \
    -e INPUT_RESULTS_FILE=results.json \
    -e GITHUB_WORKSPACE="/home/runner/work/spencerschrock/actions-test" \
    -e INPUT_POLICY_FILE="/policy.yml" \
    -e INPUT_REPO_TOKEN=$GITHUB_AUTH_TOKEN \
    -e GITHUB_REPOSITORY="spencerschrock/actions-test" \
    -e GITHUB_EVENT_PATH="/event.json" \
    -e GITHUB_API_URL="https://api.github.com" \
    -e INPUT_PUBLISH_RESULTS="true" \
    -v /tmp/docker:/home/runner/work/spencerschrock/actions-test \
    spencerschrock/scorecard-action:latest

Fixes #1426
Fixes #1427
Fixes #1429

There were two issues at play that prevented the binary from reading the
correct results file:

1. The paths were not joined with a separator. This led to file not
   found errors, as the file was saved in the wrong place with the wrong
   name.
2. The signing code tried to read the file from the current working
   directory instead of the GitHub workspace directory.

Signed-off-by: Spencer Schrock <sschrock@google.com>
Copy link
Member

@justaugustus justaugustus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick nit!

internal/scorecard/format.go Outdated Show resolved Hide resolved
Signed-off-by: Spencer Schrock <sschrock@google.com>
Copy link
Member

@justaugustus justaugustus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix, @spencerschrock!

@spencerschrock spencerschrock merged commit fdeb02d into ossf:main Aug 12, 2024
9 checks passed
@spencerschrock spencerschrock deleted the fix-result-file branch August 12, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants