Skip to content

Commit

Permalink
refactor: CLI client interface (#1839)
Browse files Browse the repository at this point in the history
## Relevant issue(s)

Closes #1472
Closes #1507
Closes #1860 

## Description

This is a follow up to #1776

This PR adds a CLI implementation that implements the client.DB
interface and runs through the existing integration test suite.

- [x] Merge existing server config code
- [x] Refactor CLI to use new HTTP client
- [x] Remove `net/api` package
- [x] Remove `api/http` package
- [x] Lens tests are timing out in CI: fixed #1862
- [x] Code coverage is incorrectly reporting: fixed #1861
- [x] Flaky test causing failures: fixed #1912

Renamed Commands:
- `peerid` to `client peer info`
- `client p2pcollection` to `client p2p collection`
- `client replicator` to `client p2p replicator`
- `client schema list` to `client collection describe`

Removed Commands:
- `block get`
- `ping`
- `rpc`

Added Commands:
- `client collection create`
- `client collection delete`
- `client collection get`
- `client collection keys`
- `client collection update`
- `client tx create`
- `client tx discard`
- `client tx commit`
- `client schema migration up`
- `client schema migration down`
- `client schema migration reload`

**Notes for reviewers**:
- `.github` changes are merged from #1871
- `Makefile` most of these changes are also from #1871
- `docs/cli` ignore these changes, it will be updated next release
- sorry for all of the merge commits, I am working on learning rebase
flow

## Tasks

- [x] I made sure the code is well commented, particularly
hard-to-understand areas.
- [x] I made sure the repository-held documentation is changed
accordingly.
- [x] I made sure the pull request title adheres to the conventional
commit style (the subset used in the project can be found in
[tools/configs/chglog/config.yml](tools/configs/chglog/config.yml)).
- [x] I made sure to discuss its limitations such as threats to
validity, vulnerability to mistake and misuse, robustness to
invalidation of assumptions, resource requirements, ...

## How has this been tested?

`make test`

Specify the platform(s) on which this was tested:
- MacOS
  • Loading branch information
nasdf authored Oct 2, 2023
1 parent 6244c5b commit 4c3df48
Show file tree
Hide file tree
Showing 185 changed files with 4,000 additions and 13,916 deletions.
76 changes: 0 additions & 76 deletions .github/workflows/code-test-coverage.yml

This file was deleted.

55 changes: 0 additions & 55 deletions .github/workflows/detect-change.yml

This file was deleted.

103 changes: 103 additions & 0 deletions .github/workflows/run-tests-and-upload-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# 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: Run Tests And Upload Coverage Workflow

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- master
- develop

jobs:
run-tests:
name: Run tests matrix job

runs-on: ubuntu-latest

strategy:
matrix:
client-type: [go, http, cli]
database-type: [badger-file, badger-memory]
mutation-type: [gql, collection-named, collection-save]
detect-changes: [false]
include:
- client-type: go
database-type: badger-memory
mutation-type: collection-save
detect-changes: true

env:
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_MUTATION_TYPE: ${{ matrix.mutation-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.20"
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.client-type }}_${{ matrix.database-type }}_${{ matrix.mutation-type }}
path: coverage.txt
if-no-files-found: error
retention-days: 1

upload-coverage:
name: Upload test code coverage job

runs-on: ubuntu-latest

needs: run-tests

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@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: defradb-codecov
flags: all-tests
os: 'linux'
fail_ci_if_error: true
verbose: true
50 changes: 0 additions & 50 deletions .github/workflows/run-tests.yml

This file was deleted.

54 changes: 0 additions & 54 deletions .github/workflows/test-collection-named.yml

This file was deleted.

48 changes: 0 additions & 48 deletions .github/workflows/test-gql-mutations.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cmd/defradb/defradb
cmd/genclidocs/genclidocs
cmd/genmanpages/genmanpages
coverage.txt
coverage
tests/bench/*.log
tests/bench/*.svg

Expand Down
Loading

0 comments on commit 4c3df48

Please sign in to comment.