Skip to content

Add blog post "FerretDB Demo: Launch and Test a Database in Minutes" #16672

Add blog post "FerretDB Demo: Launch and Test a Database in Minutes"

Add blog post "FerretDB Demo: Launch and Test a Database in Minutes" #16672

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
- releases/*
schedule:
- cron: "12 0 * * *"
# Do not run this workflow in parallel for any PR change.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: false
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
jobs:
short-test:
name: Short test
runs-on: ubuntu-22.04
timeout-minutes: 10
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready')
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # for `git describe` to work
lfs: false # LFS is used only by website
- name: Setup Go
uses: FerretDB/github-actions/setup-go@main
with:
cache-key: short-test
- name: Install Task
run: go generate -x
working-directory: tools
- name: Run init
run: bin/task init
- name: Run short unit tests
run: bin/task test-unit-short
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
test:
name: Test
runs-on: ubuntu-22.04
timeout-minutes: 10
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready')
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # for `git describe` to work
lfs: false # LFS is used only by website
- name: Setup Go
uses: FerretDB/github-actions/setup-go@main
with:
cache-key: test
- name: Install Task
run: go generate -x
working-directory: tools
- name: Start environment
run: bin/task env-up-detach
- name: Run init
run: bin/task init
- name: Regenerate and reformat
run: bin/task gen
- name: Build bin/ferretdb
run: bin/task build-host
- name: Wait for and setup environment
run: bin/task env-setup
- name: Run unit tests
run: bin/task test-unit
env:
GOFLAGS: ${{ runner.debug == '1' && '-v' || '' }}
# 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/codecov-action/issues/837.
#
# We also can't use ${{ vars.CODECOV_TOKEN }}: https://github.com/orgs/community/discussions/44322
- name: Upload coverage information to codecov
uses: codecov/codecov-action@v3
with:
token: 22159d7c-856d-4fe9-8fdb-5d9ecff35514
files: ./cover.txt
flags: unit
fail_ci_if_error: true
verbose: true
- name: Upload coverage information to coveralls
uses: coverallsapp/github-action@v2
with:
file: ./cover.txt
flag-name: unit
parallel: true
# 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
integration:
name: Integration ${{ matrix.name }} ${{ matrix.shard_index }}/${{ matrix.shard_total }}
runs-on:
group: paid
timeout-minutes: 20
# Do not run this job in parallel for any PR change or branch/tag push
# to save some resources.
concurrency:
group: ${{ github.workflow }}-${{ matrix.name }}-${{ matrix.shard_index }}-${{ 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:
include:
- { name: "MongoDB", task: "mongodb", shard_index: 1, shard_total: 1 }
- { name: "PostgreSQL", task: "pg", shard_index: 1, shard_total: 3 }
- { name: "PostgreSQL", task: "pg", shard_index: 2, shard_total: 3 }
- { name: "PostgreSQL", task: "pg", shard_index: 3, shard_total: 3 }
- { name: "SQLite", task: "sqlite", shard_index: 1, shard_total: 3 }
- { name: "SQLite", task: "sqlite", shard_index: 2, shard_total: 3 }
- { name: "SQLite", task: "sqlite", shard_index: 3, shard_total: 3 }
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # for `git describe` to work
lfs: false # LFS is used only by website
- name: Setup Go
uses: FerretDB/github-actions/setup-go@main
with:
cache-key: integration
- name: Install Task
run: go generate -x
working-directory: tools
- name: Start environment
run: bin/task env-up-detach
- name: Run init
run: bin/task init
- name: Wait for and setup environment
run: bin/task env-setup
- name: Run ${{ matrix.name }} tests (${{ matrix.shard_index }}/${{ matrix.shard_total }})
run: bin/task test-integration-${{ matrix.task }} SHARD_INDEX=${{ matrix.shard_index }} SHARD_TOTAL=${{ matrix.shard_total }}
env:
GOFLAGS: ${{ runner.debug == '1' && '-v' || '' }}
# 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/codecov-action/issues/837.
#
# We also can't use ${{ vars.CODECOV_TOKEN }}: https://github.com/orgs/community/discussions/44322
- name: Upload coverage information to codecov
uses: codecov/codecov-action@v3
with:
token: 22159d7c-856d-4fe9-8fdb-5d9ecff35514
files: ./integration/integration-${{ matrix.task }}.txt
flags: integration,${{ matrix.task }},shard-${{ matrix.shard_index }}
fail_ci_if_error: true
verbose: true
- name: Upload coverage information to coveralls
uses: coverallsapp/github-action@v2
with:
file: ./integration/integration-${{ matrix.task }}.txt
flag-name: integration-${{ matrix.task }}-${{ matrix.shard_index }}
parallel: true
# 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
# https://github.com/lemurheavy/coveralls-public/issues/1636
submit-coveralls:
name: Submit final coveralls report
runs-on: ubuntu-22.04
needs: [test, integration]
if: always() && (github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready'))
steps:
- name: Submit coveralls
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
env-data:
name: env-data
runs-on: ubuntu-22.04
timeout-minutes: 10
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready')
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # for `git describe` to work
lfs: false # LFS is used only by website
- name: Setup Go
uses: FerretDB/github-actions/setup-go@main
with:
cache-key: env-data
- name: Install Task
run: go generate -x
working-directory: tools
- name: Start environment
run: bin/task env-up-detach
- name: Run init
run: bin/task init
- name: Wait for and setup environment
run: bin/task env-setup
- name: Run env-data
run: bin/task env-data
env:
GOFLAGS: ${{ runner.debug == '1' && '-v' || '' }}
golangci-lint:
name: golangci-lint
runs-on: ubuntu-22.04
timeout-minutes: 10
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready')
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # for `golangci-lint run --new` to work
lfs: false # LFS is used only by website
- name: Setup Go
uses: FerretDB/github-actions/setup-go@main
with:
cache-key: lint
- name: Run linters
uses: FerretDB/github-actions/linters@main
fuzz-short:
name: Fuzz short
runs-on: ubuntu-22.04
timeout-minutes: 10
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready')
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
path: source
fetch-depth: 0 # for `git describe` to work
lfs: false # LFS is used only by website
- name: Setup Go
uses: FerretDB/github-actions/setup-go@main
with:
cache-key: fuzz
- name: Install Task
run: go generate -x
working-directory: source/tools
# Use deploy key instead of Personal Access Token (PAT) to limit access to one repository.
# If secrets are not available (for example, for a pull request from a fork), GITHUB_TOKEN PAT is used automatically.
- name: Checkout collected fuzz corpus
uses: actions/checkout@v3
with:
repository: FerretDB/fuzz-corpus
ssh-key: ${{ secrets.FUZZ_CORPUS_DEPLOY_KEY }}
path: fuzz-corpus
fetch-depth: 0 # for commit and push to work
- name: Start environment
run: bin/task env-up-detach
working-directory: source
- name: Run init
run: bin/task init
working-directory: source
- name: Setup corpus
run: bin/task fuzz-corpus
working-directory: source
- name: Wait for and setup environment
run: bin/task env-setup
working-directory: source
# precompile tests with unset GOMAXPROCS
- name: Init fuzzers
run: bin/task fuzz-init
working-directory: source
# TODO https://github.com/FerretDB/FerretDB/issues/238
# TODO https://github.com/FerretDB/FerretDB/issues/344
- name: Run collected fuzzing corpus
run: bin/task fuzz FUZZTIME=1s
working-directory: source
env:
GOMAXPROCS: 1 # otherwise, oom-killer kills fuzzer too often
- name: Collect corpus
if: always()
run: |
bin/task fuzz-corpus
go run ./cmd/fuzztool corpus seed ../fuzz-corpus
working-directory: source
# `secrets` are not supported in `if`, so we have to do this trick with environment variable:
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
# https://github.com/actions/runner/issues/520
- name: Push corpus if possible
if: always() && env.KEY != ''
env:
KEY: ${{ secrets.FUZZ_CORPUS_DEPLOY_KEY }}
run: |
git config user.name ferretdb-bot
git config user.email ferretdb-bot@ferretdb.io
git add --all .
git diff-index --patch
git diff-index --quiet HEAD || git commit --message 'Update corpus'
git fetch
git rebase origin/main
git push
working-directory: fuzz-corpus
- name: Upload corpus if push is not possible
if: failure() && env.KEY == ''
env:
KEY: ${{ secrets.FUZZ_CORPUS_DEPLOY_KEY }}
uses: actions/upload-artifact@v3
with:
name: fuzz-corpus
path: fuzz-corpus.zip
retention-days: 1
if-no-files-found: error
- name: Collect Linux logs
if: failure()
run: |
mkdir -p /tmp/logs
ls -al /var/log/
sudo cp /var/log/syslog /tmp/logs/
sudo free > /tmp/logs/free.txt
sudo chmod 0666 /tmp/logs/*
working-directory: source
- name: Compress Linux logs before upload
if: failure()
run: zip -r -q -9 linux-logs.zip /tmp/logs
- name: Upload Linux logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: linux-logs
path: linux-logs.zip
retention-days: 1
if-no-files-found: error
# 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
working-directory: source