name: PR Checks

on:
  pull_request:
    branches:
      - main

jobs:
  pr-checks:
    runs-on: ubuntu-latest
    steps:
      - name: Install Node
        run: |
          apt-get update && apt-get install -y nodejs
      - name: Checkout
        uses: actions/checkout@v4
        with:
          # super-linter needs the full git history to get the
          # list of files that changed across commits
          fetch-depth: 0

      # This _shouldn't_ be necessary, since `node_modules` are checked-in?
      # But, adding it because, without it, I get `Cannot find module '/workspace/scubbo/commit-report-sync/node_modules/.../...out/index.js'.
      # Please verify that the package.json has a valid "main" entry
      # Weird!
      - name: Install
        run: npm ci
          
# Usually I would...
#      - name: Super Linter
#        uses: super-linter/super-linter@v7.3.0
# But it's not playing nice with Gitea Actions:
# https://gitea.scubbo.org/scubbo/commit-report-sync/actions/runs/11/jobs/0
# `failed to create container: 'Error response from daemon: conflicting options: custom host-to-IP mapping and the network mode'`
# So, while getting this working, falling back to ESLint and Prettier.
#
# Also TODO - convert these to actually fix problems, not just report them (mostly pretty easy - `--write` for prettier,
# and I gotta assume there's similar for `eslint` - but, I want to only change one thing at a time!)
      - name: ESLint
        run: |
          npm install eslint
          npx eslint .
      - name: Prettier
        run: |
          npm install prettier
          npx prettier .
