name: CI

on:
  push:
    branches:
      - master
      - upcoming
  pull_request:

jobs:
  build:
    if: github.actor != 'allcontributors[bot]'
    runs-on: ubuntu-latest
    env:
      GAME_REVISION: 0
      GAME_LANGUAGE: ENGLISH
      COMPARE: 0
      UNUSED_ERROR: 1
      DEPRECATED_ERROR: 1
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install binutils
        run: |
          sudo apt update
          sudo apt install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi libpng-dev python3
        # build-essential and git are already installed

      - name: ROM (Emerald)
        env:
          COMPARE: 0
          GAME_VERSION: EMERALD
        run: make -j${nproc} -O all

      - name: ROM (Firered)
        env:
          COMPARE: 0
        run: |
          make firered -j${nproc} -O

      - name: ROM (Leafgreen)
        env:
          COMPARE: 0
        run: |
          make leafgreen -j${nproc} -O

      - name: Release
        env:
          GAME_VERSION: EMERALD
        run: |
          make tidy
          make -j${nproc} release
        # make tidy to purge previous build

      - name: Test
        env:
          GAME_VERSION: EMERALD
          TEST: 1
        run: |
          make -j${nproc} check

  docs_validate:
    if: github.actor != 'allcontributors[bot]'
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Check that SUMMARY.md includes markdown doc files
        run: |
          .github/docs_validate/inclusive_summary.py

  allcontributors:
    if: github.actor == 'allcontributors[bot]'
    runs-on: ubuntu-latest
    needs: []
    steps:
      - name: Automatically pass for allcontributors
        run: echo "CI automatically passes for allcontributors" && exit 0

