diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7c437c5075..4904e42d39 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: diff --git a/Procfile b/Procfile index 50265a63ec..a23064be9c 100644 --- a/Procfile +++ b/Procfile @@ -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 diff --git a/demo/script/start-css b/demo/script/start-css new file mode 100755 index 0000000000..c4db313b6a --- /dev/null +++ b/demo/script/start-css @@ -0,0 +1,4 @@ +#! /bin/bash + +echo $$ > tmp/pids/css.pid +exec npm run build:css -- --watch diff --git a/demo/script/start-vite b/demo/script/start-vite new file mode 100755 index 0000000000..0c2772a96c --- /dev/null +++ b/demo/script/start-vite @@ -0,0 +1,4 @@ +#! /bin/bash + +echo $$ > tmp/pids/vite.pid +exec bin/vite dev diff --git a/playwright.config.ts b/playwright.config.ts index f187f55fe8..bd56e88eeb 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -23,15 +23,15 @@ 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, @@ -39,13 +39,13 @@ const config: PlaywrightTestConfig = { 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 diff --git a/script/dev b/script/dev index c3f85063ef..1114755fbc 100755 --- a/script/dev +++ b/script/dev @@ -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 diff --git a/script/run-playwright b/script/run-playwright new file mode 100755 index 0000000000..3c0e2d04c9 --- /dev/null +++ b/script/run-playwright @@ -0,0 +1,4 @@ +#! /bin/bash + +./script/stop-existing-processes +exec npx playwright test --workers 6 diff --git a/script/stop-existing-processes b/script/stop-existing-processes new file mode 100755 index 0000000000..7ac8b5472a --- /dev/null +++ b/script/stop-existing-processes @@ -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