name: Firmware

on:
  push:
    branches:
      - "main"
    tags:
      - "*"
  pull_request:
    paths:
      - "Firmware/**"
      - ".gitea/workflows/**"

#
jobs:
  make_firmware:
    runs-on: ubuntu-latest
    name: Firmware Builder

    steps:
      - uses: actions/checkout@v2
      # - name: Cache pip
      #   uses: actions/cache@v2
      #   with:
      #     path: ~/.cache/pip
      #     key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
      #     restore-keys: |
      #       ${{ runner.os }}-pip-
      # - name: Cache PlatformIO
      #   uses: actions/cache@v2
      #   with:
      #     path: ~/.platformio
      #     key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
      - name: Set up Python
        uses: actions/setup-python@v5
      - name: Install PlatformIO
        run: |
          python -m pip install --upgrade pip
          pip install --upgrade platformio

      - name: Run PlatformIO
        run: cd Firmware && make build

      - uses: actions/upload-artifact@v2
        with:
          name: Display_Binaries
          path: Firmware/.pio/build/ATmega328P/firmware.*

  delint:
    runs-on: ubuntu-latest
    name: Delinter

    steps:
      - uses: actions/checkout@v2
      # - name: Cache pip
      #   uses: actions/cache@v2
      #   with:
      #     path: ~/.cache/pip
      #     key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
      #     restore-keys: |
      #       ${{ runner.os }}-pip-
      # - name: Cache PlatformIO
      #   uses: actions/cache@v2
      #   with:
      #     path: ~/.platformio
      #     key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
      - name: Set up Python
        uses: actions/setup-python@v5
      - name: Install PlatformIO
        run: |
          whereis python3
          python -m pip install --upgrade pip
          pip install --upgrade platformio

      - name: Run Delinter
        run: cd Firmware && pio check
#
