Skip to content

Commit

Permalink
feat: sys-362 fix test parallelizm and ratelimits
Browse files Browse the repository at this point in the history
  • Loading branch information
gigovich committed Dec 3, 2024
1 parent 8dc435f commit 7a33588
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:

concurrency:
group: default
group: default
cancel-in-progress: false

permissions:
Expand All @@ -19,13 +19,13 @@ jobs:
uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
cache: true
- name: Format code
run: go fmt ./...
run: go fmt ./...
- name: Generate docs
run: go run github.com/hashicorp/terraform-plugin-docs/cmd/[email protected]
run: go run github.com/hashicorp/terraform-plugin-docs/cmd/[email protected]
- name: Check if any files have changed
run: test -z "$(git status --porcelain)" || ( git diff && exit 1 )
run: test -z "$(git status --porcelain)" || ( git diff && exit 1 )

test:
runs-on: ubuntu-22.04
Expand All @@ -36,17 +36,18 @@ jobs:
uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
cache: true
- name: Run unit tests
run: go test -v ./...
run: go test -v ./...
- name: Run acceptance tests
env:
TF_ACC: 'yup'
UPTIME_TOKEN: '${{ secrets.UPTIME_TOKEN }}'
run: go test -v ./... -run ^TestAcc[A-Z]
TF_ACC: "yup"
UPTIME_TOKEN: "${{ secrets.UPTIME_TOKEN }}"
UPTIME_RATE_LIMIT: "0.4"
run: go test -test.timeout=40m -test.parallel=1 -v ./... -run ^TestAcc[A-Z]

release:
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-22.04
needs:
- validate
Expand All @@ -60,10 +61,10 @@ jobs:
uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
cache: true
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
id: import_gpg
id: import_gpg
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Run GoReleaser
Expand All @@ -73,4 +74,4 @@ jobs:
version: "~> v2"
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 11 additions & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"runtime"
"strconv"
"sync"
"time"

Expand Down Expand Up @@ -69,14 +70,23 @@ func (p *providerImpl) Configure(ctx context.Context, rq provider.ConfigureReque
rs.Diagnostics.Append(diags...)
return
}
if cfg.Endpoint.IsNull() {
cfg.Endpoint = types.StringValue(os.Getenv("UPTIME_ENDPOINT"))
}
if cfg.Token.IsNull() {
cfg.Token = types.StringValue(os.Getenv("UPTIME_TOKEN"))
}
if cfg.Trace.IsNull() {
cfg.Trace = types.BoolValue(os.Getenv("UPTIME_TRACE") != "")
}
if cfg.RateLimit.IsNull() {
cfg.RateLimit = types.Float64Value(0.5)
rateLimit := 0.5
if val := os.Getenv("UPTIME_RATE_LIMIT"); val != "" {
if parsedVal, err := strconv.ParseFloat(val, 64); err != nil {
rateLimit = parsedVal
}
}
cfg.RateLimit = types.Float64Value(rateLimit)
}
opts := []upapi.Option{
upapi.WithToken(cfg.Token.ValueString()),
Expand Down

0 comments on commit 7a33588

Please sign in to comment.