name: 3Dmol.js Coverage

on:
  workflow_dispatch:
  workflow_run:
    workflows:
     - "3Dmol.js CI"
    types:
      - completed 

jobs:
  cover:
    if: ${{ github.event.workflow_run.conclusion != 'failure' }}
    runs-on: self-hosted
    timeout-minutes: 60
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20

      # As our package has a postInstall script, which in turn calls `npm run build`, hence we do not need a explicit job for that
      - name: Install Dependencies & Build 3dmol.js
        run: npm install 

      - name: Coverage
        # coverage has trouble fetching data for some reason in the CI,
        # I don't actually care about the test results (that's tested above)
        # so ignore any failure here
        run: npm run cover
        continue-on-error: true
        timeout-minutes: 60
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v3

