Skip to content

Commit adc74a4

Browse files
committed
initial commit, open source wait package
1 parent d929f63 commit adc74a4

File tree

12 files changed

+510
-1
lines changed

12 files changed

+510
-1
lines changed

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
version: 2
3+
updates:
4+
- package-ecosystem: "gomod" # See documentation for possible values
5+
directory: "/" # Location of package manifests
6+
schedule:
7+
interval: "daily"
8+
reviewers:
9+
- muir
10+
- dncohen
11+
12+
- package-ecosystem: github-actions
13+
directory: "/"
14+
schedule:
15+
interval: "daily"
16+
reviewers:
17+
- muir
18+
- dncohen

.github/workflows/codecov.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Test and coverage
2+
3+
on: [push, pull_request]
4+
5+
permissions: # added using https://github.com/step-security/secure-workflows
6+
contents: read
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Harden Runner
13+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481
14+
with:
15+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
16+
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
18+
with:
19+
fetch-depth: 2
20+
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b
21+
with:
22+
go-version: '1.20'
23+
- name: Run coverage
24+
run: go test ./... -race -coverprofile=coverage.txt -covermode=atomic
25+
- name: Upload coverage to Codecov
26+
uses: codecov/[email protected]
27+
with:
28+
verbose: true
29+
env:
30+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/codeql-analysis.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ main ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ main ]
20+
schedule:
21+
- cron: '20 3 * * 4'
22+
23+
permissions: # added using https://github.com/step-security/secure-workflows
24+
contents: read
25+
26+
jobs:
27+
analyze:
28+
name: Analyze
29+
runs-on: ubuntu-latest
30+
permissions:
31+
actions: read
32+
contents: read
33+
security-events: write
34+
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
language: [ 'go' ]
39+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
40+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
41+
42+
steps:
43+
- name: Harden Runner
44+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481
45+
with:
46+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
47+
48+
- name: Checkout repository
49+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
50+
51+
# Initializes the CodeQL tools for scanning.
52+
- name: Initialize CodeQL
53+
uses: github/codeql-action/init@1b549b9259bda1cb5ddde3b41741a82a2d15a841
54+
with:
55+
languages: ${{ matrix.language }}
56+
# If you wish to specify custom queries, you can do so here or in a config file.
57+
# By default, queries listed here will override any specified in a config file.
58+
# Prefix the list here with "+" to use these queries and those in the config file.
59+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
60+
61+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
62+
# If this step fails, then you should remove it and run the build manually (see below)
63+
- name: Autobuild
64+
uses: github/codeql-action/autobuild@1b549b9259bda1cb5ddde3b41741a82a2d15a841
65+
66+
# ℹ️ Command-line programs to run using the OS shell.
67+
# 📚 https://git.io/JvXDl
68+
69+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
70+
# and modify them (or add more) to build your code if your project
71+
# uses a compiled language
72+
73+
#- run: |
74+
# make bootstrap
75+
# make release
76+
77+
- name: Perform CodeQL Analysis
78+
uses: github/codeql-action/analyze@1b549b9259bda1cb5ddde3b41741a82a2d15a841

.github/workflows/go.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
on: [push, pull_request]
2+
name: Unit Tests
3+
permissions: # added using https://github.com/step-security/secure-workflows
4+
contents: read
5+
6+
jobs:
7+
test:
8+
strategy:
9+
matrix:
10+
go-version: [1.20.x, 1.21.x, 1.22.x, 1.23.x]
11+
os: [ubuntu-latest, macos-latest, windows-latest]
12+
runs-on: ${{ matrix.os }}
13+
steps:
14+
- name: Harden Runner
15+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481
16+
with:
17+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
18+
19+
- name: Install Go
20+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b
21+
with:
22+
go-version: ${{ matrix.go-version }}
23+
- name: Checkout code
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
25+
- name: Test
26+
run: go test ./...

.github/workflows/golangci-lint.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: golangci-lint
2+
on: [push]
3+
permissions: # added using https://github.com/step-security/secure-workflows
4+
contents: read
5+
6+
jobs:
7+
golangci:
8+
permissions:
9+
contents: read # for actions/checkout to fetch code
10+
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
11+
name: lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Harden Runner
15+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481
16+
with:
17+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
18+
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
20+
- name: golangci-lint
21+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd
22+
with:
23+
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
24+
version: latest
25+
26+
# Optional: working directory, useful for monorepos
27+
# working-directory: somedir
28+
output: checkstyle
29+
30+
# Optional: golangci-lint command line arguments.
31+
# args: --issues-exit-code=0
32+
# args: --out-format checkstyle
33+
34+
# Optional: show only new issues if it's a pull request. The default value is `false`.
35+
# only-new-issues: true
36+
37+
# Optional: if set to true then the action will use pre-installed Go.
38+
# skip-go-installation: true
39+
40+
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
41+
# skip-pkg-cache: true
42+
43+
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
44+
# skip-build-cache: true

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2023 SingleStore, Inc
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# make formats, tests, and validates
2+
3+
4+
DOLLAR=$
5+
6+
all:
7+
git status | awk '/modified:/{print ${DOLLAR}NF}' | perl -n -e 'print if /\.go${DOLLAR}/' | xargs -r gofmt -w -s
8+
go mod tidy
9+
go test ./...
10+
golangci-lint run
11+
@ echo any output from the following command indicates an out-of-date direct dependency
12+
go list -u -m -f '{{if (and (not .Indirect) .Update)}}{{.}}{{end}}' all
13+
14+
misspell:;
15+
go install github.com/client9/misspell/cmd/misspell@latest
16+
misspell -w `find . -name \*.md`
17+

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
# wait
1+
# once - a nicer API for doing things once
2+
3+
[![GoDoc](https://godoc.org/github.com/singlestore-labs/once?status.svg)](https://pkg.go.dev/github.com/singlestore-labs/once)
4+
![unit tests](https://github.com/singlestore-labs/once/actions/workflows/go.yml/badge.svg)
5+
[![report card](https://goreportcard.com/badge/github.com/singlestore-labs/once)](https://goreportcard.com/report/github.com/singlestore-labs/once)
6+
[![codecov](https://codecov.io/gh/singlestore-labs/once/branch/main/graph/badge.svg)](https://codecov.io/gh/singlestore-labs/once)
7+
8+
Install:
9+
10+
go get github.com/singlestore-labs/once
11+
12+
---
13+
14+
Once is a small package that provides a nicer (as compared to sync.Once) API for doing
15+
things once.

go.mod

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module github.com/singlestore-labs/wait
2+
3+
go 1.20
4+
5+
require (
6+
github.com/memsql/errors v0.1.0
7+
github.com/stretchr/testify v1.10.0
8+
)
9+
10+
require (
11+
github.com/davecgh/go-spew v1.1.1 // indirect
12+
github.com/kr/text v0.2.0 // indirect
13+
github.com/pkg/errors v0.9.1 // indirect
14+
github.com/pmezard/go-difflib v1.0.0 // indirect
15+
gopkg.in/yaml.v3 v3.0.1 // indirect
16+
)

go.sum

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
2+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
3+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
5+
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
6+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
7+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
8+
github.com/memsql/errors v0.1.0 h1:TcYi6OOSlxrJhcgD79AdXGYzgb7+ZVLy71HEvPJylvM=
9+
github.com/memsql/errors v0.1.0/go.mod h1:82DslK+/CPzNprzYkjXk70ZHzzGCESIyv9PfH/hYcaQ=
10+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
11+
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
12+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
13+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
14+
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
15+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
16+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
17+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
18+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
19+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
20+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)