Create frontend plugin frontend-plugin-demo-2 #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Playwright tests | |
on: | |
pull_request: | |
branches: [main] | |
jobs: | |
changes: | |
name: Scan for changes | |
runs-on: ubuntu-latest | |
outputs: | |
plugins: ${{ steps.scan.outputs.plugins }} | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4 | |
with: | |
node-version: 18 | |
- name: Determine changes | |
id: scan | |
env: | |
HEAD: ${{ github.sha }} | |
BASE: ${{ github.event.pull_request.base.sha }} | |
run: | | |
root=$(pwd) | |
cd plugins | |
changed=() | |
for f in */; do | |
if git diff --name-only $BASE $HEAD | grep $f -q; then | |
if [[ ! -L "$f" && -f "$f/package.json" ]]; then | |
cd $f | |
if npm run | grep ui-test -q; then | |
changed+=($f) | |
fi | |
cd $root/plugins | |
fi | |
fi | |
done | |
JSON="[$(echo ${changed[@]} | sed 's/ /,/g')]" | |
echo "plugins=$(echo $JSON)" >> $GITHUB_OUTPUT | |
playwright: | |
name: 'Run Playwright Tests' | |
needs: changes | |
if: needs.changes.outputs.plugins != '[]' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: yarn | |
- name: Install playwright | |
run: yarn playwright install --with-deps chromium | |
- name: Run tests | |
env: | |
PLUGINS: ${{ needs.changes.outputs.plugins }} | |
run: | | |
root=$(pwd) | |
cd packages/backend | |
readarray folders < <(echo $PLUGINS | sed 's/[][]//g' | sed 's/,/ /g') | |
# enable permission support and RBAC plugins | |
printf "\npermission:\n enabled: true\n" >> ${root}/app-config.yaml | |
cd $root/plugins | |
# Launch suitable plugins with changes | |
for f in $folders; do | |
cd $f | |
echo "Starting $f plugin" | |
tmpfile=$(mktemp) | |
# Start the plugin | |
yarn start >$tmpfile 2>&1 & | |
for attempt in $(seq 1 45); do | |
sleep 1 | |
if grep -q "Error:" $tmpfile; then | |
cat $tmpfile | |
exit 1 | |
fi | |
if grep -q "webpack compiled" $tmpfile; then | |
echo "$f started" | |
break | |
fi | |
if [[ attempt -eq 45 ]]; then | |
echo "Failed to launch $f" | |
cat $tmpfile | |
exit 1 | |
fi | |
done | |
# Run UI tests | |
yarn run ui-test | |
# Kill the plugin | |
pid=$(lsof -i :3000 -Fp | grep p | sed s/p//) | |
kill -9 $pid | |
echo "$f shut down" | |
cd $root/plugins | |
done | |
- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4 | |
if: always() | |
with: | |
name: playwright-report | |
path: plugins/*/playwright-report/ | |
retention-days: 1 |