Home > Back-end >  Improve GitHub workflow performance?
Improve GitHub workflow performance?

Time:12-02

Background

  • I have created a GitHub workflow (in .github/workflows directory),
  • every command put there runs fine,
  • and ng build finishes in 5 minutes.
  • The problem is that my Jasmine unit-tests (which specify Chrome as runner), take multiple hours, which I execute like:
    ng test
    
  • Said unit-tests take only 1 minute on my local.
  • In the CI workflow I do specify Ubuntu latest,
  • But I think it runs "Headless" (without UI support, which would be pretty slow, while emulating any UI code).

Question

Is there any way to run GitHub's Workflow and/or Action NOT "Headless"?
(and by that, somehow improve performance.)

CodePudding user response:

I am thinking it is running in watch mode in your CI as well and therefore never stopping. Try creating a new script and running this new script in your ci/pipeline.

// We are turning watch off and specifying the browser as Chrome.

"test": "ng test",
"test:ci": "ng test --browser Chrome --watch=false"

Instead of npm run test in your CI, it should now be npm run test:ci. npm run test:ci should work locally for you as well where the tests just run once.

If that doesn't work, try following this. Some changes are made to the karma.conf.js and scripts to make it work in Bitbucket CI but I am thinking you wouldn't need this.

CodePudding user response:

No need to force GitHub's "Headless" server to have head (GUI support).

Nowadays we can simply configure Jasmine (or rather Karma's target browser), to run Headless as well.


Change Workflow's run into something like:

npx ng test --no-watch --no-progress --browsers=ChromeHeadlessCI

And ensure your karma.conf.js has proper settings, something like:

browsers: ['Chrome', 'ChromeHeadless', 'ChromeHeadlessCI'],
customLaunchers: {
  ChromeHeadlessCI: {
    base: 'ChromeHeadless',
    flags: ['--no-sandbox']
  }
},

See also: https://angular.io/guide/testing#configure-cli-for-ci-testing-in-chrome

  • Related