Skip to content

Prepare CI for testing with FerretDB v2 #266

Prepare CI for testing with FerretDB v2

Prepare CI for testing with FerretDB v2 #266

Workflow file for this run

---
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 0 * * *"
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
MONGODB_URI: mongodb://localhost:27017/
jobs:
test:
name: Test ${{ matrix.dockerfile }}
runs-on: ubuntu-22.04
timeout-minutes: 15
# Do not run this job in parallel for any PR change or branch push.
concurrency:
group: ${{ github.workflow }}-test-${{ matrix.dockerfile }}-${{ 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')
strategy:
fail-fast: false
matrix:
dockerfile: [mongo, ferretdb1, ferretdb2]
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: test
- name: Install Task and tools
run: go generate -x
working-directory: tools
- name: Init
run: bin/task init
- name: Run code generators (and formatters)
run: bin/task gen
- name: Run short tests
run: bin/task test-short
- name: Start development environment
run: bin/task env-up-detach
env:
DOCKERFILE: ${{ matrix.dockerfile }}
- name: Run all tests
run: bin/task test
- name: Get logs
if: always()
run: bin/task env-logs
- name: Run linters
run: bin/task lint
# The token is not required but should make uploads more stable.
# If secrets are unavailable (for example, for a pull request from a fork), it fallbacks to the tokenless uploads.
#
# Unfortunately, it seems that tokenless uploads fail too often.
# See https://github.com/codecov/feedback/issues/301.
#
# We also can't use ${{ vars.CODECOV_TOKEN }}: https://github.com/orgs/community/discussions/44322
- name: Upload coverage information to codecov
if: always()
uses: codecov/codecov-action@v4
with:
token: 69371c38-548a-488e-8843-bfbbf32810bd
files: ./cover.txt
flags: test
fail_ci_if_error: true
verbose: true
- name: Upload coverage information to coveralls
uses: coverallsapp/github-action@v2
with:
file: ./cover.txt
flag-name: test
- name: Check dirty
run: |
git status
git diff --exit-code
fuzz:
name: Fuzz
runs-on: ubuntu-22.04
timeout-minutes: 15
# Do not run this job in parallel for any PR change or branch push.
concurrency:
group: ${{ github.workflow }}-fuzz-${{ 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: fuzz
- name: Install Task and tools
run: go generate -x
working-directory: tools
- name: Run fuzzers
run: bin/task fuzz