name: CI

# Controls when the action will run.
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches: [ rc, master ]
  pull_request:
    branches: [ ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  linux:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
        with:
          submodules: true

      - name: Set up JDK
        uses: actions/setup-java@v1
        with:
          java-version: 11

      - name: apt
        run: sudo apt install device-tree-compiler

      # Runs a single command using the runners shell
      - name: Unit Test
        run: ./gradlew check && ./gradlew clean

      # Runs a set of commands using the runners shell
      - name: Integration Test
        run: |
         ./integrationTest.py

  macos:
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true

      - name: Set up JDK
        uses: actions/setup-java@v1
        with:
          java-version: 11

      - name: brew
        run: brew install dtc

      - name: Unit Test
        run: ./gradlew check && ./gradlew clean

      # Runs a set of commands using the runners shell
      - name: Integration Test
        run: ./integrationTest.py

  windows:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true

      - name: Set up JDK
        uses: actions/setup-java@v1
        with:
          java-version: 11

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.x'

      - name: Display Python version
        run: python -c "import sys; print(sys.version)"

      - name: choco
        run: choco install openssl

      - name: Unit Test
        run: ./gradlew.bat check && ./gradlew.bat clean

      # Runs a set of commands using the runners shell
      - name: Integration Test
        run: python integrationTest.py

