From af15c66865fdc4262555ec6385def95cd0807623 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 7 May 2022 14:55:33 +0200 Subject: [PATCH 1/7] Adding RateLimitSleep() to all tests --- breach_test.go | 8 ++++---- hibp_test.go | 2 +- paste_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/breach_test.go b/breach_test.go index b69270c..d871b2d 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/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 0244d83..f495534 100644 --- a/paste_test.go +++ b/paste_test.go @@ -21,7 +21,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( From 2af48736dfb07cc755e0a3a348538b38db70c004 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 7 May 2022 14:57:14 +0200 Subject: [PATCH 2/7] Update sonarqube.yml --- .github/workflows/sonarqube.yml | 2 ++ 1 file changed, 2 insertions(+) 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 From 41c8f9eefc53c2a0d166cd71a2cb216d28dc98c1 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 7 May 2022 14:59:31 +0200 Subject: [PATCH 3/7] Update codecov.yml --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 27b95c19bc2992df4c694ef45f872241a33a77cb Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 7 May 2022 15:03:09 +0200 Subject: [PATCH 4/7] Update and rename codecov.yml to codecov_testonly.yml --- .github/workflows/{codecov.yml => codecov_testonly.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{codecov.yml => codecov_testonly.yml} (95%) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov_testonly.yml similarity index 95% rename from .github/workflows/codecov.yml rename to .github/workflows/codecov_testonly.yml index ad50212..b80cd65 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov_testonly.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - go: [1.15, 1.16, 1.17, 1.18] + go: [1.15, 1.16, 1.17] steps: - name: Checkout Code uses: actions/checkout@master From 2cd451a84d75bfa3b157b12ae727bcd322b05dd8 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 7 May 2022 15:03:43 +0200 Subject: [PATCH 5/7] Update codecov_testonly.yml --- .github/workflows/codecov_testonly.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/codecov_testonly.yml b/.github/workflows/codecov_testonly.yml index b80cd65..0401aba 100644 --- a/.github/workflows/codecov_testonly.yml +++ b/.github/workflows/codecov_testonly.yml @@ -30,9 +30,3 @@ jobs: - name: Run Tests run: | go test -v -race --coverprofile=coverage.coverprofile --covermode=atomic . - - - name: Upload coverage to Codecov - if: success() && matrix.go == 1.18 && matrix.os == 'ubuntu-latest' - uses: codecov/codecov-action@v2 - with: - token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos From 356b48bed778138b45e18b166eb07637531e88cb Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 7 May 2022 15:04:51 +0200 Subject: [PATCH 6/7] Create codecov.yml --- .github/workflows/codecov.yml | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000..df1de10 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,40 @@ +name: Codecov workflow +on: + push: + branches: + - main + paths: + - '**.go' + - 'go.*' + - '.github/**' + - 'codecov.yml' + pull_request: + branches: + - main + paths: + - '**.go' + - 'go.*' + - '.github/**' + - 'codecov.yml' +env: + HIBP_API_KEY: ${{ secrets.HIBP_API_KEY }} +jobs: + run: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + go: [1.18] + steps: + - name: Checkout Code + uses: actions/checkout@master + + - name: Run Tests + run: | + go test -v -race --coverprofile=coverage.coverprofile --covermode=atomic . + + - name: Upload coverage to Codecov + if: success() && matrix.go == 1.18 && matrix.os == 'ubuntu-latest' + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos From 90124586b8304d8829ba245196efdb724a693a71 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 7 May 2022 15:05:09 +0200 Subject: [PATCH 7/7] Update codecov_testonly.yml --- .github/workflows/codecov_testonly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov_testonly.yml b/.github/workflows/codecov_testonly.yml index 0401aba..9dcdbe7 100644 --- a/.github/workflows/codecov_testonly.yml +++ b/.github/workflows/codecov_testonly.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - go: [1.15, 1.16, 1.17] + go: [1.15, 1.16, 1.17, 1.18] steps: - name: Checkout Code uses: actions/checkout@master