diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 0ca3893fc..6ed21ee43 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,136 +1,224 @@ -name: Build and lint - +name: Build, lint and typecheck examples + on: # Triggers the workflow on push or pull request events but only for the main branch push: branches: [main, release**] pull_request: branches: [main, release**] - + # Don't run on draft PR's, see: https://github.com/orgs/community/discussions/25722#discussioncomment-3248917 + types: [opened, synchronize, reopened, ready_for_review] # Allows us to run the workflow manually from the Actions tab workflow_dispatch: env: - RUST_FMT: nightly-2022-06-09-x86_64-unknown-linux-gnu - RUST_CLIPPY: 1.62 + NODE_VERSION: 18.16.0 + RUST_VERSION: 1.62 + RUST_FMT: nightly-2023-04-01-x86_64-unknown-linux-gnu jobs: - build: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v2 - with: - submodules: "recursive" - - - uses: actions/setup-node@v2 - with: - node-version: "14.16.0" - - - name: Get dependencies - run: yarn - - - name: Install rust - run: rustup default 1.62 - - - name: Get wasm-pack - uses: jetli/wasm-pack-action@v0.3.0 - with: - version: 'latest' - - - name: Build - run: yarn build - - - lint: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v2 - with: - submodules: "recursive" - - uses: actions/setup-node@v2 - with: - node-version: "14.16.0" - - - name: Get dependencies - run: yarn - - - name: Lint - run: yarn lint - - - common_test: - runs-on: ubuntu-20.04 - defaults: - run: - working-directory: packages/common - steps: - - uses: actions/checkout@v2 - with: - submodules: "recursive" - - uses: actions/setup-node@v2 - with: - node-version: "14.16.0" - - name: Get dependencies - run: yarn - - name: Install rust - run: rustup default 1.62 - - name: Get wasm-pack - uses: jetli/wasm-pack-action@v0.3.0 - with: - version: 'latest' - - name: build rust-bindings - run: yarn build:rust-bindings --dev - - name: generate grpc - run: mkdir grpc; yarn generate - - name: test - run: yarn test - - rust_lint_fmt: - name: rust:lint:fmt - # Don't run on draft pull requests - if: ${{ !github.event.pull_request.draft }} - runs-on: ubuntu-latest - defaults: - run: - working-directory: packages/rust-bindings - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ env.RUST_FMT }} - override: true - components: rustfmt - - name: Format - run: | - cargo fmt -- --color=always --check - rust_lint_clippy: - name: rust:lint:clippy - needs: "rust_lint_fmt" - # Don't run on draft pull requests - if: ${{ !github.event.pull_request.draft }} - runs-on: ubuntu-latest - defaults: - run: - working-directory: packages/rust-bindings - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ env.RUST_CLIPPY }} - override: true - target: ${{ env.TARGET }} - components: rustfmt, clippy - - name: Clippy - run: | - git config --global url."https://github.com/".insteadOf "git@github.com:" - cargo clippy --color=always --tests --benches -- -Dclippy::all + build: + if: github.event.pull_request.draft == false + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + with: + submodules: "recursive" + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + + - name: Cache build-output + uses: actions/cache@v3 + with: + path: | + ./node_modules/@concordium + ./packages/rust-bindings/pkg + ./packages/common/lib + ./packages/nodejs/lib + key: ${{ runner.os }}-build_output-${{ github.event.pull_request.head.sha || github.sha }} + + - name: Cache GRPC + id: cache-grpc + uses: actions/cache@v3 + with: + path: | + ./packages/common/grpc + ./packages/nodejs/grpc + key: ${{ runner.os }}-grpc-${{ hashFiles('deps/concordium-base/concordium-grpc-api') }} + + - name: Get dependencies + run: yarn install --immutable + + - name: Install rust + run: rustup default ${{ env.RUST_VERSION }} + + - uses: Swatinem/rust-cache@v2 + with: + workspaces: | + packages/rust-bindings + deps/concordium-deps + + - name: Get wasm-pack + uses: jetli/wasm-pack-action@v0.4.0 + with: + version: 'latest' + + - name: Build GRPC bindings + if: steps.cache-grpc.outputs.cache-hit != 'true' + run: | + mkdir -p packages/common/grpc + mkdir -p packages/nodejs/grpc + yarn workspace @concordium/common-sdk generate + yarn workspace @concordium/node-sdk generate + + - name: Build + run: yarn build:dev + + typecheck-examples: + runs-on: ubuntu-22.04 + needs: build + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v3 + with: + submodules: "recursive" + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + + - name: Cache build-output + uses: actions/cache@v3 + with: + path: | + ./node_modules/@concordium + ./packages/rust-bindings/pkg + ./packages/common/lib + ./packages/nodejs/lib + key: ${{ runner.os }}-build_output-${{ github.event.pull_request.head.sha || github.sha }} + + - name: Cache GRPC + id: cache-grpc + uses: actions/cache@v3 + with: + path: | + ./packages/common/grpc + ./packages/nodejs/grpc + key: ${{ runner.os }}-grpc-${{ hashFiles('deps/concordium-base/concordium-grpc-api') }} + + - name: Get dependencies + run: yarn install --immutable + + - name: Typecheck examples + run: yarn workspace @concordium/examples typecheck + + lint: + runs-on: ubuntu-22.04 + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v3 + with: + submodules: "recursive" + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + + - name: Install dependencies + run: yarn install --immutable + + - name: Lint + run: yarn lint + + common_test: + runs-on: ubuntu-22.04 + needs: build + if: github.event.pull_request.draft == false + defaults: + run: + working-directory: packages/common + steps: + - uses: actions/checkout@v3 + with: + submodules: "recursive" + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + + - name: Cache build-output + uses: actions/cache@v3 + with: + path: | + ./node_modules/@concordium + ./packages/rust-bindings/pkg + ./packages/common/lib + ./packages/nodejs/lib + key: ${{ runner.os }}-build_output-${{ github.event.pull_request.head.sha || github.sha }} + + - name: Cache GRPC + id: cache-grpc + uses: actions/cache@v3 + with: + path: | + ./packages/common/grpc + ./packages/nodejs/grpc + key: ${{ runner.os }}-grpc-${{ hashFiles('deps/concordium-base/concordium-grpc-api') }} + + - name: Get dependencies + run: yarn install --immutable + + - name: Run Tests + run: yarn test + + rust_lint_fmt: + runs-on: ubuntu-22.04 + if: github.event.pull_request.draft == false + defaults: + run: + working-directory: packages/rust-bindings + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install formatter + run: | + rustup default ${{ env.RUST_FMT }} + rustup component add rustfmt + + - name: Format + run: cargo fmt -- --color=always --check + + rust_lint_clippy: + runs-on: ubuntu-22.04 + needs: rust_lint_fmt + if: github.event.pull_request.draft == false + defaults: + run: + working-directory: packages/rust-bindings + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: "recursive" + + - name: Install clippy + run: | + rustup default ${{ env.RUST_VERSION }} + rustup component add clippy + + - uses: Swatinem/rust-cache@v2 + with: + workspaces: | + packages/rust-bindings + deps/concordium-deps + + - name: Run clippy + run: cargo clippy --color=always --tests --benches -- -Dclippy::all + diff --git a/deps/concordium-base b/deps/concordium-base index dc76159cd..d7a0b90be 160000 --- a/deps/concordium-base +++ b/deps/concordium-base @@ -1 +1 @@ -Subproject commit dc76159cd8f76785c7a73503bdf92f69a6c84915 +Subproject commit d7a0b90be478dcbc95b771b4b79d8a9befbe2d13 diff --git a/examples/package.json b/examples/package.json index 3a92e118e..2f0655088 100644 --- a/examples/package.json +++ b/examples/package.json @@ -1,4 +1,5 @@ { + "name": "@concordium/examples", "type": "module", "dependencies": { "@concordium/node-sdk": "workspace:^", diff --git a/packages/rust-bindings/package.json b/packages/rust-bindings/package.json index 22f592d77..2324cba9b 100644 --- a/packages/rust-bindings/package.json +++ b/packages/rust-bindings/package.json @@ -17,8 +17,8 @@ "/pkg/**/concordium_rust_bindings*" ], "scripts": { - "lint": "cargo clippy", - "lint-fix": "cargo +nightly-2022-06-09-x86_64-unknown-linux-gnu fmt", + "fmt": "cargo +nightly-2023-04-01-x86_64-unknown-linux-gnu fmt -- --color=always --check", + "clippy": "cargo +1.62 clippy --color=always --tests --benches -- -Dclippy::all", "build": "wasm-pack build --target web --out-dir pkg/bundler \"$@\" && wasm-pack build --target nodejs --out-dir pkg/node \"$@\"", "build-dev": "yarn build --dev", "build:rust-bindings": "yarn build" diff --git a/yarn.lock b/yarn.lock index 7a7eca1db..81ee640bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1350,6 +1350,26 @@ __metadata: languageName: unknown linkType: soft +"@concordium/examples@workspace:examples": + version: 0.0.0-use.local + resolution: "@concordium/examples@workspace:examples" + dependencies: + "@concordium/node-sdk": "workspace:^" + "@grpc/grpc-js": ^1.3.4 + "@typescript-eslint/eslint-plugin": ^4.28.1 + "@typescript-eslint/parser": ^4.28.1 + eslint: ^7.29.0 + eslint-config-prettier: ^8.3.0 + eslint-plugin-import: ^2.23.4 + eslint-plugin-prettier: ^3.4.0 + lint-staged: ^12.0.2 + meow: 11.0 + prettier: ^2.3.2 + ts-node: 10.9 + typescript: ^4.3.5 + languageName: unknown + linkType: soft + "@concordium/node-sdk@workspace:^, @concordium/node-sdk@workspace:packages/nodejs": version: 0.0.0-use.local resolution: "@concordium/node-sdk@workspace:packages/nodejs" @@ -4342,26 +4362,6 @@ __metadata: languageName: node linkType: hard -"examples-1f5c57@workspace:examples": - version: 0.0.0-use.local - resolution: "examples-1f5c57@workspace:examples" - dependencies: - "@concordium/node-sdk": "workspace:^" - "@grpc/grpc-js": ^1.3.4 - "@typescript-eslint/eslint-plugin": ^4.28.1 - "@typescript-eslint/parser": ^4.28.1 - eslint: ^7.29.0 - eslint-config-prettier: ^8.3.0 - eslint-plugin-import: ^2.23.4 - eslint-plugin-prettier: ^3.4.0 - lint-staged: ^12.0.2 - meow: 11.0 - prettier: ^2.3.2 - ts-node: 10.9 - typescript: ^4.3.5 - languageName: unknown - linkType: soft - "execa@npm:^5.0.0, execa@npm:^5.1.1": version: 5.1.1 resolution: "execa@npm:5.1.1"