Skip to content

Commit

Permalink
chore: move CI builds from travis-ci.org to GitHub actions (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Lukashov committed Jul 6, 2021
1 parent 45931e4 commit dff9c3d
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 96 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Unit Tests

# all pull requests
on: pull_request

jobs:
unit-tests-p2:
name: Polymer 2 on the CI agent
runs-on: ubuntu-latest
steps:
- name: Set up Node 12.x
uses: actions/setup-node@v2
with:
node-version: 12.x

- name: Check out the source code
uses: actions/checkout@v2

- name: Install global npm dependencies
# bower is needed to run 'bower install'
# polymer-cli is needed to run the lint step
# web-component-tester is needed to run the test step
run: "npm install --quiet --no-progress --global bower polymer-cli web-component-tester"

- name: Install project npm dependencies
run: "npm install --quiet --no-progress"

- name: Install project Bower dependencies
run: "bower install --quiet"

- name: Run automated magi-cli checks
run: "npm run check"

- name: Run a linter
run: "npm run lint"

# the full set of environments is tested with Polymer 3 below
- name: Run unit tests locally (in the VM instance running this job)
run: "xvfb-run -s '-screen 0 1024x768x24' wct"

unit-tests-p3:
name: Polymer 3 on SauceLabs
runs-on: ubuntu-latest
steps:
- name: Set up Node 12.x
uses: actions/setup-node@v2
with:
node-version: 12.x

- name: Check out the (Polymer 2) source code
uses: actions/checkout@v2

- name: Install global npm dependencies
# magi-cli, bower and polymer-modulizer are needed to run the Polymer 3 conversion step
# web-component-tester is needed to run the test step
run: "npm install --quiet --no-progress --global bower magi-cli web-component-tester polymer-modulizer"

- name: Convert the source code to Polymer 3
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
magi p3-convert --out . --import-style=name
# Using yarn instead of npm here to check that the dependency tree does not have two
# versions of the same component. With P2 / Bower that is checked automatically, but
# with P3 / npm it is not.
- name: Install project npm dependencies
run: "yarn install --flat"

# workaround for running tests on Android on SauceLabs (see wct.conf.js)
- name: Add 'localhost-for-saucelabs' to /etc/hosts
run: echo "127.0.0.1 localhost-for-saucelabs" | sudo tee -a /etc/hosts

- name: Run unit tests on SauceLabs
run: "wct --npm --env saucelabs"
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
41 changes: 41 additions & 0 deletions .github/workflows/visual-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Visual Tests

# all pull requests
on: pull_request

jobs:
visual-tests:
name: Polymer 2 on SauceLabs
runs-on: ubuntu-latest
steps:
- name: Set up Node 12.x
uses: actions/setup-node@v2
with:
node-version: 12.x

- name: Check out the source code
uses: actions/checkout@v2

- name: Install global npm dependencies
# bower is needed to run 'bower install'
# gemini is needed to run the visual tests step
run: "npm install --quiet --no-progress --global bower gemini@^4.0.0 gemini-sauce gemini-polyserve"

- name: Install project npm dependencies
run: "npm install --quiet --no-progress"

- name: Install project Bower dependencies
run: "bower install --quiet"

- name: Run visual tests on SauceLabs
run: "gemini test --reporter html --reporter flat test/visual"
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}

- name: Publish the Visual Tests failures report as an Artifact for this Workflow run
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: Visual tests failures report
path: gemini-report/
67 changes: 0 additions & 67 deletions .travis.yml

This file was deleted.

51 changes: 22 additions & 29 deletions wct.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
var envIndex = process.argv.indexOf('--env') + 1;
var env = envIndex ? process.argv[envIndex] : undefined;

// workaround for Android 7+ blocking all HTTP traffic
// see https://wiki.saucelabs.com/display/DOCS/Known+Issues
// add it to your own local `/etc/hosts` to run SauceLabs tests locally
var tunneledLocalhost = 'localhost-for-saucelabs';

module.exports = {
testTimeout: 180 * 1000,
verbose: false,
Expand Down Expand Up @@ -32,43 +37,31 @@ module.exports = {
},

registerHooks: function(context) {
const saucelabsPlatformsMobile = [
'iOS Simulator/iphone@12.2',
'iOS Simulator/iphone@10.3'
];

const saucelabsPlatformsMicrosoft = [
'Windows 10/microsoftedge@18',
'Windows 10/internet explorer@11'
];

const saucelabsPlatformsDesktop = [
'macOS 10.13/safari@latest'
];

const saucelabsPlatforms = [
...saucelabsPlatformsMobile,
...saucelabsPlatformsMicrosoft,
...saucelabsPlatformsDesktop
];

const cronPlatforms = [
const testBrowsers = [
{
deviceName: 'Android GoogleAPI Emulator',
platformName: 'Android',
platformVersion: '8.1',
browserName: 'chrome'
platformVersion: '11.0',
browserName: 'Chrome',
},
'iOS Simulator/ipad@12.2',
'iOS Simulator/iphone@10.3',
'iOS Simulator/iphone@10.3', // should be 9.x, but SauceLabs does not provide that
'macOS 11/safari@latest',
'Windows 10/microsoftedge@latest',
'Windows 10/microsoftedge@18',
'Windows 10/internet explorer@11',
'Windows 10/chrome@latest',
'Windows 10/firefox@latest'
'Windows 10/firefox@latest',
'Windows 10/firefox@78', // latest ESR as of 2021-06-30
];

if (env === 'saucelabs') {
context.options.plugins.sauce.browsers = saucelabsPlatforms;
} else if (env === 'saucelabs-cron') {
context.options.plugins.sauce.browsers = cronPlatforms;
context.options.webserver = context.options.webserver || {};
context.options.webserver.hostname = tunneledLocalhost;
context.options.plugins.sauce.tunnelOptions = {
tunnelDomains: tunneledLocalhost
};

context.options.plugins.sauce.browsers = testBrowsers;
}
}
};

0 comments on commit dff9c3d

Please sign in to comment.