bookmarks/.github/workflows/floccus.yml

223 lines
6.5 KiB
YAML

name: Floccus
on:
pull_request:
push:
branches:
- master
- stable*
paths:
- 'lib/**'
- 'composer.json'
- 'composer.lock'
- '.github/workflows/floccus.yml'
env:
APP_NAME: bookmarks
concurrency:
group: floccus-tests-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
init:
runs-on: ubuntu-latest
strategy:
# do not stop on another job's failure
fail-fast: false
matrix:
node-version: [ 20.x ]
npm-version: [ 10.x ]
floccus-branch: [ 'master', 'develop' ]
steps:
- name: Checkout floccus
uses: actions/checkout@v2
with:
path: floccus
ref: ${{ matrix.floccus-branch }}
repository: floccusAddon/floccus
- name: Set up node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Set up npm ${{ matrix.npm-version }}
run: npm i -g npm@"${{ matrix.npm-version }}"
- name: Cache node modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies & build
working-directory: floccus
run: |
npm ci
npm run build-release --if-present
- name: Save context
uses: buildjet/cache/save@v3
with:
key: floccus-context-${{ matrix.floccus-branch }}-${{ github.run_id }}
path: ./
selenium:
runs-on: ubuntu-latest
needs: init
env:
SELENIUM_HUB_HOST: hub
TEST_HOST: nextcloud
SERVER_BRANCH: ${{ matrix.server-version }}
MYSQL_PASSWORD: root
strategy:
# do not stop on another job's failure
fail-fast: false
matrix:
node-version: [20.x]
npm-version: [10.x]
server-version: ['28']
floccus-branch: ['master', 'develop']
floccus-adapter:
- nextcloud-bookmarks
- nextcloud-bookmarks-old
test-name:
- test
browsers:
- firefox
- chrome
name: ${{ matrix.browsers }} floccus@${{ matrix.floccus-branch }} ${{ matrix.floccus-adapter }}:${{ matrix.test-name}}
services:
hub:
image: selenium/hub:4.11.0-20230801
ports:
- 4442:4442
- 4443:4443
- 4444:4444
firefox:
image: selenium/node-firefox:4.11.0-20230801
env:
SE_EVENT_BUS_HOST: hub
SE_EVENT_BUS_PUBLISH_PORT: 4442
SE_EVENT_BUS_SUBSCRIBE_PORT: 4443
options: --shm-size="2g"
chrome:
image: selenium/node-chrome:4.11.0-20230801
env:
SE_EVENT_BUS_HOST: hub
SE_EVENT_BUS_PUBLISH_PORT: 4442
SE_EVENT_BUS_SUBSCRIBE_PORT: 4443
options: --shm-size="2g"
nextcloud:
image: nextcloud:${{ matrix.server-version }}
env:
NEXTCLOUD_ADMIN_USER: admin
NEXTCLOUD_ADMIN_PASSWORD: admin
MYSQL_DATABASE: nextcloud
MYSQL_USER: root
MYSQL_PASSWORD: ${{env.MYSQL_PASSWORD}}
MYSQL_HOST: mysql
NEXTCLOUD_TRUSTED_DOMAINS: nextcloud
volumes:
- /home/runner/work/bookmarks/bookmarks/apps:/var/www/html/custom_apps
options: --name nextcloud
mysql:
image: mariadb:10.5 # see https://github.com/nextcloud/docker/issues/1536
env:
MYSQL_ROOT_PASSWORD: ${{env.MYSQL_PASSWORD}}
steps:
- name: Set up node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Set up npm ${{ matrix.npm-version }}
run: npm i -g npm@"${{ matrix.npm-version }}"
- name: Restore context
uses: buildjet/cache/restore@v3
with:
fail-on-cache-miss: true
key: floccus-context-${{matrix.floccus-branch}}-${{ github.run_id }}
path: ./
- name: Checkout bookmarks app
uses: actions/checkout@v2
with:
path: ${{ env.APP_NAME }}
if: matrix.floccus-adapter == 'nextcloud-bookmarks' || matrix.floccus-adapter == 'nextcloud-bookmarks-old'
- name: Install bookmarks app
shell: bash
run: |
cd ${{ env.APP_NAME }}
composer install --ignore-platform-req=php --no-dev
if: matrix.floccus-adapter == 'nextcloud-bookmarks' || matrix.floccus-adapter == 'nextcloud-bookmarks-old'
- name: Enable bookmarks app
shell: bash
run: |
sudo cp -R ${{env.APP_NAME}} apps/
NEXT_WAIT_TIME=0
until [ $NEXT_WAIT_TIME -eq 25 ] || docker exec --user www-data nextcloud php occ app:enable ${{ env.APP_NAME }}; do
sleep $(( NEXT_WAIT_TIME++ ))
done
[ $NEXT_WAIT_TIME -lt 25 ]
if: matrix.floccus-adapter == 'nextcloud-bookmarks' || matrix.floccus-adapter == 'nextcloud-bookmarks-old'
- name: Enable APCu
run: |
NEXT_WAIT_TIME=0
until [ $NEXT_WAIT_TIME -eq 25 ] || docker exec --user www-data nextcloud php occ config:system:set --value "\\OC\\Memcache\\APCu" memcache.local; do
sleep $(( NEXT_WAIT_TIME++ ))
done
[ $NEXT_WAIT_TIME -lt 25 ]
if: matrix.floccus-adapter != 'fake'
- name: Wait for Selenium
run: |
sudo apt install -y jq
while ! curl -sSL "http://localhost:4444/wd/hub/status" 2>&1 \
| jq -r '.value.ready' 2>&1 | grep "true" >/dev/null; do
echo 'Waiting for the Grid'
sleep 1
done
echo "Selenium Grid is up - executing tests"
- name: Run tests
working-directory: floccus
env:
SELENIUM_BROWSER: ${{ matrix.browsers }}
FLOCCUS_TEST: ${{matrix.floccus-adapter}} ${{ matrix.test-name}}
run: |
npm run test
summary:
runs-on: ubuntu-latest
needs: [ init, selenium ]
if: always()
name: selenium-summary
steps:
- name: Summary status
run: if ${{ needs.init.result != 'success' || ( needs.selenium.result != 'success' && needs.selenium.result != 'skipped' ) }}; then exit 1; fi