2021-06-15 01:55:18 +02:00
|
|
|
# Publicly credit Sauce Labs because they generously support open source
|
|
|
|
# projects.
|
2024-03-16 20:38:00 +01:00
|
|
|
name: Frontend Tests
|
2021-06-15 01:55:18 +02:00
|
|
|
|
2024-03-16 20:38:00 +01:00
|
|
|
on:
|
|
|
|
workflow_call:
|
2021-06-15 01:55:18 +02:00
|
|
|
|
|
|
|
jobs:
|
2024-03-16 20:38:00 +01:00
|
|
|
test-frontend:
|
2021-06-15 01:55:18 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
|
|
|
name: Check out Etherpad core
|
2022-03-01 23:17:16 +01:00
|
|
|
uses: actions/checkout@v3
|
2022-01-28 07:33:52 +01:00
|
|
|
with:
|
|
|
|
repository: ether/etherpad-lite
|
2024-03-13 19:11:19 +01:00
|
|
|
- uses: pnpm/action-setup@v3
|
|
|
|
name: Install pnpm
|
|
|
|
with:
|
|
|
|
version: 8
|
|
|
|
run_install: false
|
|
|
|
- name: Get pnpm store directory
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
|
|
- uses: actions/cache@v4
|
|
|
|
name: Setup pnpm cache
|
2022-01-28 07:33:52 +01:00
|
|
|
with:
|
2024-03-13 19:11:19 +01:00
|
|
|
path: ${{ env.STORE_PATH }}
|
|
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-pnpm-store-
|
2022-01-28 07:33:52 +01:00
|
|
|
-
|
|
|
|
name: Check out the plugin
|
2022-03-01 23:17:16 +01:00
|
|
|
uses: actions/checkout@v3
|
2022-01-28 07:33:52 +01:00
|
|
|
with:
|
|
|
|
path: ./node_modules/__tmp
|
|
|
|
-
|
|
|
|
name: export GIT_HASH to env
|
|
|
|
id: environment
|
|
|
|
run: |
|
|
|
|
cd ./node_modules/__tmp
|
|
|
|
echo "::set-output name=sha_short::$(git rev-parse --short ${{ github.sha }})"
|
|
|
|
-
|
|
|
|
name: Determine plugin name
|
|
|
|
id: plugin_name
|
|
|
|
run: |
|
|
|
|
cd ./node_modules/__tmp
|
|
|
|
npx -c 'printf %s\\n "::set-output name=plugin_name::${npm_package_name}"'
|
|
|
|
-
|
|
|
|
name: Rename plugin directory
|
|
|
|
env:
|
|
|
|
PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }}
|
|
|
|
run: |
|
|
|
|
mv ./node_modules/__tmp ./node_modules/"${PLUGIN_NAME}"
|
|
|
|
-
|
|
|
|
name: Install plugin dependencies
|
|
|
|
env:
|
|
|
|
PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }}
|
|
|
|
run: |
|
|
|
|
cd ./node_modules/"${PLUGIN_NAME}"
|
2024-03-13 19:11:19 +01:00
|
|
|
pnpm i
|
2022-01-28 07:33:52 +01:00
|
|
|
# Etherpad core dependencies must be installed after installing the
|
|
|
|
# plugin's dependencies, otherwise npm will try to hoist common
|
|
|
|
# dependencies by removing them from src/node_modules and installing them
|
|
|
|
# in the top-level node_modules. As of v6.14.10, npm's hoist logic appears
|
|
|
|
# to be buggy, because it sometimes removes dependencies from
|
|
|
|
# src/node_modules but fails to add them to the top-level node_modules.
|
|
|
|
# Even if npm correctly hoists the dependencies, the hoisting seems to
|
|
|
|
# confuse tools such as `npm outdated`, `npm update`, and some ESLint
|
|
|
|
# rules.
|
|
|
|
-
|
|
|
|
name: Install Etherpad core dependencies
|
2024-02-21 21:50:11 +01:00
|
|
|
run: bin/installDeps.sh
|
2024-03-13 19:11:19 +01:00
|
|
|
- name: Create settings.json
|
|
|
|
run: cp ./src/tests/settings.json settings.json
|
|
|
|
- name: Run the frontend tests
|
2022-01-28 07:33:52 +01:00
|
|
|
shell: bash
|
|
|
|
run: |
|
2024-07-18 08:51:30 +02:00
|
|
|
pnpm run prod &
|
2024-03-13 19:11:19 +01:00
|
|
|
connected=false
|
|
|
|
can_connect() {
|
|
|
|
curl -sSfo /dev/null http://localhost:9001/ || return 1
|
|
|
|
connected=true
|
|
|
|
}
|
|
|
|
now() { date +%s; }
|
|
|
|
start=$(now)
|
|
|
|
while [ $(($(now) - $start)) -le 15 ] && ! can_connect; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
cd src
|
|
|
|
pnpm exec playwright install chromium --with-deps
|
|
|
|
pnpm run test-ui --project=chromium
|