Skip to content

Commit

Permalink
Updated CI (#185)
Browse files Browse the repository at this point in the history
* Updated CI

* Fixed build and cleaned a little

* Updated rust caching

* Removed yarn rust linting

* Updated concordium-base

* Added yarn scripts for rust formatting and simplified build-caching

* Build is cached even if insignificant branches change

* Build-output cache now looks at the commit HEAD ref

* fixed hashing

* Updated concordium-base

---------

Co-authored-by: Søren Bruus Zeppelin <[email protected]>
  • Loading branch information
rasmus-kirk and soerenbf authored May 16, 2023
1 parent 46d61aa commit 3226f42
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 147 deletions.
336 changes: 212 additions & 124 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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 "[email protected]:"
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/[email protected]
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

1 change: 1 addition & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "@concordium/examples",
"type": "module",
"dependencies": {
"@concordium/node-sdk": "workspace:^",
Expand Down
4 changes: 2 additions & 2 deletions packages/rust-bindings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading

0 comments on commit 3226f42

Please sign in to comment.