From b34b3fba65b5c05390489c520d6cecc5348c5db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Tue, 12 Sep 2023 17:28:15 +0200 Subject: [PATCH] Fix CI --- .github/workflows/deployment.yml | 4 +- .github/workflows/pipeline.yml | 505 +++++++++++++++--------------- packages/common/package.json | 4 +- pages/misc-pages/upgrade-guide.md | 10 +- 4 files changed, 261 insertions(+), 262 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index fee13f62c..4296dddb7 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -59,7 +59,7 @@ jobs: run: yarn install --immutable - name: Build release - run: yarn build + run: yarn build:rust-bindings && yarn build:dev - name: Store build-release uses: ./.github/actions/upload-artifact @@ -70,7 +70,7 @@ jobs: packages/nodejs/lib packages/web/lib packages/rust-bindings/lib/**/index* - packages/*/grpc-api + packages/nodejs/grpc-api packages/*/package.json packages/*/README.md diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 7c23a493b..bbeec7387 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,261 +1,260 @@ 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: + # 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: - NODE_VERSION: 18.16.0 - RUST_VERSION: 1.65 - RUST_FMT: nightly-2023-04-01-x86_64-unknown-linux-gnu + NODE_VERSION: 18.16.0 + RUST_VERSION: 1.65 + RUST_FMT: nightly-2023-04-01-x86_64-unknown-linux-gnu jobs: - 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 GRPC - id: cache-grpc - uses: actions/cache@v3 - with: - path: | - ./packages/common/grpc-api - ./packages/nodejs/grpc-api - key: ${{ runner.os }}-grpc-${{ hashFiles('deps/concordium-base/concordium-grpc-api') }} - - - name: Cache WebPack - uses: actions/cache@v3 - with: - path: ./packages/web/.webpack-cache - # These two lines ensure that a fresh cache is generated after each run - key: ${{ runner.os }}-webpack-${{ github.run_id }} - restore-keys: ${{ runner.os }}-webpack - - - 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-api - mkdir -p packages/nodejs/grpc-api - yarn workspace @concordium/common-sdk generate - yarn workspace @concordium/node-sdk generate - - - name: Build - run: yarn build:dev - - - name: Store build-debug - uses: ./.github/actions/upload-artifact - with: - name: build-debug - path: | - ./node_modules/@concordium - ./packages/rust-bindings/lib - ./packages/common/lib - ./packages/nodejs/lib - ./packages/common/grpc-api - ./packages/nodejs/grpc-api - ./packages/ccd-js-gen/lib - - typecheck-examples: - runs-on: ubuntu-22.04 - needs: build - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: yarn - - - name: Get build-debug - uses: ./.github/actions/download-artifact - with: - name: build-debug - - - name: Get dependencies - run: yarn install --immutable - - - name: Typecheck examples - run: yarn workspace @concordium/examples typecheck - - common-tests: - runs-on: ubuntu-22.04 - needs: build - defaults: - run: - working-directory: packages/common - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: yarn - - - name: Get build-debug - uses: ./.github/actions/download-artifact - with: - name: build-debug - - - name: Get dependencies - run: yarn install --immutable - - - name: Run Tests - run: yarn test - - typedoc: - runs-on: ubuntu-22.04 - needs: build - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: yarn - - - name: Get build-debug - uses: ./.github/actions/download-artifact - with: - name: build-debug - - - name: Get dependencies - run: yarn install --immutable - - - name: Build typedoc - run: yarn typedoc - - lint: - runs-on: ubuntu-22.04 - needs: build - if: github.event.pull_request.draft == false - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: yarn - - - name: Get build-debug - uses: ./.github/actions/download-artifact - with: - name: build-debug - - - name: Install dependencies - run: yarn install --immutable - - - name: Lint - run: yarn lint - - markdown-lint: - runs-on: ubuntu-22.04 - if: github.event.pull_request.draft == false - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: yarn - - - name: Install dependencies - run: yarn install --immutable - - - name: Lint markdown - run: yarn markdown:lint - - markdown-linkcheck: - runs-on: ubuntu-22.04 - if: github.event.pull_request.draft == false - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: yarn - - - name: Install dependencies - run: yarn install --immutable - - - name: Lint markdown - run: yarn markdown:linkcheck - - 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 + 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 GRPC + id: cache-grpc + uses: actions/cache@v3 + with: + path: | + ./packages/common/grpc-api + ./packages/nodejs/grpc-api + key: ${{ runner.os }}-grpc-${{ hashFiles('deps/concordium-base/concordium-grpc-api') }} + + - name: Cache WebPack + uses: actions/cache@v3 + with: + path: ./packages/web/.webpack-cache + # These two lines ensure that a fresh cache is generated after each run + key: ${{ runner.os }}-webpack-${{ github.run_id }} + restore-keys: ${{ runner.os }}-webpack + + - 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-api + mkdir -p packages/nodejs/grpc-api + yarn workspace @concordium/common-sdk generate + yarn workspace @concordium/node-sdk generate + + - name: Build + run: yarn build:rust-bindings && yarn build:dev + + - name: Store build-debug + uses: ./.github/actions/upload-artifact + with: + name: build-debug + path: | + ./node_modules/@concordium + ./packages/rust-bindings/lib + ./packages/common/lib + ./packages/nodejs/lib + ./packages/nodejs/grpc-api + ./packages/ccd-js-gen/lib + + typecheck-examples: + runs-on: ubuntu-22.04 + needs: build + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + + - name: Get build-debug + uses: ./.github/actions/download-artifact + with: + name: build-debug + + - name: Get dependencies + run: yarn install --immutable + + - name: Typecheck examples + run: yarn workspace @concordium/examples typecheck + + common-tests: + runs-on: ubuntu-22.04 + needs: build + defaults: + run: + working-directory: packages/common + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + + - name: Get build-debug + uses: ./.github/actions/download-artifact + with: + name: build-debug + + - name: Get dependencies + run: yarn install --immutable + + - name: Run Tests + run: yarn test + + typedoc: + runs-on: ubuntu-22.04 + needs: build + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + + - name: Get build-debug + uses: ./.github/actions/download-artifact + with: + name: build-debug + + - name: Get dependencies + run: yarn install --immutable + + - name: Build typedoc + run: yarn typedoc + + lint: + runs-on: ubuntu-22.04 + needs: build + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + + - name: Get build-debug + uses: ./.github/actions/download-artifact + with: + name: build-debug + + - name: Install dependencies + run: yarn install --immutable + + - name: Lint + run: yarn lint + + markdown-lint: + runs-on: ubuntu-22.04 + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + + - name: Install dependencies + run: yarn install --immutable + + - name: Lint markdown + run: yarn markdown:lint + + markdown-linkcheck: + runs-on: ubuntu-22.04 + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + + - name: Install dependencies + run: yarn install --immutable + + - name: Lint markdown + run: yarn markdown:linkcheck + + 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/packages/common/package.json b/packages/common/package.json index 18a485808..c3ca4392d 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -67,8 +67,8 @@ "lint": "eslint . --cache --ext .ts,.tsx --max-warnings 0", "lint-fix": "yarn --silent lint --fix; exit 0", "test": "jest", - "build": "rm -rf grpc-api; mkdir -p grpc-api; yarn generate && yarn build-dev && cp -R grpc-api lib", - "build-dev": "yarn tsc-esm && yarn tsc-cjs", + "build": "rm -rf grpc-api; mkdir -p grpc-api; yarn generate && yarn build-dev", + "build-dev": "yarn tsc-esm && yarn tsc-cjs && cp -R grpc-api lib", "tsc-esm": "tsc -p tsconfig.build.json", "tsc-cjs": "tsc -p tsconfig.build.json --outDir ./lib/cjs --module commonjs", "clean": "rimraf -- lib grpc-api" diff --git a/pages/misc-pages/upgrade-guide.md b/pages/misc-pages/upgrade-guide.md index 7613d24ea..7242c95da 100644 --- a/pages/misc-pages/upgrade-guide.md +++ b/pages/misc-pages/upgrade-guide.md @@ -18,10 +18,10 @@ The following entrypoints are made available for consumers of `@concordium/web-s - `@concordium/web-sdk/id` entrypoint exposes functionality for working with ID proofs. - `@concordium/web-sdk/json-rpc` entrypoint exposes the **(deprecated)** json-rpc client for interacting with a nodes GPRCv1 interface. - `@concordium/web-sdk/schema` entrypoint exposes functionality for working with smart contract schemas, i.e.(de)serializing types using a smart contract schema. - - This uses the wasm entrypoint at `@concordium/rust-bindings/dapp`. + - This uses the wasm entrypoint at `@concordium/rust-bindings/dapp`. - `@concordium/web-sdk/types` entrypoint exposes functionality for working with concordium domain types. - `@concordium/web-sdk/wasm` entrypoint exposes a variety of functionality for working with concordium domain types, which requires WASM. - - This uses the wasm entrypoint at `@concorodium/rust-bindings/wallet`. + - This uses the wasm entrypoint at `@concorodium/rust-bindings/wallet`. - `@concordium/web-sdk/web3-id` entrypoint exposes functionality for working with web3-id proofs. ### NodeJS @@ -41,13 +41,13 @@ The following entrypoints are made available for consumers of `@concordium/node- - `@concordium/node-sdk/grpc` entrypoint exposes the grpc client for interacting with a nodes GRPCv2 interface. - `@concordium/node-sdk/id` entrypoint exposes functionality for working with ID proofs. - `@concordium/node-sdk/schema` entrypoint exposes functionality for working with smart contract schemas, i.e.(de)serializing types using a smart contract schema. - - This uses the wasm entrypoint at `@concordium/rust-bindings/dapp`. + - This uses the wasm entrypoint at `@concordium/rust-bindings/dapp`. - `@concordium/node-sdk/types` entrypoint exposes functionality for working with concordium domain types. - `@concordium/node-sdk/wasm` entrypoint exposes a variety of functionality for working with concordium domain types, which requires WASM. - - This uses the wasm entrypoint at `@concorodium/rust-bindings/wallet`. + - This uses the wasm entrypoint at `@concorodium/rust-bindings/wallet`. - `@concordium/node-sdk/web3-id` entrypoint exposes functionality for working with web3-id proofs. -### Optimizing bundle size (for bundled applications). +### Optimizing bundle size (for bundled applications) The following example shows how to optimize the produced bundle of your application with **webpack 5**. This revolves around loading the WASM necessary for the SDK to work asynchronously instead of embedding it. Corresponding strategies also exist for other bundlers.