# You need to change lines 38 and 46 in case the plugin's name on npmjs.com is different
# from the repository name

name: "Backend tests"

# any branch is useful for testing before a PR is submitted
on: [push, pull_request]

jobs:
  withplugins:
    # run on pushes to any branch
    # run on PRs from external forks
    if: |
         (github.event_name != 'pull_request')
         || (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id)
    name: with Plugins
    runs-on: ubuntu-latest

    steps:
    - name: Install libreoffice
      run: |
        sudo add-apt-repository -y ppa:libreoffice/ppa
        sudo apt update
        sudo apt install -y --no-install-recommends libreoffice libreoffice-pdfimport

    # clone etherpad-lite
    - name: Install etherpad core
      uses: actions/checkout@v2
      with:
        repository: ether/etherpad-lite

    - name: Install all dependencies and symlink for ep_etherpad-lite
      run: src/bin/installDeps.sh

    # clone this repository into node_modules/ep_plugin-name
    - name: Checkout plugin repository
      uses: actions/checkout@v2
      with:
        path: ./node_modules/${{github.event.repository.name}}

    - name: Install plugin dependencies
      run: |
        cd node_modules/${{github.event.repository.name}}
        npm ci

    - name: Run the backend tests
      run: cd src && npm test

##ETHERPAD_NPM_V=2
## NPM configuration automatically created using src/bin/plugins/updateAllPluginsScript.sh
