Skip to content

Commit

Permalink
Start refactoring CI and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mario4tier committed Jul 31, 2024
1 parent e767ff4 commit 0ed74de
Show file tree
Hide file tree
Showing 18 changed files with 1,198 additions and 508 deletions.
73 changes: 73 additions & 0 deletions .github/DESIGN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
## Documentation Workflows

All documentation, including suibase.io website, are done with markdown files (.md).

Changes can be done on either main or dev with push or PR.

Only the docs on main are published/visible.

Changes are detected by actions/diffs and triggers these workflows:
(1) deploy-docs.yml
build/publish the suibase.io website (hosted by github pages).
The generated site is in the gh-pages branch.

(2) trig-rust-api-docs.yml
push a file to ChainMovers/suibase-api-docs repo to remotely trig the rustdoc build/publish
The resulting docs are hosted by gh pages at https://chainmovers.github.io/suibase-api-docs/suibase

## Source code changes workflows
Push/PR only on the **dev branch**.

The dev branch have various quick tests with multiple OS. Intended to catch errors early after every change. These tests (and more) are also inclided in the daily extensive tests.

actions/diffs detect changes and triggers these workflows:

(1) scripts-tests.yml
Done on bash script changes

(2) suibase-daemon-tests.yml
Tests on code changes related to suibase-daemon. Upon success, will send a file to ChainMovers/suibase-binaries repo to trig potentially further build/publish a new version.
This test force the building of the suibase-daemon (does not use the pre-build binaries).

(3) rust-tests.yml
Done on code changes that might affect the rust API, demos and other rust projects (excluding rust suibase-daemon backend)


## Merge Check Workflows
(1) main-merge-check.yml
Does a few quick sanity checks (not involving lengthy building), for VSCode/daemon/scripts version compatibility.
In particular, verifies that suibase-daemon binaries were built and released successfully prior to merging code requiring a new
version on main.

## Other QA Workflows
(1) main-nithgly-tests.yml/dev-nightly-tests.yml
**Extensive** branch tests done once a day, even when no Suibase changes (in case a dependency breaks something).
Results are published as passed/failed "badges" on githbub README.

(2) release-check.yml
Done on any script/code changes on main.

Simulate someone updating to latest Suibase version. Verifies that binaries can properly be downloaded/installed.

The goal is not to test extensively all features, but rather just validation that the continuous integration itself is working as expected (e.g. if something depend on a backend version, make sure that version is indeed still published).


## About run-all.sh
Many gh action simply call "scripts/tests/run-all.sh".

A subset of tests can be selected with a combination of:
--scripts-tests
--suibase-daemon-tests
--rust-tests
--release-tests
--main-merge-check
--dev-push-check

**extensive** tests happen when there are no skip parameters.







20 changes: 14 additions & 6 deletions .github/actions/diffs/action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Detect Changes
description: Defines variables indicating the parts of the code that changed
description: Variables indicating the type of change to the repos

outputs:
isDoc:
description: True when changes related to documentation
description: True when changes related to docs/website.
value: "${{ steps.diff.outputs.isDoc }}"
isRust:
description: True when changes related to Rust
description: True when changes related to Rust.
value: "${{ steps.diff.outputs.isRust }}"
isMove:
description: True when changes related to Move
Expand All @@ -19,15 +20,18 @@ outputs:
isSuibaseDaemon:
description: True when changes to Suibase Daemon
value: "${{ steps.diff.outputs.isSuibaseDaemon }}"
isVSCodeExtension:
description: True when changes to Suibase VSCode extension
value: "${{ steps.diff.outputs.isVSCodeExtension }}"

runs:
using: composite
steps:
- uses: actions/checkout@v4
- name: Detect Changes
uses: dorny/[email protected]
id: diff
id: diff
with:
base: ${{ github.ref }}
filters: |
isRust:
- 'rust/**'
Expand All @@ -45,11 +49,15 @@ runs:
- 'update'
- 'repair'
- 'pip-install'
- 'update-daemon'
- 'restart'
- '.github/workflows/scripts-tests.yml'
isDocHelperAPI:
- 'rust/helper/lib.rs'
- 'rust/helper/error.rs'
- '.github/workflows/trig-rust-api-docs.yml'
isSuibaseDaemon:
- 'rust/suibase/Cargo.toml'
- 'rust/suibase/**'
- '.github/workflows/trig-sui-binaries.yml'
isVSCodeExtension::
- 'typescript/vscode-extension/**'
4 changes: 2 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ jobs:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.x"

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
version: "latest"
run_install: true

- name: Copy pnpm dependency files
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/dev-nightly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macOS-latest]
os: [ubuntu-latest, macOS-latest]
ci_workdir: [localnet]
include:
- ci_branch: dev
include:
- ci_branch: main
ci_workdir: localnet
ci_cache_all_crates: false
ci_cache_provider: buildjet
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
with:
cache: "false" # Control cache in "Rust Caching" step instead.

- name: Rust Caching
- name: Rust api/demo caching
uses: Swatinem/rust-cache@v2
env:
RUST_ADD_CACHE_KEY_COMPONENT: ${{ matrix.os }}-${{ matrix.ci_branch }}
Expand All @@ -64,10 +64,19 @@ jobs:
rust/demo-app
rust/helper-uniffi
rust/helper
rust/suibase
cache-provider: ${{ matrix.ci_cache_provider }}
cache-all-crates: ${{ matrix.ci_cache_all_crates }}

- name: Rust suibase-daemon caching
uses: Swatinem/rust-cache@v2
env:
RUST_ADD_CACHE_KEY_COMPONENT: suibase-daemon-${{ matrix.os }}-${{ github.ref_name }}
with:
workspaces: |
rust/suibase
cache-provider: buildjet
cache-all-crates: true

- name: Sui Prerequesites (Ubuntu)
if: runner.os == 'Linux'
run: |
Expand Down
54 changes: 9 additions & 45 deletions .github/workflows/release-tests.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Done on any changes to Suibase main branch
#
# This is a quick sanity QA to double check that the branch
# used by most users is not broken, particularly
# following a merge.
# This is a very quick sanity check that simulate someone
# updating to the latest branch + current pre-built binaries.
#
# More extensive tests are done on dev branch and nightly.
# Purposely do not install Rust + Sui pre-requesites.
#
name: release tests
# More extensive tests are expected already done on dev branch and nightly.
#
name: Release Tests

# Controls when the workflow will run

Expand All @@ -24,55 +25,20 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
include:
- ci_branch: main
ci_cache_all_crates: false
ci_cache_provider: buildjet

steps:
- name: Free Disk Space (Ubuntu)
if: runner.os == 'Linux'
uses: jlumbroso/free-disk-space@main
with:
# 'true' means remove...
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false # Not sure if needed for heavy link... keep it for now.

- name: Checkout Dev Branch
uses: actions/checkout@v4

- name: Install Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: "false" # Control cache in "Rust Caching" step instead.

- name: Rust Caching
uses: Swatinem/rust-cache@v2
env:
RUST_ADD_CACHE_KEY_COMPONENT: ${{ matrix.os }}-${{ matrix.ci_branch }}
with:
workspaces: |
rust/demo-app
rust/helper-uniffi
rust/helper
rust/suibase
cache-provider: ${{ matrix.ci_cache_provider }}
cache-all-crates: ${{ matrix.ci_cache_all_crates }}

- name: Sui Prerequesites (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get install curl cmake gcc libssl-dev pkg-config libclang-dev libpq-dev build-essential
sudo apt-get install curl
- name: Sui Prerequesites (macOS)
if: runner.os == 'macOS'
run: |
brew install curl cmake
brew install curl
- name: Prepare environment
run: |
Expand All @@ -81,6 +47,4 @@ jobs:
ln -s $GITHUB_WORKSPACE $HOME/suibase
- name: Only sanity tests the release
env:
CI_BRANCH: ${{ matrix.ci_branch }}
run: $HOME/suibase/scripts/tests/run-all.sh --fast --github_token ${{ secrets.GITHUB_TOKEN }}
run: $HOME/suibase/scripts/tests/run-all.sh --release-tests --github_token ${{ secrets.GITHUB_TOKEN }}
110 changes: 110 additions & 0 deletions .github/workflows/rust-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Rust Tests
# Test for rust API/demo.
#
# Does not include testing suibase-daemon (check instead with suibase-daemon-tests.yml).

on:
push:
branches: ["dev"]
pull_request:
branches: ["dev"]

workflow_dispatch:

jobs:
diff:
runs-on: [ubuntu-latest]
outputs:
isChanged: ${{ steps.diff.outputs.isScript == 'true' || steps.diff.outputs.isRust == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Detect Changes
uses: "./.github/actions/diffs"
id: diff
with:
ref: ${{ github.ref }}

test:
name: Test ${{ matrix.os }} ${{ matrix.ci_workdir }}
needs: diff
if: ${{ (needs.diff.outputs.isChanged == 'true') || (github.event_name == 'workflow_dispatch') }}

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
ci_workdir: [localnet, devnet, testnet, mainnet]
include:
- ci_branch: testnet
ci_workdir: localnet
ci_cache_all_crates: false
ci_cache_provider: github
- ci_branch: devnet
ci_workdir: devnet
ci_cache_all_crates: false
ci_cache_provider: github
- ci_branch: testnet
ci_workdir: testnet
ci_cache_all_crates: false
ci_cache_provider: buildjet
- ci_branch: mainnet
ci_workdir: mainnet
ci_cache_all_crates: false
ci_cache_provider: buildjet

steps:
- name: Free Disk Space (Ubuntu)
if: runner.os == 'Linux'
uses: jlumbroso/free-disk-space@main
with:
# 'true' means remove...
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false # Not sure if needed for heavy link... keep it for now.

- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Install Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: "false" # Control cache in "Rust Caching" step instead.

- name: Rust api/demo caching
uses: Swatinem/rust-cache@v2
env:
RUST_ADD_CACHE_KEY_COMPONENT: ${{ matrix.os }}-${{ matrix.ci_branch }}
with:
workspaces: |
rust/demo-app
rust/helper-uniffi
rust/helper
cache-provider: ${{ matrix.ci_cache_provider }}
cache-all-crates: ${{ matrix.ci_cache_all_crates }}

- name: Sui Prerequesites (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get install curl cmake gcc libssl-dev pkg-config libclang-dev libpq-dev build-essential
- name: Sui Prerequesites (macOS)
if: runner.os == 'macOS'
run: |
brew install curl cmake
- name: Prepare environment
run: |
mkdir -p $HOME/.local/bin
echo "$HOME/.local/bin" >> $GITHUB_PATH
ln -s $GITHUB_WORKSPACE $HOME/suibase
- name: Run rust demo/api tests only
env:
CI_WORKDIR: ${{ matrix.ci_workdir }}
CI_BRANCH: ${{ matrix.ci_branch }}
run: $HOME/suibase/scripts/tests/run-all.sh --rust-tests --github_token ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 0ed74de

Please sign in to comment.