Skip to content
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

Github Actions #226

Merged
merged 5 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@Workiva/skreams
tannermiller-wf marked this conversation as resolved.
Show resolved Hide resolved
38 changes: 38 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Tests"

on:
pull_request:
push:
branches:
- 'master'
tags:
- '*'

permissions:
pull-requests: write
contents: read
id-token: write

jobs:
Tests:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.15', 'stable' ]
name: Tests on Go ${{ matrix.go }}
steps:
- name: Checkout Repo
uses: actions/[email protected]
with:
path: go/src/github.com/Workiva/go-datastructures

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}

- name: Run Tests
timeout-minutes: 10
run: |
cd go/src/github.com/Workiva/go-datastructures
go test ./...
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

17 changes: 15 additions & 2 deletions sort/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ func MultithreadedSortComparators(comparators Comparators) Comparators {
var wg sync.WaitGroup

numCPU := int64(runtime.NumCPU())
if numCPU%2 == 1 { // single core machine
numCPU++
if numCPU == 1 { // single core machine
numCPU = 2
} else {
// otherwise this algo only works with a power of two
numCPU = int64(prevPowerOfTwo(uint64(numCPU)))
}

chunks := chunk(toBeSorted, numCPU)
Expand Down Expand Up @@ -70,3 +73,13 @@ func chunk(comparators Comparators, numParts int64) []Comparators {
}
return parts
}

func prevPowerOfTwo(x uint64) uint64 {
x = x | (x >> 1)
x = x | (x >> 2)
x = x | (x >> 4)
x = x | (x >> 8)
x = x | (x >> 16)
x = x | (x >> 32)
return x - (x >> 1)
}
Loading