From ceb9eb5468fef61218c61bc3941035c3717840cd Mon Sep 17 00:00:00 2001 From: Anatolios Laskaris Date: Mon, 20 Mar 2023 08:54:20 +0200 Subject: [PATCH] chore: Add to e2e (#12) --- .cargo/config.toml | 2 + .github/workflows/ci.yml | 33 +++------------ .github/workflows/e2e.yml | 77 ++++++++++++++++++++++++++++++++++ .github/workflows/snapshot.yml | 74 ++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 49 ++++++++++++++++++++++ Cargo.toml | 2 +- build.sh | 7 +++- 7 files changed, 214 insertions(+), 30 deletions(-) create mode 100644 .cargo/config.toml create mode 100644 .github/workflows/e2e.yml create mode 100644 .github/workflows/snapshot.yml create mode 100644 .github/workflows/tests.yml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..325ec1c --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[registries] +fluence = { index = "git://crates.fluence.dev/index" } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8aeb18..d50a3d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: ci +name: "ci" on: pull_request: @@ -14,30 +14,7 @@ concurrency: jobs: tests: - name: "cargo test" - runs-on: ubuntu-latest - timeout-minutes: 60 - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Rust toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - - - name: Install marine - uses: baptiste0928/cargo-install@v1.3.0 - with: - crate: marine - - - name: Build - run: ./build.sh - - - name: Run cargo test - run: cargo test --release --all-features - - - name: Run cargo fmt - run: cargo fmt --all -- --check - - # - name: Run cargo clippy - # run: cargo clippy --all --all-features + name: "Run tests" + uses: ./.github/workflows/tests.yml + with: + ref: ${{ github.ref }} diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 0000000..79caf9e --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,77 @@ +name: "e2e" + +on: + pull_request: + paths-ignore: + - "**.md" + push: + branches: + - "master" + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + snapshot: + name: "sqlite-wasm" + uses: ./.github/workflows/snapshot.yml + with: + ref: ${{ github.ref }} + + registry: + needs: + - snapshot + uses: fluencelabs/registry/.github/workflows/tests.yml@main + with: + cargo-dependencies: | + [ + { + "package": "marine-sqlite-connector", + "version": "=${{ needs.snapshot.outputs.version }}", + "registry": "fluence" + } + ] + + spell: + needs: + - snapshot + uses: fluencelabs/spell/.github/workflows/snapshot.yml@main + with: + cargo-dependencies: | + [ + { + "package": "marine-sqlite-connector", + "version": "=${{ needs.snapshot.outputs.version }}", + "registry": "fluence" + } + ] + + rust-peer: + needs: + - spell + + uses: fluencelabs/rust-peer/.github/workflows/snapshot.yml@master + with: + image-name: "docker.fluence.dev/sqlite-wasm-connector" + cargo-dependencies: | + [ + { + "package": "fluence-spell-dtos", + "version": "=${{ needs.spell.outputs.cargo-version }}", + "registry": "fluence" + }, + { + "package": "fluence-spell-distro", + "version": "=${{ needs.spell.outputs.cargo-version }}", + "registry": "fluence" + } + ] + + spell-aqua-tests: + name: "spell" + needs: + - rust-peer + uses: fluencelabs/spell/.github/workflows/tests.yml@main + with: + rust-peer-image: "${{ needs.rust-peer.outputs.rust-peer-image }}" diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 0000000..129c674 --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,74 @@ +name: Publish snapshots + +on: + workflow_call: + inputs: + ref: + description: "GitHub ref to checkout to" + type: string + default: "master" + outputs: + version: + description: "snapshot version" + value: ${{ jobs.snapshot.outputs.version }} + +jobs: + snapshot: + name: "Publish snapshot" + runs-on: ubuntu-latest + timeout-minutes: 60 + + outputs: + version: "${{ steps.snapshot.outputs.version }}" + + permissions: + contents: read + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + repository: fluencelabs/sqlite-wasm-connector + ref: ${{ inputs.ref }} + + - name: Import secrets + uses: hashicorp/vault-action@v2.5.0 + with: + url: https://vault.fluence.dev + path: jwt/github + role: ci + method: jwt + jwtGithubAudience: "https://github.com/fluencelabs" + jwtTtl: 300 + exportToken: false + secrets: | + kv/cargo-registry/users/ci token | CARGO_REGISTRIES_FLUENCE_TOKEN + + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install marine + uses: baptiste0928/cargo-install@v1.3.0 + with: + crate: marine + + - name: Download sqlite-wasm + continue-on-error: true + uses: actions/download-artifact@v3 + with: + name: sqlite-wasm + path: artifacts/ + + - name: Build + run: ./build.sh + + - name: Generate snapshot version + id: version + uses: fluencelabs/github-actions/generate-snapshot-id@main + + - name: Publish snapshot + id: snapshot + uses: fluencelabs/github-actions/cargo-publish-snapshot@main + with: + id: ${{ steps.version.outputs.id }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..4b526f1 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,49 @@ +name: Run tests + +on: + workflow_call: + inputs: + ref: + description: "git ref to checkout to" + type: string + default: "master" + +jobs: + tests: + name: "cargo test" + runs-on: ubuntu-latest + timeout-minutes: 60 + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + repository: fluencelabs/sqlite-wasm-connector + ref: ${{ inputs.ref }} + + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install marine + uses: baptiste0928/cargo-install@v1.3.0 + with: + crate: marine + + - name: Download sqlite-wasm + continue-on-error: true + uses: actions/download-artifact@v3 + with: + name: sqlite-wasm + path: artifacts/ + + - name: Build + run: ./build.sh + + - name: Run cargo test + run: cargo test --release --all-features + + - name: Run cargo fmt + run: cargo fmt --all -- --check + + # - name: Run cargo clippy + # run: cargo clippy --all --all-features diff --git a/Cargo.toml b/Cargo.toml index f791aaf..195e3e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ path = "src/test.rs" [dependencies] marine-rs-sdk = "0.7.0" -bytesize = "1.2.0" +bytesize = "1.1.0" [dev-dependencies] marine-rs-sdk-test = "0.2.0" diff --git a/build.sh b/build.sh index 1443b73..25fe008 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash + +SQLITE_WASM_VERSION="v0.18.0_w" + set -o errexit -o nounset -o pipefail # set current working directory to script directory to run script from everywhere @@ -13,4 +16,6 @@ mkdir -p artifacts cp target/wasm32-wasi/release/test.wasm artifacts/ # download SQLite 3 to use in tests -curl -L https://github.com/fluencelabs/sqlite/releases/download/v0.18.0_w/sqlite3.wasm -o artifacts/sqlite3.wasm +if [[ ! -f artifacts/sqlite3.wasm ]]; then + curl -L https://github.com/fluencelabs/sqlite/releases/download/${SQLITE_WASM_VERSION}/sqlite3.wasm -o artifacts/sqlite3.wasm +fi