Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
limemloh committed Jan 31, 2024
1 parent dbd8e2c commit 0f668f2
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 222 deletions.
251 changes: 98 additions & 153 deletions .github/workflows/format-lint-build-test.yml
Original file line number Diff line number Diff line change
@@ -1,158 +1,103 @@
name: Format, Lint, Build and Test
on:
push:
branches:
- main
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- ready_for_review
push:
branches:
- main
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- ready_for_review
env:
NODE_VERSION: 'lts/*'
RUST_VERSION: "1.75"
CARGO_CONCORDIUM_VERSION: "3.2"
MY_CONTRACT_PATH: contracts/my-contract
MY_CONTRACT_DEPLOY_SCRIPT_PATH: contracts/my-contract/deploy-scripts
NODE_VERSION: "lts/*"
RUST_VERSION: "1.75"
CARGO_CONCORDIUM_VERSION: "3.2"
MY_CONTRACT_PATH: contracts/my-contract
MY_CONTRACT_DEPLOY_SCRIPT_PATH: contracts/my-contract/deploy-scripts
jobs:
rustfmt-my-contract:
name: Check formatting smart contracts
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust toolchain with rustfmt available
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
components: rustfmt
- name: Run cargo fmt
working-directory: ${{ env.MY_CONTRACT_PATH }}
run: cargo fmt --check
rustfmt-my-contract-deploy-scripts:
name: Check formatting smart contract deploy scripts
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust toolchain with rustfmt available
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
components: rustfmt
- name: Run cargo fmt
working-directory: ${{ env.MY_CONTRACT_DEPLOY_SCRIPT_PATH }}
run: cargo fmt --check
clippy-my-contract:
name: Run linter on smart contracts
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust toolchain with clippy available
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
uses: actions-rust-lang/setup-rust-toolchain@v1
toolchain: ${{ env.RUST_VERSION }}
target: wasm32-unknown-unknown
components: clippy
- name: Run cargo clippy
working-directory: ${{ env.MY_CONTRACT_PATH }}
run: cargo clippy --locked -- -D warnings
clippy-my-contract-deploy-scripts:
name: Run linter on smart contract deploy scripts
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust toolchain with clippy available
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
target: wasm32-unknown-unknown
components: clippy
- name: Run cargo clippy
working-directory: ${{ env.MY_CONTRACT_DEPLOY_SCRIPT_PATH }}
run: cargo clippy --locked -- -D warnings
prettier:
name: Check formatting frontend
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Setup Node for frontend
uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_VERSION}}
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install NPM dependencies
working-directory: frontend
run: npm clean-install
- name: Run prettier
working-directory: frontend
run: npm run format
eslint:
name: Run linter on frontend
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Setup Node for frontend
uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_VERSION}}
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install NPM dependencies
working-directory: frontend
run: npm clean-install
- name: Run linter
working-directory: frontend
run: npm run lint
build-and-test:
needs: [rustfmt-my-contract, rustfmt-my-contract-deploy-scripts, clippy-my-contract, clippy-my-contract-deploy-scripts, prettier, eslint]
runs-on: ubuntu-latest
name: Build and test everything
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: wasm32-unknown-unknown
toolchain: ${{ env.RUST_VERSION }}
rustfmt-clippy:
name: Check formatting smart contracts
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust toolchain with rustfmt available
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
target: wasm32-unknown-unknown
components: rustfmt, clippy
- name: Run cargo fmt
working-directory: ${{ env.MY_CONTRACT_PATH }}
run: cargo fmt --check
- name: Run cargo fmt
working-directory: ${{ env.MY_CONTRACT_DEPLOY_SCRIPT_PATH }}
run: cargo fmt --check
- name: Run cargo clippy
working-directory: ${{ env.MY_CONTRACT_PATH }}
run: cargo clippy --locked -- -D warnings
- name: Run cargo clippy
working-directory: ${{ env.MY_CONTRACT_DEPLOY_SCRIPT_PATH }}
run: cargo clippy --locked -- -D warnings
prettier-eslint:
name: Check formatting frontend
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Setup Node for frontend
uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_VERSION}}
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install NPM dependencies
working-directory: frontend
run: npm clean-install
- name: Run prettier
working-directory: frontend
run: npm run format-check
- name: Run eslint
working-directory: frontend
run: npm run lint-check
build-and-test:
name: Build and test everything
needs: [rustfmt-clippy, prettier-eslint]
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: wasm32-unknown-unknown
toolchain: ${{ env.RUST_VERSION }}
- name: Install cargo-concordium from crates.io
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-concordium
version: ${{env.CARGO_CONCORDIUM_VERSION}}
- name: Build and test smart contract
working-directory: ${{ env.MY_CONTRACT_PATH }}
run: cargo concordium test --out "./concordium-out/module.wasm.v1"

- name: Install cargo-concordium from crates.io
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-concordium
version: ${{env.CARGO_CONCORDIUM_VERSION}}

- name: Build and test smart contract
working-directory: ${{ env.MY_CONTRACT_PATH }}
run: cargo concordium test --out "./concordium-out/module.wasm.v1"

# Frontend build and test
- name: Setup Node for frontend
uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_VERSION}}
cache: 'npm'
cache-dependency-path: frontend/package-lock.json

- name: Install NPM dependencies
working-directory: frontend
run: npm clean-install

# This must be run after building the smart contracts.
- name: Generate smart contract clients
working-directory: frontend
run: npm run generate

- name: Build all libraries and samples
working-directory: frontend
run: npm run build
# Frontend build and test
- name: Setup Node for frontend
uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_VERSION}}
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install NPM dependencies
working-directory: frontend
run: npm clean-install
# This must be run after building the smart contracts.
- name: Generate smart contract clients
working-directory: frontend
run: npm run generate
- name: Build all libraries and samples
working-directory: frontend
run: npm run build
4 changes: 0 additions & 4 deletions frontend/.prettierignore

This file was deleted.

58 changes: 0 additions & 58 deletions frontend/README.md

This file was deleted.

5 changes: 3 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint src",
"format": "prettier --check src",
"lint-check": "eslint",
"format-check": "prettier --check .",
"format-fix": "prettier --write .",
"preview": "vite preview",
"generate": "ccd-js-gen --module ../contracts/my-contract/concordium-out/module.wasm.v1 --out-dir ./generated --output-type TypeScript --ts-nocheck"
},
Expand Down
2 changes: 0 additions & 2 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
Expand Down
3 changes: 0 additions & 3 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ export default defineConfig({
wasm(),
topLevelAwait(), // For legacy browser compatibility
],
define: {
global: "globalThis",
},
});

0 comments on commit 0f668f2

Please sign in to comment.