-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
174 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
name: Go | ||
on: | ||
pull_request: | ||
types: | ||
- unlabeled # if GitHub Actions stuck, add and remove "not ready" label to force rebuild | ||
- opened | ||
- reopened | ||
- synchronize | ||
push: | ||
branches: | ||
- main | ||
schedule: | ||
- cron: "12 3 * * *" | ||
|
||
env: | ||
GOPATH: /home/runner/go | ||
GOCACHE: /home/runner/go/cache | ||
GOLANGCI_LINT_CACHE: /home/runner/go/cache/lint | ||
GOMODCACHE: /home/runner/go/mod | ||
GOPROXY: https://proxy.golang.org | ||
GOTOOLCHAIN: local | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 10 | ||
|
||
# Do not run this job in parallel for any PR change or branch push. | ||
concurrency: | ||
group: ${{ github.workflow }}-tests-${{ github.head_ref || github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready') | ||
|
||
steps: | ||
# TODO https://github.com/FerretDB/github-actions/issues/211 | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go | ||
uses: FerretDB/github-actions/setup-go@main | ||
with: | ||
cache-key: tests | ||
|
||
- name: Install Task | ||
run: go generate -x | ||
working-directory: tools | ||
|
||
- name: Run init | ||
run: bin/task init | ||
|
||
- name: Run tests | ||
run: bin/task test | ||
env: | ||
GOFLAGS: ${{ runner.debug == '1' && '-v' || '' }} | ||
|
||
# we don't want them on CI | ||
- name: Clean test and fuzz caches | ||
if: always() | ||
run: go clean -testcache -fuzzcache | ||
|
||
- name: Check dirty | ||
run: | | ||
git status | ||
git diff --exit-code | ||
linters: | ||
name: Linters | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 5 | ||
|
||
# Do not run this job in parallel for any PR change or branch push. | ||
concurrency: | ||
group: ${{ github.workflow }}-linters-${{ github.head_ref || github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready') | ||
|
||
steps: | ||
# TODO https://github.com/FerretDB/github-actions/issues/211 | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # for `golangci-lint run --new` to work | ||
|
||
- name: Setup Go | ||
uses: FerretDB/github-actions/setup-go@main | ||
with: | ||
cache-key: linters | ||
|
||
- name: Run linters | ||
uses: FerretDB/github-actions/linters@main | ||
|
||
- name: Format and lint documentation | ||
run: bin/task docs-fmt |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2021 FerretDB Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package runner | ||
|
||
import ( | ||
"bytes" | ||
"sync" | ||
) | ||
|
||
// LockedBuffer is a thread-safe [bytes.Buffer]. | ||
type LockedBuffer struct { | ||
b bytes.Buffer | ||
m sync.Mutex | ||
} | ||
|
||
// Bytes calls [bytes.Buffer.Write] in a thread-safe way. | ||
func (lb *LockedBuffer) Write(p []byte) (int, error) { | ||
lb.m.Lock() | ||
defer lb.m.Unlock() | ||
|
||
return lb.b.Write(p) | ||
} | ||
|
||
// Bytes calls [bytes.Buffer.Bytes] in a thread-safe way. | ||
func (lb *LockedBuffer) Bytes() []byte { | ||
lb.m.Lock() | ||
defer lb.m.Unlock() | ||
|
||
return lb.b.Bytes() | ||
} |