name: joystream-node
on:
  pull_request:

jobs:
  benchmarking:
    name: Benchmarking
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: '14.x'
      - uses: technote-space/get-diff-action@v3
        with:
          PREFIX_FILTER: |
            node
            runtime-modules
            utils/chain-spec-builder
          SUFFIX_FILTER: |
            .rs
          FILES: |
            Cargo.lock
            Cargo.toml

      # TODO: Look for change in source code but no corresponding version bump of runtime or binaries
      # - name: Check version modified correctly
      #   if: env.GIT_DIFF

      - name: Toolchains
        run: |
          ./setup.sh
        if: env.GIT_DIFF

      - name: Build
        run: |
          pushd node
          WASM_BUILD_TOOLCHAIN=nightly-2021-02-20 cargo +nightly-2021-02-20 build --release --features runtime-benchmarks
          popd
        if: env.GIT_DIFF

      - name: Generate Weights
        run: |
          ./scripts/generate-weights.sh 5 2
          # Show any changes in computed weights
          git diff
        if: env.GIT_DIFF