Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add github workflow(fix #17) #18

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: ci

on:
pull_request:
branches:
- main
- v*
push:
branches:
- main
- v*

jobs:
fmt:
name: cargo fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt
override: true
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

# sort the dependencies in Cargo.toml
cargo_sort:
name: cargo sort
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: baptiste0928/cargo-install@v2
with:
crate: cargo-sort
version: latest
- run: cargo sort -c

# check cargo.toml format
taplo_fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: baptiste0928/cargo-install@v2
with:
crate: taplo-cli
version: latest
- run: taplo check

# check unused dependency
cargo_machete:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: baptiste0928/cargo-install@v2
with:
crate: cargo-machete
version: latest
- run: cargo-machete

clippy_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rustup component add clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all --all-features -- -D warnings

build:
name: cargo build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/cargo@v1
with:
command: build

go_binding:
name: go binding build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: baptiste0928/cargo-install@v2
with:
crate: uniffi-bindgen-go
git: https://github.com/NordSecurity/uniffi-bindgen-go
tag: "v0.1.5+v0.23.0"
cache-key: "[email protected]+v0.23.0"
- uses: actions/setup-go@v4
with:
go-version: 1.21
- run: make test_go

test:
name: cargo test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/cargo@v1
with:
command: test
args: --all
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ BINDINGS_DIR_EXAMPLE:=${ROOT_DIR}/examples/Golang/generated
LD_LIBRARY_PATH := ${LD_LIBRARY_PATH}:${LIB_DIR}
BINDINGS_DIR?="${ROOT_DIR}/binding_tests/generated"
UNIFFI_VERSION=0.23.0
UNIFFI_BINDGEN_GO_VERSION=v0.1.3+v${UNIFFI_VERSION}
UNIFFI_BINDGEN_GO_VERSION=v0.1.5+v${UNIFFI_VERSION}

prepare_ffi:
@if [[ `uniffi-bindgen-go -V | grep 'v.${UNIFFI_VERSION}'` ]]; then \
Expand All @@ -59,14 +59,14 @@ prepare_wasm:
fi

build_binding_files: prepare_ffi
rm -rf ${BINDINGS_DIR}
rm -rf ${BINDINGS_DIR} ${BINDINGS_DIR_EXAMPLE}
uniffi-bindgen-go ${ROOT_DIR}/bindings/sdk/src/ffi.udl --out-dir ${BINDINGS_DIR} --config=${ROOT_DIR}/bindings/sdk/ffi_golang.toml
uniffi-bindgen-go ${ROOT_DIR}/bindings/sdk/src/ffi.udl --out-dir ${BINDINGS_DIR_EXAMPLE} --config=${ROOT_DIR}/bindings/sdk/ffi_golang.toml

build_binding_lib:
cargo build --package bindings_sdk --release

test_go: build_binding_lib build_binding_files
test_go: build_binding_files build_binding_lib
cd ${ROOT_DIR}/binding_tests && \
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} \
CGO_LDFLAGS="-lzklink_sdk -L${LIB_DIR} -lm -ldl" \
Expand Down
Loading