diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 4ad4a3f..946e5f3 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -27,14 +27,26 @@ jobs: - name: Start the server run: | npm install --prefix server - node server/app.js & + node server/app.js > server.log 2>&1 & - name: Start the testrunner run: | npm install --prefix testrunner - node testrunner/app.js & + node testrunner/app.js > testrunner.log 2>&1 & + - name: Install sitespeed.io globally + run: npm install sitespeed.io -g + - name: Show versions + run: | + docker --version + sitespeed.io --version - name: Run a test run: | git clone https://github.com/sitespeedio/sitespeed.io.git cd sitespeed.io npm install - bin/sitespeed.js https://www.wikipedia.org -n 1 --api.hostname 127.0.0.1 --api.location default --headless --api.json \ No newline at end of file + bin/sitespeed.js https://www.wikipedia.org -n 1 --api.hostname 127.0.0.1 --api.location default --headless --api.json + - name: Display Server log + if: failure() || success() + run: cat server.log + - name: Display testrunner log + if: failure() || success() + run: cat testrunner.log \ No newline at end of file diff --git a/.github/workflows/gui.yml b/.github/workflows/gui.yml new file mode 100644 index 0000000..01eb7c5 --- /dev/null +++ b/.github/workflows/gui.yml @@ -0,0 +1,52 @@ +name: Test the GUI +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + - uses: actions/checkout@v4 + - name: Install Chrome + run: | + wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - + sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' + sudo apt-get update + sudo apt-get --only-upgrade install google-chrome-stable + google-chrome --version + - name: Start dependencies + run: docker-compose -f docker-compose.yml up -d + - name: Start the server + run: | + npm install --prefix server + node server/app.js > server.log 2>&1 & + - name: Start the testrunner + run: | + npm install --prefix testrunner + node testrunner/app.js --logging.verbose true > testrunner.log 2>&1 & + - name: Install sitespeed.io globally + run: npm install sitespeed.io -g + - name: Show versions + run: | + docker --version + sitespeed.io --version + - name: Run a test + run: | + git clone https://github.com/sitespeedio/sitespeed.io.git + cd sitespeed.io + npm install + bin/sitespeed.js ../test/scripts/addatest.mjs --multi -n 1 --headless + - name: Display Server log + if: failure() || success() + run: cat server.log + - name: Display testrunner log + if: failure() || success() + run: cat testrunner.log \ No newline at end of file diff --git a/test/scripts/addatest.mjs b/test/scripts/addatest.mjs new file mode 100644 index 0000000..f46fefe --- /dev/null +++ b/test/scripts/addatest.mjs @@ -0,0 +1,16 @@ +/** + * @param {import('browsertime').BrowsertimeContext} context + * @param {import('browsertime').BrowsertimeCommands} commands + */ +export default async function (context, commands) { + await commands.navigate('http://127.0.0.1:3000/'); + await commands.addText.byId('https://www.wikipedia.org', 'url'); + await commands.select.selectByIdAndValue('iterations', 1); + await commands.mouse.singleClick.byXpath('/html/body/section/div/div[2]/ul/li[2]'); + await commands.wait.byId('commandlinearea', 5000); + await commands.addText.byId('--headless', 'commandlinearea'); + await commands.measure.start('RunTest'); + await commands.click.byIdAndWait('submittest'); + await commands.wait.byXpath('/html/body/div[2]/h1',30000); + return commands.measure.stop(); + } \ No newline at end of file diff --git a/testrunner/src/testrunners/docker-testrunner.js b/testrunner/src/testrunners/docker-testrunner.js index 6903c47..f94fdf6 100644 --- a/testrunner/src/testrunners/docker-testrunner.js +++ b/testrunner/src/testrunners/docker-testrunner.js @@ -70,7 +70,7 @@ export default async function runJob(job) { logger, dockerLogger ); - logger.info('Finished with job'); + logger.info('Finished with job with exit code: ' + testResult.exitCode); const resultQueue = await queueHandler.getQueue('result'); let runTime = testResult.result.timestamp; if ( @@ -174,6 +174,7 @@ async function runDocker( await process; } catch (error) { + logger.error('Could not run Docker:' + error); exitCode = error.exitCode; } diff --git a/testrunner/src/testrunners/testrunner.js b/testrunner/src/testrunners/testrunner.js index 2e82c32..f5ec2a8 100644 --- a/testrunner/src/testrunners/testrunner.js +++ b/testrunner/src/testrunners/testrunner.js @@ -31,7 +31,7 @@ export default async function runJob(job) { configFilePath, logger ); - logger.info('Finished job'); + logger.info('Finished job with exitCode %s', testResult.exitCode); const resultQueue = await queueHandler.getQueue('result'); let runTime = testResult.result.timestamp; @@ -130,6 +130,7 @@ async function runTest(job, workingDirectory, configFileName, logger) { await process; } catch (error) { // if sitespeed.io exits with 0 zero, execa will throw an error + logger.error('Could not run sitespeed.io', error); exitCode = error.exitCode; } try {