diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..e5f4782e90 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: CI + +on: + push: + branches: + - develop + pull_request: + branches: + - develop + +env: + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1 + +jobs: + build: + strategy: + max-parallel: 1 + matrix: + browser: ["mac-chrome-latest","mac-firefox-latest","mac-safari-latest","windows-chrome-latest","windows-firefox-latest","windows-edge-latest","ios-latest"] + name: Build assets + runs-on: [ubuntu-latest] + steps: + + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.6.0 + with: + access_token: ${{ github.token }} + + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up node + uses: actions/setup-node@v1 + with: + node-version: '12.x' + + - name: Cache node modules + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install Node.js dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Lint & Karma + env: + BROWSER: ${{ matrix.browser }} + run: npm run lint-and-karma || npm run lint-and-karma diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000000..d13699ab90 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,49 @@ +name: Deploy + +on: + workflow_run: + workflows: ['CI'] + branches: [develop] + types: + - completed + +jobs: + build: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: [ubuntu-latest] + steps: + + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.6.0 + with: + access_token: ${{ github.token }} + + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up node + uses: actions/setup-node@v1 + with: + node-version: '12.x' + + - name: Set GitHub packages registry + run: | + npm config set '//npm.pkg.github.com/:_authToken' ${{ secrets.GH_TOKEN }} + npm config set @typeform:registry https://npm.pkg.github.com/ + + - name: Cache node modules + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install Node.js dependencies + run: npm ci + + - name: Deploy + if: contains(github.ref, 'refs/heads/develop') + run: | + npm run build + npm run semantic-release diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 92095577c3..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -language: node_js -node_js: - - 'lts/*' - -branches: - only: - - develop -os: - - linux -dist: xenial - -before_install: - - npm config set '//npm.pkg.github.com/:_authToken' $GH_TOKEN - - npm config set @typeform:registry https://npm.pkg.github.com/ - -install: - - npm ci - -script: - - npm run build - - travis_retry npm run travis - -env: - global: - - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 - jobs: - - BROWSER=mac-chrome-latest - - BROWSER=mac-firefox-latest - - BROWSER=mac-safari-latest - - BROWSER=windows-chrome-latest - - BROWSER=windows-firefox-latest - - BROWSER=windows-edge-latest - - BROWSER=ios-latest - # - BROWSER=android-latest - -jobs: - allow_failures: - - env: BROWSER=android-latest - include: - - stage: "Deploy" - if: (NOT type IN (pull_request)) AND (branch = develop) - script: - - npm run build - - npm run semantic-release diff --git a/_develop/karma.config.js b/_develop/karma.config.js index 5893c90994..c6955f5400 100644 --- a/_develop/karma.config.js +++ b/_develop/karma.config.js @@ -54,7 +54,7 @@ module.exports = config => { }); /* eslint-disable no-param-reassign */ - if (process.env.TRAVIS) { + if (process.env.CI) { config.transports = ['polling']; config.browsers = [process.env.BROWSER]; config.browserDisconnectTimeout = 10000; diff --git a/_develop/sauce.js b/_develop/sauce.js index f8448d5ead..0a56412ad5 100644 --- a/_develop/sauce.js +++ b/_develop/sauce.js @@ -1,10 +1,10 @@ const _ = require('lodash'); const os = require('os'); -if (process.env.TRAVIS) { +if (process.env.CI) { module.exports = { - build: process.env.TRAVIS_BUILD_ID, - tunnel: process.env.TRAVIS_JOB_NUMBER, + build: process.env.GITHUB_RUN_ID, + tunnel: process.env.GITHUB_RUN_NUMBER, }; } else { const id = _.random(16 * 16 * 16 * 16).toString(16); diff --git a/package.json b/package.json index 404f927d72..00bdffba6d 100644 --- a/package.json +++ b/package.json @@ -162,7 +162,7 @@ "test:functional": "./_develop/scripts/puppeteer.sh", "test:unit": "npm run build; karma start _develop/karma.config.js", "test:coverage": "webpack --env.coverage --config _develop/webpack.config.js; karma start _develop/karma.config.js --reporters coverage", - "travis": "npm run lint && karma start _develop/karma.config.js --reporters dots,saucelabs" + "lint-and-karma": "npm run lint && karma start _develop/karma.config.js --reporters dots,saucelabs" }, "keywords": [ "editor",