diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b1ffd48 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: + - package-ecosystem: cargo + directory: / + schedule: + interval: monthly + allow: + - dependency-type: direct diff --git a/.github/workflows/cargo-checkmate.yaml b/.github/workflows/cargo-checkmate.yaml new file mode 100644 index 0000000..41db0da --- /dev/null +++ b/.github/workflows/cargo-checkmate.yaml @@ -0,0 +1,38 @@ +name: Cargo checkmate + +on: [workflow_call] + +jobs: + cache-checkmate: + name: Cache checkmate + runs-on: ubuntu-22.04 + if: github.event.pull_request.draft == false + steps: + - uses: taiki-e/cache-cargo-install-action@v1 + with: + tool: cargo-checkmate + + cargo-checkmate: + name: Cargo checkmate + strategy: + matrix: + phase: [build, check, clippy, doc, format] + needs: cache-checkmate + runs-on: ubuntu-22.04 + if: github.event.pull_request.draft == false + env: + RUSTFLAGS: -D warnings + steps: + - uses: taiki-e/cache-cargo-install-action@v1 + with: + tool: cargo-checkmate + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install protoc + run: sudo apt-get install protobuf-compiler + + - name: Run cargo checkmate + run: cargo-checkmate run ${{ matrix.phase }} + diff --git a/.github/workflows/ci-nightly.yaml b/.github/workflows/ci-nightly.yaml new file mode 100644 index 0000000..c8fccdc --- /dev/null +++ b/.github/workflows/ci-nightly.yaml @@ -0,0 +1,53 @@ +name: CI (Nightly) + +on: + schedule: + - cron: '30 3 * * *' + workflow_dispatch: + +jobs: + cargo-checkmate: + uses: ./.github/workflows/cargo-checkmate.yaml + + reject-trailing-whitespace: + name: Reject trailing whitespace + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Reject trailing whitespace + run: ./utils/trailing-whitespace.sh reject + + test: + uses: ./.github/workflows/test.yaml + + create-timestamp: + uses: zingolabs/zingo-mobile/.github/workflows/create-timestamp.yaml@dev + + create-cache-key: + uses: zingolabs/zingo-mobile/.github/workflows/create-cache-key.yaml@dev + + build-android: + strategy: + matrix: + arch: [ x86_64, x86, arm64-v8a, armeabi-v7a ] + fail-fast: false + uses: zingolabs/zingo-mobile/.github/workflows/build.yaml@dev + needs: create-cache-key + with: + cache-key: ${{ needs.create-cache-key.outputs.cache-key }} + arch: ${{ matrix.arch }} + + integration-test-android: + strategy: + matrix: + abi: [ x86_64, x86, arm64-v8a, armeabi-v7a ] + fail-fast: false + uses: zingolabs/zingo-mobile/.github/workflows/integration-test.yaml@dev + needs: [ create-timestamp, create-cache-key, build-android ] + with: + timestamp: ${{ needs.create-timestamp.outputs.timestamp }} + cache-key: ${{ needs.create-cache-key.outputs.cache-key }} + abi: ${{ matrix.abi }} + diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..71f5381 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,51 @@ +name: CI + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + push: + branches: [stable, dev] + workflow_dispatch: + +jobs: + cargo-checkmate: + uses: ./.github/workflows/cargo-checkmate.yaml + + reject-trailing-whitespace: + name: Reject trailing whitespace + runs-on: ubuntu-22.04 + if: github.event.pull_request.draft == false + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Reject trailing whitespace + run: ./utils/trailing-whitespace.sh reject + + run-doc-tests: + name: Run doc tests + runs-on: ubuntu-22.04 + if: github.event.pull_request.draft == false + env: + RUSTFLAGS: -D warnings + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + + - name: Install protoc + run: sudo apt-get install protobuf-compiler + + - name: Cargo cache + uses: Swatinem/rust-cache@v2 + + - name: Run doc tests + run: cargo test --doc + + test: + uses: ./.github/workflows/test.yaml + with: + nextest-flags: "-E 'not test(slow)'" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml.bak similarity index 100% rename from .github/workflows/ci.yml rename to .github/workflows/ci.yml.bak diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml new file mode 100644 index 0000000..042ba03 --- /dev/null +++ b/.github/workflows/coverage.yaml @@ -0,0 +1,42 @@ +name: Coverage (Weekly) + +on: + schedule: + - cron: '30 8 * * 0' + workflow_dispatch: + +jobs: + coverage: + name: Coverage + runs-on: ubuntu-22.04 + env: + RUSTFLAGS: -D warnings + container: + image: zingodevops/ci-build:002 + options: --security-opt seccomp=unconfined + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Symlink lightwalletd and zcash binaries + run: ln -s /usr/bin/lightwalletd /usr/bin/zcashd /usr/bin/zcash-cli ./libtonode-tests/regtest/bin/ + + - name: Symlink zcash parameters + run: ln -s /root/.zcash-params /github/home + + - name: Cargo cache + uses: Swatinem/rust-cache@v2 + + - name: Generate code coverage + uses: actions-rs/cargo@v1 + with: + command: tarpaulin + args: --all-features --verbose --workspace --avoid-cfg-tarpaulin --skip-clean --release --timeout 3000 --out xml + + - name: Upload to codecov.io + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./cobertura.xml + fail_ci_if_error: true + diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..4e7ff03 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,81 @@ +name: Test + +on: + workflow_call: + inputs: + nextest-flags: + required: false + type: string + +env: + NEXTEST-FLAGS: ${{ inputs.nextest-flags }} + +jobs: + build-test-artifacts: + name: Build test artifacts + runs-on: ubuntu-22.04 + if: github.event.pull_request.draft == false + env: + RUSTFLAGS: -D warnings + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + + - name: Install nextest + uses: taiki-e/install-action@nextest + + - name: Install protoc + run: sudo apt-get install protobuf-compiler + + - name: Cargo cache + uses: Swatinem/rust-cache@v2 + + - name: Build and archive tests + run: cargo nextest archive --verbose --workspace --all-features --archive-file nextest-archive.tar.zst + + - name: Upload archive + uses: actions/upload-artifact@v3 + with: + name: nextest-archive + path: nextest-archive.tar.zst + + run-tests: + name: Run tests + runs-on: ubuntu-22.04 + if: github.event.pull_request.draft == false + needs: build-test-artifacts + env: + RUSTFLAGS: -D warnings + container: + image: zingodevops/ci-build:002 + options: --security-opt seccomp=unconfined + strategy: + matrix: + partition: [1, 2, 3, 4, 5, 6, 7, 8] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: create binaries dir + run: mkdir -p ./test_binaries/bins + + - name: Symlink lightwalletd and zcash binaries + run: ln -s /usr/bin/lightwalletd /usr/bin/zcashd /usr/bin/zcash-cli ./test_binaries/bins/ + + - name: Symlink zcash parameters + run: ln -s /root/.zcash-params /github/home + + - name: Download archive + uses: actions/download-artifact@v3 + with: + name: nextest-archive + + - name: Run tests + run: | + cargo nextest run --verbose --profile ci --archive-file nextest-archive.tar.zst \ + --workspace-remap ./ --partition count:${{ matrix.partition }}/8 ${{ env.NEXTEST-FLAGS }} +