Skip to content

Commit

Permalink
ci(github-actions): add new workflow coverage: format, clippy and cov…
Browse files Browse the repository at this point in the history
…erage
  • Loading branch information
bioinformatist committed Jul 21, 2023
1 parent 6352e6d commit dfe6c05
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 6 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Coveralls

on:
push:
branches:
- main

jobs:
get-taos-version:
runs-on: ubuntu-latest

outputs:
taos-version: ${{ steps.gettaosversion.outputs.version }}

steps:
- uses: actions/checkout@v3

- name: Get taos version
id: gettaosversion
run: echo "version=$(cat TAOSVERSION)" >> $GITHUB_OUTPUT

coverage:
needs: get-taos-version
runs-on: ubuntu-latest

services:
tdengine:
image: tdengine/tdengine:${{ needs.get-taos-version.outputs.taos-version }}
ports:
- 6030:6030

steps:
- uses: actions/checkout@v3

- uses: dtolnay/rust-toolchain@nightly

- uses: taiki-e/install-action@cargo-tarpaulin

- name: Cache taosc
id: cache-taosc
uses: actions/cache@v3
with:
key: taosc-${{ needs.get-taos-version.outputs.taos-version }}
path: TDengine-client-${{ needs.get-taos-version.outputs.taos-version }}

- if: ${{ steps.cache-taosc.outputs.cache-hit != 'true' }}
name: Get taosc
run: |
curl -sO https://www.taosdata.com/assets-download/3.0/TDengine-client-${{ needs.get-taos-version.outputs.taos-version }}-Linux-x64-Lite.tar.gz
tar zxf TDengine-client-${{ needs.get-taos-version.outputs.taos-version }}-Linux-x64-Lite.tar.gz
- name: Install taosc
run: |
cd TDengine-client-${{ needs.get-taos-version.outputs.taos-version}}
./install_client.sh
- name: Coverage
run: cargo +nightly tarpaulin --follow-exec --post-test-delay 10 --coveralls ${{ secrets.COVERALLS_REPO_TOKEN }} -- --test-threads=1
64 changes: 64 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Tests

on:
pull_request:
types: [opened, synchronize]

jobs:
get-taos-version:
runs-on: ubuntu-latest

outputs:
taos-version: ${{ steps.gettaosversion.outputs.version }}

steps:
- uses: actions/checkout@v3

- name: Get taos version
id: gettaosversion
run: echo "version=$(cat TAOSVERSION)" >> $GITHUB_OUTPUT

tests:
needs: get-taos-version
runs-on: ubuntu-latest

services:
tdengine:
image: tdengine/tdengine:${{ needs.get-taos-version.outputs.taos-version }}
ports:
- 6030:6030

steps:
- uses: actions/checkout@v3

- name: Cache taosc
id: cache-taosc
uses: actions/cache@v3
with:
key: taosc-${{ needs.get-taos-version.outputs.taos-version }}
path: TDengine-client-${{ needs.get-taos-version.outputs.taos-version }}

- if: ${{ steps.cache-taosc.outputs.cache-hit != 'true' }}
name: Get taosc
run: |
curl -sO https://www.taosdata.com/assets-download/3.0/TDengine-client-${{ needs.get-taos-version.outputs.taos-version }}-Linux-x64-Lite.tar.gz
tar zxf TDengine-client-${{ needs.get-taos-version.outputs.taos-version }}-Linux-x64-Lite.tar.gz
- name: Install taosc
run: |
cd TDengine-client-${{ needs.get-taos-version.outputs.taos-version}}
./install_client.sh
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy

- name: Check format
run: cargo fmt --check --all

- name: Check clippy
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Test
run: cargo test -- --test-threads=1
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ members = [
"cml-core",
"cml-tdengine",
]
resolver = "2"

[workspace.dependencies]
anyhow = "1"
Expand Down
1 change: 1 addition & 0 deletions TAOSVERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.7.1
7 changes: 2 additions & 5 deletions cml-core/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ pub struct MetaData<F> {
impl<F> MetaData<F> {
pub fn get_placeholders(&self) -> (String, String) {
(
vec![
"?";
self.optional_tags.as_ref().map_or(0, |v| v.len()) + self.inherent_tag_num
]
.join(", "),
vec!["?"; self.optional_tags.as_ref().map_or(0, |v| v.len()) + self.inherent_tag_num]
.join(", "),
vec!["?"; self.optional_field_num + self.inherent_field_num].join(", "),
)
}
Expand Down
3 changes: 3 additions & 0 deletions cml-tdengine/src/core/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ mod tests {

cml.run(config, build_fn, build_fn)?;

taos.exec("DROP DATABASE IF EXISTS training_data")?;
taos.exec("DROP DATABASE IF EXISTS task")?;

Ok(())
}
}
2 changes: 1 addition & 1 deletion cml-tdengine/src/models/stables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<'a> STable<'a> {
fn field_to_stmt(fields: &[Field]) -> String {
fields
.iter()
.map(|f| format!("{}", f.sql_repr()))
.map(|f| f.sql_repr().to_string())
.collect::<Vec<String>>()
.join(",")
}
Expand Down

0 comments on commit dfe6c05

Please sign in to comment.