Skip to content

Commit

Permalink
modify ci scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
vincanger committed Mar 4, 2024
1 parent 93d85e0 commit 5cc3400
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/opensaas-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
- name: Run Playwright tests
run: |
cd app
npx playwright test tests/whatever.spec.ts
DEBUG=pw:webserver npx playwright test tests/whatever.spec.ts
31 changes: 31 additions & 0 deletions app/ci-start-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const cp = require('child_process');
const readline = require('linebyline');

function spawn(name, cmd, args, done) {
const spawnOptions = {
detached: true,
};
const proc = cp.spawn(cmd, args, spawnOptions);

// We close stdin stream on the new process because otherwise the start-app
// process hangs.
// See https://github.com/wasp-lang/wasp/pull/1218#issuecomment-1599098272.
proc.stdin.destroy();

readline(proc.stdout).on('line', (data) => {
console.log(`\x1b[0m\x1b[33m[${name}][out]\x1b[0m ${data}`);
});
readline(proc.stderr).on('line', (data) => {
console.log(`\x1b[0m\x1b[33m[${name}][err]\x1b[0m ${data}`);
});
proc.on('exit', done);
}

// Exit if either child fails
const cb = (code) => {
if (code !== 0) {
process.exit(code);
}
};
spawn('app', 'npm', ['run', 'example-app:start-app'], cb);
spawn('db', 'npm', ['run', 'example-app:start-db'], cb);
11 changes: 9 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"name": "opensaas",
"scripts": {
"example-app:start": "node ci-start-app.js",
"example-app:start-db": "npm run example-app:cleanup-db && cd ./app && wasp start db",
"example-app:start-app": "npm run example-app:wait-for-db && npm run example-app:prepare-env && cd ./app && wasp db migrate-dev && wasp start",
"example-app:wait-for-db": "sleep 5 && ./node_modules/.bin/wait-port 5432",
"example-app:prepare-env": "cp ./app/.env.server.example ./app/.env.server",
"example-app:cleanup-db": "(docker container rm $(docker container ls -f name=^wasp-dev-db-OpenSaaS- -q) -f || true) && docker volume rm $(docker volume ls -f name=^wasp-dev-db-OpenSaaS- -q) -f || true"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.523.0",
"@aws-sdk/s3-request-presigner": "^3.523.0",
Expand Down Expand Up @@ -31,6 +39,5 @@
"prisma": "4.16.2",
"typescript": "^5.1.0",
"vite": "^4.3.9"
},
"scripts": {}
}
}
21 changes: 11 additions & 10 deletions app/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export default defineConfig({
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },

// {
// name: 'webkit',
Expand Down Expand Up @@ -71,10 +71,11 @@ export default defineConfig({
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
webServer: {
command: 'npm run example-app:start',
// Wait for the backend to start
url: 'http://localhost:3001',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
});

0 comments on commit 5cc3400

Please sign in to comment.