Skip to content

Commit

Permalink
Track and stop running processes to make it easier to run Playwright …
Browse files Browse the repository at this point in the history
…in dev
  • Loading branch information
camertron committed Sep 17, 2024
1 parent 0ffe014 commit 8d613ee
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ jobs:
- name: Run Playwright tests
id: playwright-run
continue-on-error: true
run: npx playwright test --workers 6
run: ./script/run-playwright
- id: auto-commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
Expand Down
4 changes: 2 additions & 2 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vite: cd demo; bin/vite dev
css: cd demo; npm run build:css -- --watch
vite: cd demo; script/start-vite
css: cd demo; script/start-css
web: cd demo; bin/rails s -p 4000
4 changes: 4 additions & 0 deletions demo/script/start-css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/bash

echo $$ > tmp/pids/css.pid
exec npm run build:css -- --watch
4 changes: 4 additions & 0 deletions demo/script/start-vite
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/bash

echo $$ > tmp/pids/vite.pid
exec bin/vite dev
16 changes: 8 additions & 8 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ const config: PlaywrightTestConfig = {
baseURL: 'http://127.0.0.1:4000',
browserName: 'chromium',
headless: true,
screenshot: 'only-on-failure'
screenshot: 'only-on-failure',
},
expect: {
toHaveScreenshot: {
animations: 'disabled'
animations: 'disabled',
},
toMatchSnapshot: {
threshold: 0.1
}
threshold: 0.1,
},
},
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,

reporter: [
['line'],
['html', {open: 'never', outputFolder: path.join(__dirname, '.playwright/report')}],
['json', {outputFile: path.join(__dirname, '.playwright', 'results.json')}]
['json', {outputFile: path.join(__dirname, '.playwright', 'results.json')}],
],

webServer: {
command: 'overmind start',
port: 4000
}
command: 'script/dev',
port: 4000,
},
}

export default config
2 changes: 2 additions & 0 deletions script/dev
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ bundle check || bundle install
npm install --ignore-scripts
popd

./script/stop-existing-processes

while [[ "$#" > 0 ]]; do case $1 in
-d|--debug) debug="1"; shift;;
esac; done
Expand Down
4 changes: 4 additions & 0 deletions script/run-playwright
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/bash

./script/stop-existing-processes
exec npx playwright test --workers 6
17 changes: 17 additions & 0 deletions script/stop-existing-processes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#! /bin/bash

overmind stop
rm .overmind.sock

pidfiles=(demo/tmp/pids/css.pid demo/tmp/pids/vite.pid demo/tmp/pids/server.pid)

for pidfile in "${pidfiles[@]}"
do
if [ -f $pidfile ]; then
pid=$(cat $pidfile)
name=$(basename "$pidfile" .pid)
echo "Stopping existing $name process with pid $pid"
kill -9 $pid
rm $pidfile
fi
done

0 comments on commit 8d613ee

Please sign in to comment.