diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index ad50212..df1de10 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -16,13 +16,15 @@ on: - 'go.*' - '.github/**' - 'codecov.yml' +env: + HIBP_API_KEY: ${{ secrets.HIBP_API_KEY }} jobs: run: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - go: [1.15, 1.16, 1.17, 1.18] + os: [ubuntu-latest] + go: [1.18] steps: - name: Checkout Code uses: actions/checkout@master diff --git a/.github/workflows/codecov_testonly.yml b/.github/workflows/codecov_testonly.yml new file mode 100644 index 0000000..9dcdbe7 --- /dev/null +++ b/.github/workflows/codecov_testonly.yml @@ -0,0 +1,32 @@ +name: Codecov workflow +on: + push: + branches: + - main + paths: + - '**.go' + - 'go.*' + - '.github/**' + - 'codecov.yml' + pull_request: + branches: + - main + paths: + - '**.go' + - 'go.*' + - '.github/**' + - 'codecov.yml' +jobs: + run: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + go: [1.15, 1.16, 1.17, 1.18] + steps: + - name: Checkout Code + uses: actions/checkout@master + + - name: Run Tests + run: | + go test -v -race --coverprofile=coverage.coverprofile --covermode=atomic . diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 83b5cf0..63e15d3 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -3,6 +3,8 @@ on: push: branches: - main # or the name of your main branch +env: + HIBP_API_KEY: ${{ secrets.HIBP_API_KEY }} jobs: build: name: Build diff --git a/breach_test.go b/breach_test.go index 87f53e3..a7855e2 100644 --- a/breach_test.go +++ b/breach_test.go @@ -41,7 +41,7 @@ func TestBreachesWithDomain(t *testing.T) { {"example.com is not breached", "example.com", false}, } - hc := New() + hc := New(WithRateLimitSleep()) for _, tc := range testTable { t.Run(tc.testName, func(t *testing.T) { breachList, _, err := hc.BreachApi.Breaches(WithDomain(tc.domain)) @@ -80,7 +80,7 @@ func TestBreachesWithoutUnverified(t *testing.T) { {"xiaomi.cn is breached but not verified", "xiaomi.cn", true, false}, } - hc := New() + hc := New(WithRateLimitSleep()) for _, tc := range testTable { t.Run(tc.testName, func(t *testing.T) { breachList, _, err := hc.BreachApi.Breaches(WithDomain(tc.domain), WithoutUnverified()) @@ -108,7 +108,7 @@ func TestBreachByName(t *testing.T) { {"Example is not a known breach", "Example", false, true}, } - hc := New() + hc := New(WithRateLimitSleep()) for _, tc := range testTable { t.Run(tc.testName, func(t *testing.T) { breachDetails, _, err := hc.BreachApi.BreachByName(tc.breachName) @@ -159,7 +159,7 @@ func TestBreachedAccount(t *testing.T) { if apiKey == "" { t.SkipNow() } - hc := New(WithApiKey(apiKey)) + hc := New(WithApiKey(apiKey), WithRateLimitSleep()) for _, tc := range testTable { t.Run(tc.testName, func(t *testing.T) { breachDetails, _, err := hc.BreachApi.BreachedAccount( diff --git a/codecov.yml b/codecov.yml index 7c6df36..e70d965 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,7 +2,7 @@ coverage: status: project: default: - target: 80% + target: 50% threshold: 5% base: auto if_ci_failed: error diff --git a/hibp_test.go b/hibp_test.go index 0dcf795..f2112c9 100644 --- a/hibp_test.go +++ b/hibp_test.go @@ -44,7 +44,7 @@ func TestNewWithPwnedPadding(t *testing.T) { // TestNewWithApiKey tests the New() function with the API key set func TestNewWithApiKey(t *testing.T) { apiKey := os.Getenv("HIBP_API_KEY") - hc := New(WithApiKey(apiKey)) + hc := New(WithApiKey(apiKey), WithRateLimitSleep()) if hc.ak != apiKey { t.Errorf("hibp client API key was not set properly. Expected %s, got: %s", apiKey, hc.ak) diff --git a/paste_test.go b/paste_test.go index be3d2ba..519049e 100644 --- a/paste_test.go +++ b/paste_test.go @@ -22,7 +22,7 @@ func TestPasteAccount(t *testing.T) { if apiKey == "" { t.SkipNow() } - hc := New(WithApiKey(apiKey)) + hc := New(WithApiKey(apiKey), WithRateLimitSleep()) for _, tc := range testTable { t.Run(tc.testName, func(t *testing.T) { pasteDetails, _, err := hc.PasteApi.PastedAccount(tc.accountName)