Page 1 of 1

Check if the web build is working every time a commit is pushed

Posted: Thu Nov 30, 2023 8:19 am
by MynameisBI
In the past couple of days, I've been trying to make it so every time someone push their commit to the repository, it will automatically check if the web build have any errors.

What I've done so far is creating a workflow that builds a web package with Davidobot/love.js and host it with a python http.server. What I've been struggling is I don't really know how to check whether the application has any error since it print out the error in the web console instead of the command line so the workflow can't detect the error.

The Command Prompt and Console for the bug-free version and the error version.

How can I achieve this automatic check and travel to the CI/CD dimension.

Re: Check if the web build is working every time a commit is pushed

Posted: Sat Dec 02, 2023 1:32 pm
by dusoft
Maybe use a tool like shot-scraper or other headless solution.

Re: Check if the web build is working every time a commit is pushed

Posted: Wed Dec 06, 2023 8:36 pm
by Xugro
You can start chrome (or chromium based browsers) with debug output enabled (source):

Code: Select all

chromium --log-level=0 --enable-logging=stderr
Then everything that is printed in the web console is also printed to the command line where chrome was started.

Here an simple example javascript in a file called love.js:

Code: Select all

console.log("Hello World!");
And here the command line output:

Code: Select all

[13375:13375:1206/212614.492854:INFO:CONSOLE(1)] "Hello World!", source: http://0.0.0.0:8000/love.js (1)
You can also pipe the debug output into a file:

Code: Select all

chromium --log-level=0 --enable-logging=stderr > /tmp/ci/cd/chrome.log
And analyse that file later.

But this will only tell you if the game is starting at all. It does not tell you if the game works. The game could crash after clicking the first button. If you want to test you game in the pipeline you have to write a bot, that can play it. If it is a turn based game, this could work by taking screenshots, using image recognition (e.g. with OpenCV) and then clicking/typing like a user would. For the browser you could use browser automation tools like Selenium. If it is a real time game this will get very difficult.