Skip to content

Commit

Permalink
ci: introduce typo check (openGemini#38)
Browse files Browse the repository at this point in the history
Signed-off-by: ZhangJian He <[email protected]>
  • Loading branch information
ZhangJian He authored May 20, 2024
1 parent d155be4 commit 5f984be
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/line_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches:
- main
jobs:
build:
line_lint:
name: line lint
runs-on: ubuntu-latest
steps:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/typo_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: typo check
on:
pull_request:
branches:
- main
jobs:
typo_check:
name: typo check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check typos
uses: crate-ci/typos@master
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ public CompletableFuture<Void> createDatabase(String database) {
String command = "CREATE DATABASE \"%s\"".formatted(database);
Query query = new Query(command);
String queryUrl = getQueryUrl(query);
return httpExcute(queryUrl, QueryResult.class, UrlConst.POST).thenApply(rsp -> null);
return httpExecute(queryUrl, QueryResult.class, UrlConst.POST).thenApply(rsp -> null);
}

public CompletableFuture<Void> dropDatabase(String database) {
String command = "DROP DATABASE \"%s\"".formatted(database);
Query query = new Query(command);
String queryUrl = getQueryUrl(query);
return httpExcute(queryUrl, QueryResult.class, UrlConst.POST).thenApply(rsp -> null);
return httpExecute(queryUrl, QueryResult.class, UrlConst.POST).thenApply(rsp -> null);
}

public CompletableFuture<List<String>> showDatabases() {
String command = "SHOW DATABASES";
Query query = new Query(command);
String queryUrl = getQueryUrl(query);
return httpExcute(queryUrl, QueryResult.class)
return httpExecute(queryUrl, QueryResult.class)
.thenApply(rsp -> rsp.getResults().get(0).getSeries().get(0).getValues().stream()
.map(x -> String.valueOf(x.get(0))).toList());
}
Expand Down Expand Up @@ -94,7 +94,7 @@ public CompletableFuture<Void> createRetentionPolicy(String database, RpConfig r
}
Query query = new Query(command.toString());
String queryUrl = getQueryUrl(query);
return httpExcute(queryUrl, QueryResult.class, UrlConst.POST).thenApply(rsp -> null);
return httpExecute(queryUrl, QueryResult.class, UrlConst.POST).thenApply(rsp -> null);
}

private List<RetentionPolicy> converseRps(List<List<Object>> queryRpValues) {
Expand Down Expand Up @@ -126,47 +126,47 @@ public CompletableFuture<List<RetentionPolicy>> showRetentionPolicies(String dat
query.setDatabase(database);

String queryUrl = getQueryUrl(query);
return httpExcute(queryUrl, QueryResult.class)
return httpExecute(queryUrl, QueryResult.class)
.thenApply(rsp -> converseRps(rsp.getResults().get(0).getSeries().get(0).getValues()));
}

public CompletableFuture<Void> dropRetentionPolicy(String database, String retentionPolicy) {
String command = "DROP RETENTION POLICY %s ON \"%s\"".formatted(retentionPolicy, database);
Query query = new Query(command);
String queryUrl = getQueryUrl(query);
return httpExcute(queryUrl, QueryResult.class, UrlConst.POST).thenApply(rsp -> null);
return httpExecute(queryUrl, QueryResult.class, UrlConst.POST).thenApply(rsp -> null);
}

public CompletableFuture<QueryResult> query(Query query) {
String queryUrl = getQueryUrl(query);
return httpExcute(queryUrl, QueryResult.class);
return httpExecute(queryUrl, QueryResult.class);
}

public CompletableFuture<Void> write(String database, Point point) {
String writeUrl = getWriteUrl(database);
String body = point.toString();

return httpExcute(writeUrl, Void.class, UrlConst.POST, HttpRequest.BodyPublishers.ofString(body));
return httpExecute(writeUrl, Void.class, UrlConst.POST, HttpRequest.BodyPublishers.ofString(body));
}

public CompletableFuture<Void> writeBatch(String database, List<Point> points) {
String writeUrl = getWriteUrl(database);
StringJoiner sj = new StringJoiner("\n");
points.forEach(point -> sj.add(point.toString()));

return httpExcute(writeUrl, Void.class, UrlConst.POST, HttpRequest.BodyPublishers.ofString(sj.toString()));
return httpExecute(writeUrl, Void.class, UrlConst.POST, HttpRequest.BodyPublishers.ofString(sj.toString()));
}

private <T> CompletableFuture<T> httpExcute(String url, Class<T> type) {
return httpExcute(url, type, UrlConst.GET);
private <T> CompletableFuture<T> httpExecute(String url, Class<T> type) {
return httpExecute(url, type, UrlConst.GET);
}

private <T> CompletableFuture<T> httpExcute(String url, Class<T> type, String method) {
return httpExcute(url, type, method, HttpRequest.BodyPublishers.noBody());
private <T> CompletableFuture<T> httpExecute(String url, Class<T> type, String method) {
return httpExecute(url, type, method, HttpRequest.BodyPublishers.noBody());
}

private <T> CompletableFuture<T> httpExcute(String url, Class<T> type,
String method, HttpRequest.BodyPublisher bodyPublisher) {
private <T> CompletableFuture<T> httpExecute(String url, Class<T> type,
String method, HttpRequest.BodyPublisher bodyPublisher) {
CompletableFuture<HttpResponse<String>> future;
if (UrlConst.GET.equals(method)) {
future = get(url);
Expand Down

0 comments on commit 5f984be

Please sign in to comment.