# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [14.x]

    steps:
    - name: Install wasm-pack
      uses: jetli/wasm-pack-action@v0.3.0
      with:
        version: v0.10.0
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: yarn
    - run: yarn build
  
  build-docs:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [14.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: yarn
    - run: yarn build:docs

  build-npm-release:
      # This test is to make sure sidecar can release a binary without any errors.
      # This script does not publish a release, but instead uses yarn to create a tarball and 
      # install it locally. Once installed a binary is attached to sidecars node_modules, and that 
      # binary is then tested against. For more in depth information reference the docs at 
      # `../../scripts/README.md`.

    runs-on: ubuntu-latest

    strategy: 
      matrix:
        node-version: [14.x]
    
    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: yarn
    - run: yarn test:test-release
    