# Instead of waiting for BoB to be published to npmjs.com and be upgraded
# inside mdn/interactive-examples by Dependabot, we do all those steps here
# using `npm pack`.

name: NPM Publish simulation

on:
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout mdn/interactive-examples
        uses: actions/checkout@v4
        with:
          repository: mdn/interactive-examples
          path: interactive-examples

      - name: Checkout this repository
        uses: actions/checkout@v4
        with:
          path: bob

      - name: Setup Node.js environment (interactive-examples)
        uses: actions/setup-node@v4
        with:
          node-version-file: "interactive-examples/.nvmrc"

      - name: Install all packages (interactive-examples)
        working-directory: interactive-examples
        run: npm ci

      - name: Install all packages (bob)
        working-directory: bob
        run: npm ci

      - name: Install local BoB in interactive-examples
        working-directory: interactive-examples
        run: npx install-local ../bob

      - name: Build interactive-examples
        working-directory: interactive-examples
        run: npm run build

      - name: Verify build
        working-directory: interactive-examples/docs
        run: |
          set -x
          test -e css/codemirror.css
          test -e css/editor-css.css
          test -e css/editor-js.css
          test -e css/editor-tabbed.css
          test -e css/editor-wat.css
          test -e js/codemirror.js
          test -e js/editor-css.js
          test -e js/editor-js.js
          test -e js/editor-tabbed.js
          test -e js/editor-wat.js
          test -e media/dino.svg
          test -e media/cc0-audio/t-rex-roar.mp3
          test -e media/cc0-images/gecko-320-213.jpg
          test -e media/cc0-videos/flower.webm
          test -e media/examples/firefox-logo.svg
          test -e media/fonts/Inter.var.woff2
          test -e pages/css/color.html
          test -e pages/js/array-filter.html
          test -e pages/tabbed/details.html
          test -e pages/wat/floor.html
          test -e pages/webapi-tabbed/document-queryselector.html
          test -e pages/webapi-tabbed/document-queryselector.html
