Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pluralsh/polly
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.6
Choose a base ref
...
head repository: pluralsh/polly
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.1.7
Choose a head ref
  • 2 commits
  • 7 files changed
  • 2 contributors

Commits on Mar 14, 2024

  1. Add github actions (#25)

    * Add github actions
    
    We have tests just not in gh actions
    
    * fix lint issues
    michaeljguarino authored Mar 14, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1712923 View commit details

Commits on Mar 15, 2024

  1. add MapToSlice method (#28)

    * add MapToSlice method
    
    * change name
    zreigz authored Mar 15, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a9a52c8 View commit details
Showing with 66 additions and 15 deletions.
  1. +44 −0 .github/workflows/test.yaml
  2. +3 −0 Makefile
  3. +2 −2 algorithms/graph_test.go
  4. +8 −0 algorithms/map.go
  5. +6 −6 containers/set.go
  6. +2 −2 containers/stack_test.go
  7. +1 −5 retry/algorithms.go
44 changes: 44 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
GOPATH: /home/runner/go/
GOPROXY: "https://proxy.golang.org"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true
- run: PATH=$PATH:$GOPATH/bin make build
test:
name: Unit test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true
- run: PATH=$PATH:$GOPATH/bin make test
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true
- uses: golangci/golangci-lint-action@v3
with:
version: latest
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -9,6 +9,9 @@ build: .PHONY # compiles
test: .PHONY # tests the codebase
go test ./...

fix: .PHONY ## fix issues found by linters
golangci-lint run --fix ./...

release-vsn: # tags and pushes a new release
@read -p "Version: " tag; \
git checkout main; \
4 changes: 2 additions & 2 deletions algorithms/graph_test.go
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ func TestDFS(t *testing.T) {
return nil
}

DFS(1, neighbors, visit)
_ = DFS(1, neighbors, visit)
assert.Equal(t, res, []int{1, 2, 4, 3})
}

@@ -42,7 +42,7 @@ func TestBFS(t *testing.T) {
return nil
}

BFS(1, neighbors, visit)
_ = BFS(1, neighbors, visit)
assert.Equal(t, res, []int{1, 2, 3, 4})
}

8 changes: 8 additions & 0 deletions algorithms/map.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package algorithms

func MapValues[K comparable, V any](m map[K]V) []V {
s := make([]V, 0, len(m))
for _, v := range m {
s = append(s, v)
}
return s
}

func Merge(maps ...map[string]interface{}) map[string]interface{} {
res := maps[0]
for _, m := range maps[1:] {
12 changes: 6 additions & 6 deletions containers/set.go
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ func (s Set[V]) Equal(other Set[V]) bool {
return false
}

for k, _ := range s {
for k := range s {
if !other.Has(k) {
return false
}
@@ -77,7 +77,7 @@ func (s Set[V]) Equal(other Set[V]) bool {
// s2.Difference(s1) = {a4, a5}
func (s Set[V]) Difference(other Set[V]) Set[V] {
new := NewSet[V]()
for v, _ := range s {
for v := range s {
if !other.Has(v) {
new.Add(v)
}
@@ -93,7 +93,7 @@ func (s Set[V]) Difference(other Set[V]) Set[V] {
// s2.Union(s1) = {a1, a2, a3, a4}
func (s Set[V]) Union(other Set[V]) Set[V] {
new := ToSet(s.List())
for v, _ := range other {
for v := range other {
new.Add(v)
}
return new
@@ -104,7 +104,7 @@ func Union[V comparable](sets ...Set[V]) Set[V] {

// use nested loops for a bit of extra efficiency
for _, s := range sets {
for v, _ := range s {
for v := range s {
res.Add(v)
}
}
@@ -119,7 +119,7 @@ func Union[V comparable](sets ...Set[V]) Set[V] {
// s1.Intersect(s2) = {a2}
func (s Set[V]) Intersect(other Set[V]) Set[V] {
res := NewSet[V]()
for v, _ := range s {
for v := range s {
if other.Has(v) {
res.Add(v)
}
@@ -134,7 +134,7 @@ func Intersect[V comparable](sets ...Set[V]) Set[V] {
return res
}
first, rest := sets[0], sets[1:]
for v, _ := range first {
for v := range first {
if lo.EveryBy(rest, func(s Set[V]) bool { return s.Has(v) }) {
res.Add(v)
}
4 changes: 2 additions & 2 deletions containers/stack_test.go
Original file line number Diff line number Diff line change
@@ -33,8 +33,8 @@ func TestStackToList(t *testing.T) {
s.Push(2)

assert.Equal(t, s.List(), []int{2, 3, 1})
s.Pop()
_, _ = s.Pop()
assert.Equal(t, s.List(), []int{3, 1})
s.Pop()
_, _ = s.Pop()
assert.Equal(t, s.List(), []int{1})
}
6 changes: 1 addition & 5 deletions retry/algorithms.go
Original file line number Diff line number Diff line change
@@ -24,11 +24,7 @@ func (exp *Exponential) Backoff(iter int) time.Duration {
}

func (exp *Exponential) Continue() bool {
if exp.max <= exp.start {
return false
}

return true
return exp.max > exp.start
}

type Constant struct {