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

examples: Migrate code snippets from .md files to separate sources #1125

Merged
merged 4 commits into from Oct 3, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/actions/lint-rust/action.yml
@@ -1,12 +1,12 @@
name: Lint Rust Worskapce
description: Run lints and format checks on Rust workspace code
inputs:
manfiest_path:
manifest_path:
description: Path to the Cargo.toml manifest of the Rust sources to lint
default: ${{ github.workspace }}/Cargo.toml
required: false
token:
description: GitHub secret token used by cliipy-check action
description: GitHub secret token used by clippy-check action
required: true
runs:
using: composite
Expand All @@ -18,7 +18,7 @@ runs:
args: |
--all-features
--locked
--manifest-path ${{ inputs.manfiest_path }}
--manifest-path ${{ inputs.manifest_path }}
--
-D warnings
-D clippy::dbg_macro
Expand All @@ -28,4 +28,4 @@ runs:
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --manifest-path ${{ inputs.manfiest_path }} -- --check
args: --all --manifest-path ${{ inputs.manifest_path }} -- --check
4 changes: 2 additions & 2 deletions .github/actions/test-rust/action.yml
@@ -1,7 +1,7 @@
name: Unit Test Rust Worskapce with Coverage
description: Run unit tests on a Rust workspace with coverage and uploads results to codecov
inputs:
manfiest_path:
manifest_path:
description: Path to the Cargo.toml manifest of the Rust sources to build and test
default: ${{ github.workspace }}/Cargo.toml
required: false
Expand All @@ -12,7 +12,7 @@ runs:
uses: actions-rs/tarpaulin@v0.1
with:
version: '0.20.1'
args: '--avoid-cfg-tarpaulin --manifest-path ${{ inputs.manfiest_path }} -- --test-threads 1'
args: '--avoid-cfg-tarpaulin --manifest-path ${{ inputs.manifest_path }} -- --test-threads 1'
env:
# Required as tarpaulin doesn't honor .cargo/config.
RUSTFLAGS: -C target-feature=+aes,+ssse3
Expand Down
119 changes: 119 additions & 0 deletions .github/workflows/ci-examples.yml
@@ -0,0 +1,119 @@
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
name: ci-examples

# Trigger the workflow when:
on:
# A push occurs to one of the matched branches.
push:
branches:
- main
- stable/*
# Or when a pull request event occurs for a pull request against one of the
# matched branches.
pull_request:
branches:
- main
- stable/*

# Cancel in-progress jobs on same branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint-test-runtime-sdk:
name: lint-test-runtime-sdk
runs-on: ubuntu-latest
strategy:
matrix:
example: [runtime-sdk/minimal-runtime]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
components: rustfmt, clippy

# Generate Cargo.lock needed for linting.
- name: Generate Cargo.lock
working-directory: examples/${{ matrix.example }}
run: cargo generate-lockfile

- name: Lint ${{ matrix.example }}
uses: ./.github/actions/lint-rust
with:
token: ${{ secrets.GITHUB_TOKEN }}
manifest_path: examples/${{ matrix.example }}/Cargo.toml

- name: Build and test ${{ matrix.example }}
working-directory: examples/${{ matrix.example }}
run: cargo test

lint-test-contract-sdk:
name: lint-test-contract-sdk
runs-on: ubuntu-latest
strategy:
matrix:
example: [contract-sdk/hello-world, contract-sdk/c10l-hello-world]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
target: wasm32-unknown-unknown
components: rustfmt, clippy

# Generate Cargo.lock needed for linting.
- name: Generate Cargo.lock
working-directory: examples/${{ matrix.example }}
run: cargo generate-lockfile

- name: Lint ${{ matrix.example }}
uses: ./.github/actions/lint-rust
with:
token: ${{ secrets.GITHUB_TOKEN }}
manifest_path: examples/${{ matrix.example }}/Cargo.toml

- name: Build ${{ matrix.example }} for wasm32
working-directory: examples/${{ matrix.example }}
run: cargo build --target wasm32-unknown-unknown --release

- name: Test ${{ matrix.example }}
working-directory: examples/${{ matrix.example }}
run: cargo test

lint-test-client-sdk-go:
name: lint-test-client-sdk-go
runs-on: ubuntu-latest
strategy:
matrix:
example: [client-sdk/go/minimal-runtime-client]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.17.x'

# Generate go.sum needed for linting.
- name: Generate go.sum
working-directory: examples/${{ matrix.example }}
run: go get

# NOTE: "file exists" tar errors can be safely ignored, because go is already installed.
- name: Lint ${{ matrix.example }}
uses: golangci/golangci-lint-action@v3.2.0
with:
# NOTE: The version must be specified without the patch version.
version: v1.40
working-directory: examples/${{ matrix.example }}

- name: Build ${{ matrix.example }}
working-directory: examples/${{ matrix.example }}
run: go build
6 changes: 2 additions & 4 deletions .github/workflows/ci-lint.yml
Expand Up @@ -21,9 +21,7 @@ concurrency:
cancel-in-progress: true

jobs:

lint-rust:
# NOTE: This name appears in GitHub's Checks API.
name: lint-rust
runs-on: ubuntu-latest
steps:
Expand All @@ -44,13 +42,13 @@ jobs:
uses: ./.github/actions/lint-rust
with:
token: ${{ secrets.GITHUB_TOKEN }}
manfiest_path: tests/contracts/hello/Cargo.toml
manifest_path: tests/contracts/hello/Cargo.toml

- name: Lint OAS-20 contract code
uses: ./.github/actions/lint-rust
with:
token: ${{ secrets.GITHUB_TOKEN }}
manfiest_path: contract-sdk/specs/token/oas20/Cargo.toml
manifest_path: contract-sdk/specs/token/oas20/Cargo.toml

lint-go-client-sdk:
name: lint-go-client-sdk
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/ci-test.yaml
Expand Up @@ -21,7 +21,6 @@ concurrency:
cancel-in-progress: true

jobs:

test-rust:
# NOTE: This name appears in GitHub's Checks API.
name: test-rust
Expand All @@ -46,12 +45,12 @@ jobs:
- name: Test Hello contract code
uses: ./.github/actions/test-rust
with:
manfiest_path: tests/contracts/hello/Cargo.toml
manifest_path: tests/contracts/hello/Cargo.toml

- name: Test OAS-20 contract
uses: ./.github/actions/test-rust
with:
manfiest_path: contract-sdk/specs/token/oas20/Cargo.toml
manifest_path: contract-sdk/specs/token/oas20/Cargo.toml

test-rust-sgx:
# NOTE: This name appears in GitHub's Checks API.
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Expand Up @@ -25,5 +25,9 @@ members = [
exclude = [
# Test contracts.
"tests/contracts",
# Example contracts and runtimes.
"examples/contract-sdk/hello-world",
"examples/contract-sdk/c10l-hello-world",
"examples/runtime-sdk/minimal-runtime",
]
resolver = "2"