diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 57e4782..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,44 +0,0 @@ -version: 2.1 - -orbs: - docker: circleci/docker@1.5.0 - -jobs: - sqlite_connector_rust_tests: - docker: - - image: circleci/rust:latest - resource_class: xlarge - environment: - RUST_BACKTRACE: full - steps: - - checkout - - restore_cache: - keys: - - sqlite-connector01-{{ checksum "Cargo.lock" }} - - run: | - rustup toolchain install nightly-2021-05-21 - rustup default nightly-2021-05-21 - rustup override set nightly-2021-05-21 - - rustup component add rustfmt --toolchain nightly-2021-05-21 - rustup component add clippy --toolchain nightly-2021-05-21 - rustup target add wasm32-wasi - - cargo install marine - - cargo fmt --all -- --check --color always - cargo check -v --all-features - - ./build.sh - cargo test --release -v --all-features - - save_cache: - paths: - - ~/.cargo - - ~/.rustup - key: sqlite-connector01-{{ checksum "Cargo.lock" }} - -workflows: - version: 2.1 - marine: - jobs: - - sqlite_connector_rust_tests diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml new file mode 100644 index 0000000..be1bfdc --- /dev/null +++ b/.github/actionlint.yaml @@ -0,0 +1,3 @@ +self-hosted-runner: + labels: + - builder diff --git a/.github/download_marine.sh b/.github/download_marine.sh deleted file mode 100755 index c7609aa..0000000 --- a/.github/download_marine.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -o pipefail -o errexit -o nounset -set -x - -MARINE_RELEASE="https://api.github.com/repos/fluencelabs/marine/releases/latest" -OUT_DIR=/usr/local/bin - -# get metadata about release -curl -s -H "Accept: application/vnd.github.v3+json" $MARINE_RELEASE | - # extract url and name for asset with name "marine" - # also append $OUT_DIR to each name so file is saved to $OUT_DIR - jq -r ".assets | .[] | select(.name == \"marine\") | \"\(.browser_download_url) $OUT_DIR/\(.name)\"" | - # download assets - xargs -n2 bash -c 'curl -L $0 -o $1 && chmod +x $1' diff --git a/.github/release-please/config.json b/.github/release-please/config.json new file mode 100644 index 0000000..9b29be9 --- /dev/null +++ b/.github/release-please/config.json @@ -0,0 +1,9 @@ +{ + "bootstrap-sha": "69e3f8f7a472f688d560b34d6e7670b2c28aeae8", + "release-type": "rust", + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": true, + "packages": { + ".": {} + } +} diff --git a/.github/release-please/manifest.json b/.github/release-please/manifest.json new file mode 100644 index 0000000..64f3cdd --- /dev/null +++ b/.github/release-please/manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.8.0" +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c8aeb18 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: ci + +on: + pull_request: + paths-ignore: + - "**.md" + push: + branches: + - "master" + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..b3374a5 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,35 @@ +name: lint + +on: + pull_request: + types: + - opened + - edited + - synchronize + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + pr: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + reviewdog: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Lint actions + uses: reviewdog/action-actionlint@v1 + env: + SHELLCHECK_OPTS: "-e SC2086 -e SC2207 -e SC2128" + with: + reporter: github-pr-check + fail_on_error: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6a28808 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,124 @@ +name: "release" + +on: + push: + branches: + - "master" + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + +jobs: + release-please: + runs-on: ubuntu-latest + + outputs: + release-created: ${{ steps.release.outputs['release_created'] }} + tag-name: ${{ steps.release.outputs['tag_name'] }} + version: ${{ steps.release.outputs['version'] }} + pr: ${{ steps.release.outputs['pr'] }} + + steps: + - name: Run release-please + id: release + uses: google-github-actions/release-please-action@v3 + with: + token: ${{ secrets.FLUENCEBOT_RELEASE_PLEASE_PAT }} + command: manifest + config-file: .github/release-please/config.json + manifest-file: .github/release-please/manifest.json + + - name: Show output from release-please + if: steps.release.outputs.releases_created + env: + RELEASE_PLEASE_OUTPUT: ${{ toJSON(steps.release.outputs) }} + run: echo "${RELEASE_PLEASE_OUTPUT}" | jq + + publish: + if: needs.release-please.outputs.release-created + runs-on: ubuntu-latest + needs: release-please + + permissions: + contents: write + id-token: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.FLUENCEBOT_RELEASE_PLEASE_PAT }} + + - name: Import secrets + uses: hashicorp/vault-action@v2.4.3 + with: + url: https://vault.fluence.dev + path: jwt/github + role: ci + method: jwt + jwtGithubAudience: "https://github.com/fluencelabs" + jwtTtl: 300 + exportToken: false + secrets: | + kv/crates.io/fluencebot token | CARGO_REGISTRY_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: Build + run: ./build.sh + + - name: Publish to crates.io + run: cargo publish + + slack: + if: always() + name: "Notify" + runs-on: ubuntu-latest + + needs: + - release-please + - publish + + permissions: + contents: read + id-token: write + + steps: + - uses: lwhiteley/dependent-jobs-result-check@v1 + id: status + with: + statuses: failure + dependencies: ${{ toJSON(needs) }} + + - name: Log output + run: | + echo "statuses:" "${{ steps.status.outputs.statuses }}" + echo "jobs:" "${{ steps.status.outputs.jobs }}" + echo "found any?:" "${{ steps.status.outputs.found }}" + + - name: Import secrets + uses: hashicorp/vault-action@v2.4.3 + with: + url: https://vault.fluence.dev + path: jwt/github + role: ci + method: jwt + jwtGithubAudience: "https://github.com/fluencelabs" + jwtTtl: 300 + exportToken: false + secrets: | + kv/slack/release-please webhook | SLACK_WEBHOOK_URL + + - uses: ravsamhq/notify-slack-action@v2 + if: steps.status.outputs.found == 'true' + with: + status: "failure" + notification_title: "*{workflow}* has {status_message}" + message_format: "${{ steps.status.outputs.jobs }} {status_message} in <{repo_url}|{repo}>" + footer: "<{run_url}>" diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..04c30bd --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "nightly-2022-12-06" +targets = ["x86_64-unknown-linux-gnu", "wasm32-wasi", "wasm32-unknown-unknown"] +components = ["rustfmt", "clippy"] diff --git a/sqlite3.wit b/sqlite3.wit index e5d1d9c..cd52088 100644 --- a/sqlite3.wit +++ b/sqlite3.wit @@ -1,17 +1,17 @@ (@interface it_version "0.24.1") ;; Types -(@interface type (func - (param $size: i32) +(@interface type (func + (param $size: i32) (result i32))) ;; 0 (@interface type (func )) ;; 1 -(@interface type (func +(@interface type (func (result i32))) ;; 2 -(@interface type (func +(@interface type (func (result i32))) ;; 3 -(@interface type (func +(@interface type (func (param $result_size: i32) )) ;; 4 -(@interface type (func +(@interface type (func (param $result_ptr: i32) )) ;; 5 (@interface type (record $DBOpenDescriptor ( field $ret_code: s32 @@ -32,171 +32,171 @@ field $function_name: string field $json_path: string ))) ;; 9 -(@interface type (func - (param $stmt_handle: u32 $pos: s32 $value: s64) +(@interface type (func + (param $stmt_handle: u32 $pos: s32 $value: s64) (result s32))) ;; 10 -(@interface type (func - (param $stmt_handle: u32 $pos: s32 $value: s64) +(@interface type (func + (param $stmt_handle: u32 $pos: s32 $value: s64) (result s32))) ;; 11 -(@interface type (func - (param $stmt_handle: u32 $icol: u32) +(@interface type (func + (param $stmt_handle: u32 $icol: u32) (result string))) ;; 12 -(@interface type (func - (param $stmt_handle: u32 $icol: u32) +(@interface type (func + (param $stmt_handle: u32 $icol: u32) (result string))) ;; 13 -(@interface type (func - (param $db_handle: u32 $sql: string) +(@interface type (func + (param $db_handle: u32 $sql: string) (result record 7))) ;; 14 -(@interface type (func - (param $db_handle: u32 $sql: string) +(@interface type (func + (param $db_handle: u32 $sql: string) (result record 7))) ;; 15 -(@interface type (func - (param $db_handle: u32) +(@interface type (func + (param $db_handle: u32) (result s32))) ;; 16 -(@interface type (func - (param $db_handle: u32) +(@interface type (func + (param $db_handle: u32) (result s32))) ;; 17 -(@interface type (func - (param $stmt_handle: u32 $pos: s32 $value: f64) +(@interface type (func + (param $stmt_handle: u32 $pos: s32 $value: f64) (result s32))) ;; 18 -(@interface type (func - (param $stmt_handle: u32 $pos: s32 $value: f64) +(@interface type (func + (param $stmt_handle: u32 $pos: s32 $value: f64) (result s32))) ;; 19 -(@interface type (func - (param $filename: string $flags: s32 $vfs: string) +(@interface type (func + (param $filename: string $flags: s32 $vfs: string) (result record 6))) ;; 20 -(@interface type (func - (param $filename: string $flags: s32 $vfs: string) +(@interface type (func + (param $filename: string $flags: s32 $vfs: string) (result record 6))) ;; 21 -(@interface type (func - (param $db_handle: u32) +(@interface type (func + (param $db_handle: u32) (result s32))) ;; 22 -(@interface type (func - (param $db_handle: u32) +(@interface type (func + (param $db_handle: u32) (result s32))) ;; 23 -(@interface type (func - (param $stmt_handle: u32) +(@interface type (func + (param $stmt_handle: u32) (result s32))) ;; 24 -(@interface type (func - (param $stmt_handle: u32) +(@interface type (func + (param $stmt_handle: u32) (result s32))) ;; 25 -(@interface type (func - (param $stmt_handle: u32) +(@interface type (func + (param $stmt_handle: u32) (result s32))) ;; 26 -(@interface type (func - (param $stmt_handle: u32) +(@interface type (func + (param $stmt_handle: u32) (result s32))) ;; 27 -(@interface type (func - (param $size: s64) +(@interface type (func + (param $size: s64) (result s64))) ;; 28 -(@interface type (func - (param $size: s64) +(@interface type (func + (param $size: s64) (result s64))) ;; 29 -(@interface type (func - (param $db: u32) +(@interface type (func + (param $db: u32) (result s32))) ;; 30 -(@interface type (func - (param $db: u32) +(@interface type (func + (param $db: u32) (result s32))) ;; 31 -(@interface type (func - (param $db_handle: u32 $sql: string $callback_id: s32 $callback_arg: s32) +(@interface type (func + (param $db_handle: u32 $sql: string $callback_id: s32 $callback_arg: s32) (result record 8))) ;; 32 -(@interface type (func - (param $db_handle: u32 $sql: string $callback_id: s32 $callback_arg: s32) +(@interface type (func + (param $db_handle: u32 $sql: string $callback_id: s32 $callback_arg: s32) (result record 8))) ;; 33 -(@interface type (func - (param $stmt_handle: u32 $icol: s32) +(@interface type (func + (param $stmt_handle: u32 $icol: s32) (result f64))) ;; 34 -(@interface type (func - (param $stmt_handle: u32 $icol: s32) +(@interface type (func + (param $stmt_handle: u32 $icol: s32) (result f64))) ;; 35 -(@interface type (func - (param $stmt_handle: u32 $icol: u32) +(@interface type (func + (param $stmt_handle: u32 $icol: u32) (result s32))) ;; 36 -(@interface type (func - (param $stmt_handle: u32 $icol: u32) +(@interface type (func + (param $stmt_handle: u32 $icol: u32) (result s32))) ;; 37 -(@interface type (func - (param $stmt_handle: u32 $pos: s32) +(@interface type (func + (param $stmt_handle: u32 $pos: s32) (result s32))) ;; 38 -(@interface type (func - (param $stmt_handle: u32 $pos: s32) +(@interface type (func + (param $stmt_handle: u32 $pos: s32) (result s32))) ;; 39 -(@interface type (func - (param $stmt_handle: u32 $pos: s32 $blob: array (u8) $xDel: s32) +(@interface type (func + (param $stmt_handle: u32 $pos: s32 $blob: array (u8) $xDel: s32) (result s32))) ;; 40 -(@interface type (func - (param $stmt_handle: u32 $pos: s32 $blob: array (u8) $xDel: s32) +(@interface type (func + (param $stmt_handle: u32 $pos: s32 $blob: array (u8) $xDel: s32) (result s32))) ;; 41 -(@interface type (func - (param $db_handle: u32) +(@interface type (func + (param $db_handle: u32) (result s32))) ;; 42 -(@interface type (func - (param $db_handle: u32) +(@interface type (func + (param $db_handle: u32) (result s32))) ;; 43 -(@interface type (func - (param $stmt_handle: u32) +(@interface type (func + (param $stmt_handle: u32) (result s32))) ;; 44 -(@interface type (func - (param $stmt_handle: u32) +(@interface type (func + (param $stmt_handle: u32) (result s32))) ;; 45 -(@interface type (func - (param $stmt_handle: u32 $pos: s32 $text: string $xDel: s32) +(@interface type (func + (param $stmt_handle: u32 $pos: s32 $text: string $xDel: s32) (result s32))) ;; 46 -(@interface type (func - (param $stmt_handle: u32 $pos: s32 $text: string $xDel: s32) +(@interface type (func + (param $stmt_handle: u32 $pos: s32 $text: string $xDel: s32) (result s32))) ;; 47 -(@interface type (func - (param $stmt_handle: u32) +(@interface type (func + (param $stmt_handle: u32) (result s32))) ;; 48 -(@interface type (func - (param $stmt_handle: u32) +(@interface type (func + (param $stmt_handle: u32) (result s32))) ;; 49 -(@interface type (func - (param $size: s64) +(@interface type (func + (param $size: s64) (result s64))) ;; 50 -(@interface type (func - (param $size: s64) +(@interface type (func + (param $size: s64) (result s64))) ;; 51 -(@interface type (func +(@interface type (func (result s32))) ;; 52 -(@interface type (func +(@interface type (func (result s32))) ;; 53 -(@interface type (func - (param $stmt_handle: u32 $icol: u32) +(@interface type (func + (param $stmt_handle: u32 $icol: u32) (result s64))) ;; 54 -(@interface type (func - (param $stmt_handle: u32 $icol: u32) +(@interface type (func + (param $stmt_handle: u32 $icol: u32) (result s64))) ;; 55 -(@interface type (func - (param $db_handle: u32 $ms: u32) +(@interface type (func + (param $db_handle: u32 $ms: u32) (result s32))) ;; 56 -(@interface type (func - (param $db_handle: u32 $ms: u32) +(@interface type (func + (param $db_handle: u32 $ms: u32) (result s32))) ;; 57 -(@interface type (func - (param $stmt_handle: u32 $icol: s32) +(@interface type (func + (param $stmt_handle: u32 $icol: s32) (result array (u8)))) ;; 58 -(@interface type (func - (param $stmt_handle: u32 $icol: s32) +(@interface type (func + (param $stmt_handle: u32 $icol: s32) (result array (u8)))) ;; 59 -(@interface type (func - (param $stmt_handle: u32 $N: u32) +(@interface type (func + (param $stmt_handle: u32 $N: u32) (result string))) ;; 60 -(@interface type (func - (param $stmt_handle: u32 $N: u32) +(@interface type (func + (param $stmt_handle: u32 $N: u32) (result string))) ;; 61 -(@interface type (func - (param $stmt_handle: u32 $icol: u32) +(@interface type (func + (param $stmt_handle: u32 $icol: u32) (result s32))) ;; 62 -(@interface type (func - (param $stmt_handle: u32 $icol: u32) +(@interface type (func + (param $stmt_handle: u32 $icol: u32) (result s32))) ;; 63 -(@interface type (func - (param $db_handle: u32) +(@interface type (func + (param $db_handle: u32) (result string))) ;; 64 -(@interface type (func - (param $db_handle: u32) +(@interface type (func + (param $db_handle: u32) (result string))) ;; 65