when:
  - event: ["push", "pull_request"]
    branch: master
    paths:
      - web/**
      - flake.nix
      - flake.lock
      - nix/pkgs/web-static-files.nix

engine: microvm
image: nixos

dependencies:
  - nodejs

steps:
  - name: install web deps
    command: |
      cd web
      corepack pnpm install --frozen-lockfile

  - name: lint web
    command: |
      cd web
      corepack pnpm run lint

  - name: typecheck web
    command: |
      cd web
      corepack pnpm run check

  - name: test web
    command: |
      cd web
      corepack pnpm run test:unit -- --run

  - name: sync web static assets
    command: |
      out=$(nix build .#web-static-files --no-link --print-out-paths)
      mkdir -p web/static
      rm -rf web/static/fonts web/static/logos
      cp -fr --no-preserve=ownership,mode "$out"/* web/static

  - name: build web
    command: |
      cd web
      corepack pnpm run build
