name: CI

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-node@v3
        with:
          node-version: "lts/*"

      - name: Install dependencies
        run: npm ci

      - name: Build Insect
        run: npm run build

      - name: Run tests
        run: npm test

name: CI

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-node@v3
        with:
          node-version: "lts/*"

      - name: Install dependencies
        run: npm ci

      - name: Build Insect
        run: npm run build

      - name: Run tests
        run: npm test

      - name: Generate README
        uses: docker://pandoc/core:2.19
        with:
          entrypoint: ./docs/generate

      - name: Check generated README is up to date
        run: |
          if [ -n "$(git status --porcelain README.md)" ]; then
            echo 'There is a mismatch between the autogenerated `README.md` file and the source files in the `docs` directory. If you have edited `README.md` directly, please modify the files in `docs` instead, then run `./docs/generate`. If you already modified the files in `docs`, please run `./docs/generate`.'
            echo 'Note that you need to have Pandoc (https://pandoc.org) installed to run `./docs/generate`. You can find the Pandoc version used by Insect in `.github/workflows/ci.yml` (note that the patch version is intentionally not specified in the workflow file, but it'\''s okay for you to have it).'
            echo
            echo "Here's the diff:"
            git diff README.md
            exit 1
          fi

Check in CI that the README is up to date
Check in CI that the README is up to date
