refactor: Extract definition stuff from collection.go (#2706) #1780
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
# Copyright 2022 Democratized Data Foundation | |
# | |
# Use of this software is governed by the Business Source License | |
# included in the file licenses/BSL.txt. | |
# | |
# As of the Change Date specified in that file, in accordance with | |
# the Business Source License, use of this software will be governed | |
# by the Apache License, Version 2.0, included in the file | |
# licenses/APL.txt. | |
name: Test And Upload Coverage Workflow | |
on: | |
pull_request: | |
branches: | |
- master | |
- develop | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
branches: | |
- master | |
- develop | |
jobs: | |
run-tests: | |
name: Run tests matrix job | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
client-type: [go, http, cli] | |
database-type: [badger-file, badger-memory] | |
mutation-type: [gql, collection-named, collection-save] | |
lens-type: [wasm-time] | |
detect-changes: [false] | |
database-encryption: [false] | |
include: | |
- os: ubuntu-latest | |
client-type: go | |
database-type: badger-memory | |
mutation-type: collection-save | |
lens-type: wasm-time | |
detect-changes: true | |
database-encryption: false | |
- os: ubuntu-latest | |
client-type: go | |
database-type: badger-memory | |
mutation-type: collection-save | |
lens-type: wasm-time | |
detect-changes: false | |
database-encryption: true | |
- os: macos-latest | |
client-type: go | |
database-type: badger-memory | |
mutation-type: collection-save | |
lens-type: wasm-time | |
detect-changes: false | |
database-encryption: false | |
## TODO: https://github.com/sourcenetwork/defradb/issues/2080 | |
## Uncomment the lines below to Re-enable the windows build once this todo is resolved. | |
## - os: windows-latest | |
## client-type: go | |
## database-type: badger-memory | |
## mutation-type: collection-save | |
## detect-changes: false | |
## database-encryption: false | |
- os: ubuntu-latest | |
client-type: go | |
database-type: badger-memory | |
mutation-type: collection-save | |
lens-type: wazero | |
detect-changes: false | |
database-encryption: false | |
- os: ubuntu-latest | |
client-type: go | |
database-type: badger-memory | |
mutation-type: collection-save | |
lens-type: wasmer | |
detect-changes: false | |
database-encryption: false | |
runs-on: ${{ matrix.os }} | |
# We run all runners via the bash shell to provide us with a consistent set of env variables and commands | |
defaults: | |
run: | |
shell: bash | |
env: | |
CGO_ENABLED: 1 | |
DEFRA_CLIENT_GO: ${{ matrix.client-type == 'go' }} | |
DEFRA_CLIENT_HTTP: ${{ matrix.client-type == 'http' }} | |
DEFRA_CLIENT_CLI: ${{ matrix.client-type == 'cli' }} | |
DEFRA_BADGER_MEMORY: ${{ matrix.database-type == 'badger-memory' }} | |
DEFRA_BADGER_FILE: ${{ matrix.database-type == 'badger-file' }} | |
DEFRA_BADGER_ENCRYPTION: ${{ matrix.database-encryption }} | |
DEFRA_MUTATION_TYPE: ${{ matrix.mutation-type }} | |
DEFRA_LENS_TYPE: ${{ matrix.lens-type }} | |
steps: | |
- name: Checkout code into the directory | |
uses: actions/checkout@v3 | |
- name: Setup Go environment explicitly | |
uses: actions/setup-go@v3 | |
with: | |
go-version: "1.21" | |
check-latest: true | |
- name: Build dependencies | |
run: | | |
make deps:modules | |
make deps:test | |
- name: Run integration tests | |
if: ${{ !matrix.detect-changes }} | |
run: make test:coverage | |
- name: Run change detector tests | |
if: ${{ matrix.detect-changes }} | |
run: make test:changes | |
- name: Upload coverage artifact | |
if: ${{ !matrix.detect-changes }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.os }}_${{ matrix.client-type }}_${{ matrix.database-type }}_${{ matrix.mutation-type }} | |
path: coverage.txt | |
if-no-files-found: error | |
retention-days: 7 | |
upload-coverage: | |
name: Upload test code coverage job | |
needs: run-tests | |
# Important to know: | |
# - We didn't use `if: always()` here, so this job doesn't run if we manually canceled. | |
# - `if: success()` is always implied unless `always()` or `failure()` is specified. | |
if: success() || failure() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code into the directory | |
uses: actions/checkout@v3 | |
- name: Download coverage reports | |
uses: actions/download-artifact@v3 | |
with: | |
path: coverage_reports | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
name: defradb-codecov | |
flags: all-tests | |
os: 'linux' | |
fail_ci_if_error: true | |
verbose: true |