1- name : " Backend tests "
1+ name : Backend Tests
22
33# any branch is useful for testing before a PR is submitted
4- on : [push, pull_request]
4+ on :
5+ workflow_call :
56
67jobs :
78 withplugins :
@@ -12,66 +13,80 @@ jobs:
1213 || (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id)
1314 name : with Plugins
1415 runs-on : ubuntu-latest
15-
1616 steps :
1717 -
1818 name : Install libreoffice
19- run : |
20- sudo add-apt-repository -y ppa:libreoffice/ppa
21- sudo apt update
22- sudo apt install -y --no-install-recommends libreoffice libreoffice-pdfimport
19+ 20+ with :
21+ packages : libreoffice libreoffice-pdfimport
22+ version : 1.0
2323 -
2424 name : Install etherpad core
25- uses : actions/checkout@v4
25+ uses : actions/checkout@v3
2626 with :
2727 repository : ether/etherpad-lite
28+ path : etherpad-lite
29+ - uses : pnpm/action-setup@v3
30+ name : Install pnpm
31+ with :
32+ version : 8
33+ run_install : false
34+ - name : Get pnpm store directory
35+ shell : bash
36+ run : |
37+ echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
38+ - uses : actions/cache@v4
39+ name : Setup pnpm cache
40+ with :
41+ path : ${{ env.STORE_PATH }}
42+ key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
43+ restore-keys : |
44+ ${{ runner.os }}-pnpm-store-
2845 -
2946 name : Checkout plugin repository
30- uses : actions/checkout@v4
47+ uses : actions/checkout@v3
3148 with :
32- path : ./node_modules/__tmp
49+ path : plugin
3350 -
3451 name : Determine plugin name
3552 id : plugin_name
53+ working-directory : ./plugin
3654 run : |
37- cd ./node_modules/__tmp
3855 npx -c 'printf %s\\n "::set-output name=plugin_name::${npm_package_name}"'
3956 -
40- name : Rename plugin directory
57+ name : Link plugin directory
58+ working-directory : ./plugin
4159 run : |
42- mv ./node_modules/__tmp ./node_modules/"${PLUGIN_NAME}"
43- env :
44- PLUGIN_NAME : ${{ steps.plugin_name.outputs.plugin_name }}
60+ pnpm link --global
61+ - name : Remove tests
62+ working-directory : ./etherpad-lite
63+ run : rm -rf ./src/tests/backend/specs
4564 -
46- uses : actions/setup-node@v3
47- with :
48- node-version : 20
49- cache : ' npm'
50- cache-dependency-path : |
51- src/package-lock.json
52- src/bin/doc/package-lock.json
53- node_modules/${{ steps.plugin_name.outputs.plugin_name }}/package-lock.json
54- -
run :
npm install [email protected] -g 55- name : Install legacy npm for correct dependency resolution
56- -
57- name : Install plugin dependencies
65+ name : Install Etherpad core dependencies
66+ working-directory : ./etherpad-lite
67+ run : bin/installDeps.sh
68+ - name : Link plugin to etherpad-lite
69+ working-directory : ./etherpad-lite
5870 run : |
59- cd ./node_modules/"${ PLUGIN_NAME}"
60- npm ci
71+ pnpm link --global $ PLUGIN_NAME
72+ pnpm run install-plugins --path ../../plugin
6173 env :
6274 PLUGIN_NAME : ${{ steps.plugin_name.outputs.plugin_name }}
63- # Etherpad core dependencies must be installed after installing the
64- # plugin's dependencies, otherwise npm will try to hoist common
65- # dependencies by removing them from src/node_modules and installing them
66- # in the top-level node_modules. As of v6.14.10, npm's hoist logic appears
67- # to be buggy, because it sometimes removes dependencies from
68- # src/node_modules but fails to add them to the top-level node_modules.
69- # Even if npm correctly hoists the dependencies, the hoisting seems to
70- # confuse tools such as `npm outdated`, `npm update`, and some ESLint
71- # rules.
72- -
73- name : Install Etherpad core dependencies
74- run : src/bin/installDeps.sh
75+ - name : Link ep_etherpad-lite
76+ working-directory : ./etherpad-lite/src
77+ run : |
78+ pnpm link --global
79+ - name : Link etherpad to plugin
80+ working-directory : ./plugin
81+ run : |
82+ pnpm link --global ep_etherpad-lite
7583 -
7684 name : Run the backend tests
77- run : cd src && npm test
85+ working-directory : ./etherpad-lite
86+ run : |
87+ res=$(find .. -path "./node_modules/ep_*/static/tests/backend/specs/**" | wc -l)
88+ if [ $res -eq 0 ]; then
89+ echo "No backend tests found"
90+ else
91+ pnpm run test
92+ fi
0 commit comments