From ede0e97563c8473b8cfa4045c7c2cd6129ecc1aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82=C4=99biowski-Owczarek?= Date: Mon, 10 Jan 2022 18:08:58 +0100 Subject: [PATCH] Tests: Migrate from Travis to GitHub Actions Closes gh-482 --- .github/workflows/node.js.yml | 38 +++++++++++++++++++++++++++++++++++ .travis.yml | 7 ------- test/karma/karma.conf.js | 24 +++++++++++----------- 3 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/node.js.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..c128edd --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,38 @@ +name: CI + +on: [push, pull_request] + +env: + NODE_VERSION: '16.x' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Cache + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ env.NODE_VERSION }}-npm-lock- + + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v2.1.2 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Install dependencies + run: | + npm install + + - name: Run tests + env: + BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }} + BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }} + run: | + export PATH=${HOME}/firefox:$PATH + npm test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f7da72b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: node_js -node_js: -- '12' -env: - global: - - secure: UzENy1srzIScquAja5376P0dj4X6DJsskYrQjUtRpi6tvCtpx80DiFjFAY6JKUMw/BHuugABkBmP0q5o3kMbp2y6mZO0qg+CBUZ8MX/UipNv0/xWbP7ckayLXU7RvICTObfJ0bGwF5uxxoCUBJjoKFZ0YZH94Orq8XQgC8wbNMk= - - secure: EfY8wLmtbx+VH+sE0E3jRUP6hp78WjjumuWfhfB9R7+bRMhaj9kSVo+ReKQ5GExnJlm5DtU84fmDujO9gIDDgmZZ2/83PRJ5URSEXRCiyS8A82e4cw0Jz1NuU/nzUdv+gGwhdcYlKO3oTf39tPAvuxXWIwNcKddg9/NGAAZdUXI= diff --git a/test/karma/karma.conf.js b/test/karma/karma.conf.js index 49a4be0..bc6992e 100644 --- a/test/karma/karma.conf.js +++ b/test/karma/karma.conf.js @@ -3,7 +3,7 @@ var grunt = require( "grunt" ); module.exports = function( config ) { - var isTravis = process.env.TRAVIS, + var isCi = process.env.GITHUB_ACTION, dateString = grunt.config( "dateString" ), isBrowserStack = !!( process.env.BROWSER_STACK_USERNAME && process.env.BROWSER_STACK_ACCESS_KEY ), @@ -70,10 +70,10 @@ module.exports = function( config ) { // Add BrowserStack launchers customLaunchers: require( "./launchers" ), - // Make travis output less verbose - reporters: isTravis ? "dots" : "progress", + // Make GitHub Actions output less verbose + reporters: isCi ? "dots" : "progress", - colors: !isTravis, + colors: !isCi, hostname: hostName, port: 9876, @@ -93,16 +93,16 @@ module.exports = function( config ) { browserDisconnectTolerance: 3 } ); - // Deal with Travis environment - if ( isTravis ) { - - // Browserstack launcher specifies "build" options as a default value - // of "TRAVIS_BUILD_NUMBER" variable, but this way a bit more verbose - config.browserStack.build = "travis #" + process.env.TRAVIS_BUILD_NUMBER; + // Deal with the GitHub Actions environment + if ( isCi ) { + config.browserStack.build = "Sizzle GitHub #" + process.env.GITHUB_RUN_NUMBER; // You can't get access to secure environment variables from pull requests - // so we don't have browserstack from them, but travis has headless Firefox so use that - if ( !isBrowserStack && process.env.TRAVIS_PULL_REQUEST ) { + // so we don't have browserstack from them, but GitHub Actions have headless + // Firefox so use that. + // The `GITHUB_BASE_REF` env variable is only available on PRs, see: + // https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables + if ( !isBrowserStack && process.env.GITHUB_BASE_REF ) { config.browsers.push( "FirefoxHeadless" ); } }