name: nuttx

on:
  push:
    branches:
    - 'master'
  pull_request:
    branches:
    - '*'

jobs:
  build:
    runs-on: ubuntu-latest
    container: px4io/px4-dev-nuttx:2020-01-13
    strategy:
      matrix:
        config: [
          airmind_mindpx-v2_default,
          av_x-v1_default,
          bitcraze_crazyflie_default,
          holybro_durandal-v1_default,
          holybro_durandal-v1_stackcheck,
          holybro_kakutef7_default,
          intel_aerofc-v1_default,
          modalai_fc-v1_default,
          mro_ctrl-zero-f7_default,
          mro_x21-777_default,
          mro_x21_default,
          nxp_fmuk66-v3_default,
          nxp_fmurt1062-v1_default,
          nxp_rddrone-uavcan146_default,
          omnibus_f4sd_default,
          px4_fmu-v2_default,
          px4_fmu-v2_fixedwing,
          px4_fmu-v2_lpe,
          px4_fmu-v2_multicopter,
          px4_fmu-v2_rover,
          px4_fmu-v2_test,
          px4_fmu-v3_default,
          px4_fmu-v4_cannode,
          px4_fmu-v4_default,
          px4_fmu-v4pro_default,
          px4_fmu-v5_default,
          px4_fmu-v5_fixedwing,
          px4_fmu-v5_multicopter,
          px4_fmu-v5_rover,
          px4_fmu-v5_rtps,
          px4_fmu-v5_stackcheck,
          px4_fmu-v5x_default,
          px4_fmu-v5x_p2_base_phy_LAN8742Ai,
          px4_io-v2_default,
          uvify_core_default
          ]
    steps:
    - uses: actions/checkout@v1
      with:
        token: ${{secrets.ACCESS_TOKEN}}
    - uses: actions/cache@v1.1.0
      id: ccache-persistence
      with:
        path: ~/.ccache
        key: ccache-nuttx-${{matrix.config}}
        restore-keys: |
          ccache-nuttx-${{matrix.config}}
    - name: setup ccache
      run: mkdir -p ~/.ccache && echo "max_size = 300M" > ~/.ccache/ccache.conf && ccache -z && ccache -s
    - name: make ${{matrix.config}}
      run: make ${{matrix.config}}
    - name: ccache post-run
      run: ccache -s && ccache -z
    - name: Upload px4 package
      uses: actions/upload-artifact@v1
      with:
        name: px4_package_${{matrix.config}}
        path: build/${{matrix.config}}/${{matrix.config}}.px4
