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
Create a Golang-based entrypoint for scorecard-action (1/n) #122
Conversation
Codecov Report
@@ Coverage Diff @@
## main #122 +/- ##
==========================================
+ Coverage 66.39% 69.02% +2.62%
==========================================
Files 1 2 +1
Lines 247 113 -134
==========================================
- Hits 164 78 -86
+ Misses 77 27 -50
- Partials 6 8 +2
|
595b3e6
to
af32bc2
Compare
cc @rohankh532 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you!, I didn't approve it because I would like @laurentsimon also to review it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome @justaugustus, thanks! Same comment as @naveensrinivasan, will wait for @laurentsimon review.
I want to call out the test failures here: Unit tests (https://github.com/ossf/scorecard-action/runs/5426123389?check_suite_focus=true): Run go test -covermode=atomic -coverprofile=unit-coverage.out ./...
go test -covermode=atomic -coverprofile=unit-coverage.out ./...
shell: /usr/bin/bash -e {0}
env:
GOROOT: /opt/hostedtoolcache/go/1.17.7/x64
? github.com/ossf/scorecard-action [no test files]
ok github.com/ossf/scorecard-action/entrypoint 0.009s coverage: 0.0% of statements [no tests to run]
? github.com/ossf/scorecard-action/github [no test files]
--- FAIL: TestNew (0.00s)
--- FAIL: TestNew/SuccessFormatSARIF (0.00s)
options_test.go:107: New() error = validating scorecard options: some options could not be validated: [commit option is not supported yet], wantErr false
--- FAIL: TestNew/SuccessFormatJSON (0.00s)
options_test.go:107: New() error = validating scorecard options: some options could not be validated: [commit option is not supported yet], wantErr false
FAIL
coverage: 43.9% of statements
FAIL github.com/ossf/scorecard-action/options 0.012s
FAIL
Error: Process completed with exit code 1. golangci-lint (https://github.com/ossf/scorecard-action/runs/5426123392?check_suite_focus=true): Run golangci/golangci-lint-action@b517f99ae23d86ecc4c0dec08dcf48d2336abc29
prepare environment
run golangci-lint
Running [/home/runner/golangci-lint-1.44.0-linux-amd64/golangci-lint run --out-format=github-actions --new-from-patch=/tmp/tmp-1656-d52rcyaL5U29/pull.patch --new=false --new-from-rev=] in [] ...
Error: File is not `gci`-ed (gci)
Error: File is not `gci`-ed (gci)
Error: File is not `gci`-ed (gci)
Error: issues found
Ran golangci-lint in 3505ms VS what happens locally... ❯ time go test -v -covermode=atomic -coverprofile=unit-coverage.out ./...
? github.com/ossf/scorecard-action [no test files]
testing: warning: no tests to run
PASS
coverage: 0.0% of statements
ok github.com/ossf/scorecard-action/entrypoint 0.354s coverage: 0.0% of statements [no tests to run]
? github.com/ossf/scorecard-action/github [no test files]
=== RUN TestNew
=== RUN TestNew/SuccessFormatSARIF
=== RUN TestNew/SuccessFormatJSON
--- PASS: TestNew (0.00s)
--- PASS: TestNew/SuccessFormatSARIF (0.00s)
--- PASS: TestNew/SuccessFormatJSON (0.00s)
=== RUN TestInitialize
=== RUN TestInitialize/Success
=== RUN TestInitialize/FailureNoFieldsSet
=== RUN TestInitialize/FailureBadEventPath
=== RUN TestInitialize/FailureBadEventData
--- PASS: TestInitialize (0.00s)
--- PASS: TestInitialize/Success (0.00s)
--- PASS: TestInitialize/FailureNoFieldsSet (0.00s)
--- PASS: TestInitialize/FailureBadEventPath (0.00s)
--- PASS: TestInitialize/FailureBadEventData (0.00s)
PASS
coverage: 54.4% of statements
ok github.com/ossf/scorecard-action/options 0.226s coverage: 54.4% of statements
go test -v -covermode=atomic -coverprofile=unit-coverage.out ./... 1.86s user 1.12s system 165% cpu 1.798 total ❯ time golangci-lint run -c .golangci.yml
golangci-lint run -c .golangci.yml 1.33s user 1.01s system 210% cpu 1.116 total Something is up with CI tests; will check it out. |
A wild guess, the |
Yep! I'm checking out https://github.com/nektos/act locally to see if I can mimic the GitHub Action env. |
Nice! That's a pretty cool tool. @laurentsimon might help in testing |
Exactly what I was thinking! |
e1eaf42
to
467b2e6
Compare
@azeemshaikh38 @naveensrinivasan -- Can you take a peek at #126? That PR fixes the lint config. |
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
@laurentsimon @azeemshaikh38 @naveensrinivasan -- I think this is a good stopping point. There's a bunch more to do, but all of the tests are passing and I'd to unblock the work happening in #120 (cc: @rohankh532). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
method := "GET" | ||
req, err := http.NewRequestWithContext( | ||
c.ctx, | ||
method, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use http.MethodGet
here instead.
…recard-action#122) * Move entrypoint logic to separate package * options: env var-mapped structs via github.com/caarlos0/env/v6 * go.mod: Update scorecard to v4.1.1-0.20220306220811-4b9f0389c6f6 * entrypoint: Wrap scorecard with additional flags and hide unused * entrypoint: Add `print-config` command * options: Process GitHub info together * options: Cleanups and defaulting for action-specific settings * github: Move GitHub logic to a separate package * entrypoint: Support outputting to file * Rewrite unit tests * Allow options tests to pass in GitHub Actions environments Signed-off-by: Stephen Augustus <foo@auggie.dev>
Part of #107.
Signed-off-by: Stephen Augustus foo@auggie.dev