flip-link 0.1.0

Flips the memory layout of embedded programs to protect against stack overflows
name: CI

on:
  push:
    branches: [ main]
  pull_request:
    branches: [ main ]
  schedule:
    # runs 1 min after 2 or 1 AM (summer/winter) berlin time
    - cron: '1 0 * * *'
env:
  CARGO_TERM_COLOR: always
  REPO_NAME : flip-link
  APP_NAME : test-flip-link-app
  CORE_TARGET: thumbv7em-none-eabi # needed by `core`
  NRF_TARGET: thumbv7em-none-eabihf

jobs:
  test:
    strategy:
      matrix:
        rust:
          - stable
          - nightly
        os:
          - ubuntu-latest
          - macOS-latest
          - windows-latest
    runs-on: ${{ matrix.os }}
    timeout-minutes: 10
    steps:
    - uses: actions/checkout@v2
    - uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: ${{ matrix.rust }}
        override: true
    - name: Build
      run: RUSTFLAGS='--deny warnings' cargo build
      shell: bash
    - name: Check fmt
      if: matrix.os == 'ubuntu-latest' # we only need to check fmt on one OS
      # nightly doesn't come with rustfmt so make sure it is installed
      run: |
        rustup component add rustfmt
        cargo fmt --all -- --check

  build_app:
    strategy:
      matrix:
        rust:
          - stable
          - nightly
        os:
          - ubuntu-latest
          - macOS-latest
          - windows-latest
    runs-on: ${{ matrix.os }}
    timeout-minutes: 20
    steps:
      - name: Check out flip-link repo
        uses: actions/checkout@v2
        with:
          path: ${{ env.REPO_NAME }}
      # note: we're avoiding `cargo-generate` due to its long install time
      - name: Check out app template
        uses: actions/checkout@v2
        with:
          repository: knurling-rs/app-template
          path: ${{ env.APP_NAME }}
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: ${{ matrix.rust }}
          override: true
          target: ${{ env.NRF_TARGET }}
      - name: Install dependencies
        run: |
          rustup target add ${{ env.CORE_TARGET }}
          cargo install --debug --path ${{ env.REPO_NAME }}
        shell: bash
      - name: Configure App
        run: |
          cd ${{ env.APP_NAME }}
          git apply ../${{ env.REPO_NAME }}/.github/workflows/0001-configure-test-flip-link-app-for-nrf52840.patch
      - name: Build App
        run: |
          cd ${{ env.APP_NAME }}
          cargo build --bins