Tests: Migrate from Travis to GitHub Actions

Closes gh-482
This commit is contained in:
Michał Gołębiowski-Owczarek 2022-01-10 18:08:58 +01:00 committed by GitHub
parent 20390f0573
commit ede0e97563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 19 deletions

38
.github/workflows/node.js.yml vendored Normal file
View File

@ -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

View File

@ -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=

View File

@ -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" );
}
}