[Enhancement] Reintroduce the MapStore
interface and SimpleMap
and make the Badger
a submodules
#157
Workflow file for this run
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
name: Test & Build | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
- release/** | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} | |
cancel-in-progress: true | |
env: | |
TARGET_GOLANG_VERSION: "1.20.12" | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: "0" | |
- name: Setup go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.TARGET_GOLANG_VERSION }} | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: latest | |
args: --timeout=10m | |
skip-cache: true | |
only-new-issues: true | |
- name: Install gocovmerge | |
run: go install github.com/wadey/gocovmerge@latest | |
- name: Create coverage report and run tests | |
run: | | |
set -euo pipefail | |
go test -v -p 1 ./ -mod=readonly -race -coverprofile=coverage1.txt -covermode=atomic | |
go test -v -p 1 ./kvstore/... -race -coverprofile=coverage2.txt -covermode=atomic | |
go test -v -p 1 ./kvstore/badger/... -mod=readonly -race -coverprofile=coverage3.txt -covermode=atomic | |
# Combine coverage reports | |
gocovmerge coverage1.txt coverage2.txt coverage3.txt > coverage.txt | |
- name: Sanitize test results | |
# We're utilizing `tee` above which can capture non-json stdout output so we need to remove non-json lines before additional parsing and submitting it to the external github action. | |
run: cat test_results.json | jq -c -R 'fromjson? | select(type == "object")' > tmp.json && mv tmp.json test_results.json | |
- name: Output test failures | |
# Makes it easier to find failed tests so no need to scroll through the whole log. | |
if: ${{ failure() }} | |
run: | | |
jq --argjson fail_tests "$(jq -c -r 'select(.Action == "fail") | select(.Test) | .Test' test_results.json | jq -R -s -c -r 'split("\n") | map(select(length>0))')" 'select(.Test as $t | ($fail_tests | arrays)[] | select($t == .)) | select(.Output) | .Output' test_results.json | jq -r | sed ':a;N;$!ba;s/\n\n/\n/g' > test_failures.json | |
cat test_failures.json | |
exit 1 | |
- name: Upload test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results | |
path: | | |
test_*.json | |
- name: Annotate tests on GitHub | |
# Only annotate if the test failed on target version to avoid duplicated annotations on GitHub. | |
uses: guyarb/[email protected] | |
with: | |
test-results: test_results.json | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./coverage.txt | |
build: | |
runs-on: ubuntu-latest | |
needs: tests | |
strategy: | |
fail-fast: false | |
matrix: | |
goarch: ["arm64", "amd64"] | |
timeout-minutes: 5 | |
name: Build for ${{ matrix.goarch }} | |
steps: | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.TARGET_GOLANG_VERSION }} | |
- uses: actions/checkout@v3 | |
- uses: technote-space/get-diff-action@v4 | |
with: | |
PATTERNS: | | |
**/**.go | |
go.mod | |
go.sum | |
- name: Go build | |
run: GOOS=linux GOARCH=${{ matrix.goarch }} go build | |
if: env.GIT_DIFF |