|
| 1 | +# Publicly credit Sauce Labs because they generously support open source |
| 2 | +# projects. |
| 3 | +name: Frontend Tests |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_call: |
| 7 | + |
| 8 | +jobs: |
| 9 | + test-frontend: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - |
| 14 | + name: Check out Etherpad core |
| 15 | + uses: actions/checkout@v3 |
| 16 | + with: |
| 17 | + repository: ether/etherpad-lite |
| 18 | + - uses: pnpm/action-setup@v3 |
| 19 | + name: Install pnpm |
| 20 | + with: |
| 21 | + version: 8 |
| 22 | + run_install: false |
| 23 | + - name: Get pnpm store directory |
| 24 | + shell: bash |
| 25 | + run: | |
| 26 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 27 | + - uses: actions/cache@v4 |
| 28 | + name: Setup pnpm cache |
| 29 | + with: |
| 30 | + path: ${{ env.STORE_PATH }} |
| 31 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 32 | + restore-keys: | |
| 33 | + ${{ runner.os }}-pnpm-store- |
| 34 | + - |
| 35 | + name: Check out the plugin |
| 36 | + uses: actions/checkout@v3 |
| 37 | + with: |
| 38 | + path: ./node_modules/__tmp |
| 39 | + - |
| 40 | + name: export GIT_HASH to env |
| 41 | + id: environment |
| 42 | + run: | |
| 43 | + cd ./node_modules/__tmp |
| 44 | + echo "::set-output name=sha_short::$(git rev-parse --short ${{ github.sha }})" |
| 45 | + - |
| 46 | + name: Determine plugin name |
| 47 | + id: plugin_name |
| 48 | + run: | |
| 49 | + cd ./node_modules/__tmp |
| 50 | + npx -c 'printf %s\\n "::set-output name=plugin_name::${npm_package_name}"' |
| 51 | + - |
| 52 | + name: Rename plugin directory |
| 53 | + env: |
| 54 | + PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }} |
| 55 | + run: | |
| 56 | + mv ./node_modules/__tmp ./node_modules/"${PLUGIN_NAME}" |
| 57 | + - |
| 58 | + name: Install plugin dependencies |
| 59 | + env: |
| 60 | + PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }} |
| 61 | + run: | |
| 62 | + cd ./node_modules/"${PLUGIN_NAME}" |
| 63 | + pnpm i |
| 64 | + # Etherpad core dependencies must be installed after installing the |
| 65 | + # plugin's dependencies, otherwise npm will try to hoist common |
| 66 | + # dependencies by removing them from src/node_modules and installing them |
| 67 | + # in the top-level node_modules. As of v6.14.10, npm's hoist logic appears |
| 68 | + # to be buggy, because it sometimes removes dependencies from |
| 69 | + # src/node_modules but fails to add them to the top-level node_modules. |
| 70 | + # Even if npm correctly hoists the dependencies, the hoisting seems to |
| 71 | + # confuse tools such as `npm outdated`, `npm update`, and some ESLint |
| 72 | + # rules. |
| 73 | + - |
| 74 | + name: Install Etherpad core dependencies |
| 75 | + run: bin/installDeps.sh |
| 76 | + - name: Create settings.json |
| 77 | + run: cp ./src/tests/settings.json settings.json |
| 78 | + - name: Run the frontend tests |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + pnpm run dev & |
| 82 | + connected=false |
| 83 | + can_connect() { |
| 84 | + curl -sSfo /dev/null http://localhost:9001/ || return 1 |
| 85 | + connected=true |
| 86 | + } |
| 87 | + now() { date +%s; } |
| 88 | + start=$(now) |
| 89 | + while [ $(($(now) - $start)) -le 15 ] && ! can_connect; do |
| 90 | + sleep 1 |
| 91 | + done |
| 92 | + cd src |
| 93 | + pnpm exec playwright install chromium --with-deps |
| 94 | + pnpm run test-ui --project=chromium |
0 commit comments