Switch from Travis to GitHub Workflows (#1234)

This commit is contained in:
Daniel Huigens 2021-02-12 20:49:01 +01:00
parent 01be7b7ec1
commit ce983e5a2d
7 changed files with 91 additions and 113 deletions

View File

@ -1,14 +0,0 @@
---
engines:
duplication:
enabled: true
config:
languages:
- javascript
eslint:
enabled: true
fixme:
enabled: true
ratings:
paths:
- "lib/**/*"

40
.github/workflows/browserstack.yml vendored Normal file
View File

@ -0,0 +1,40 @@
name: Test on Browserstack
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
full:
name: Full Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- run: npm ci
- run: npm run build-test
- run: npm run browserstack
lightweight:
name: Lightweight Build
needs: full
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- run: npm ci
- run: npm run build-test --lightweight
- run: npm run browserstack
env:
LIGHTWEIGHT: true
env:
BROWSERSTACK_USERNAME: danielhuigens2
BROWSERSTACK_KEY: aW2q1ms393QRorwBnfmW

19
.github/workflows/lint.yml vendored Normal file
View File

@ -0,0 +1,19 @@
name: Lint
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
lint:
name: ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- run: npm ci
- run: npm run lint

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

@ -0,0 +1,29 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Test on Node.js
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
name: ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm test

View File

@ -1,33 +0,0 @@
language: node_js
cache: npm
addons:
code_climate:
repo_token: $CODECLIMATE_REPO_TOKEN
matrix:
include:
- node_js: "14"
env: OPENPGP_NODE_JS='14' OPENPGPJSTEST='lint'
- node_js: "14"
env: OPENPGP_NODE_JS='14' OPENPGPJSTEST='test-type-definitions'
- node_js: "10"
env: OPENPGP_NODE_JS='10' OPENPGPJSTEST='unit'
- node_js: "12"
env: OPENPGP_NODE_JS='12' OPENPGPJSTEST='unit'
- node_js: "14"
env: OPENPGP_NODE_JS='14' OPENPGPJSTEST='unit'
- node_js: "14"
env: OPENPGP_NODE_JS='14' OPENPGPJSTEST='unit' LIGHTWEIGHT=1
- node_js: "14"
env: OPENPGP_NODE_JS='14' OPENPGPJSTEST='browserstack'
- node_js: "14"
env: OPENPGP_NODE_JS='14' OPENPGPJSTEST='browserstack' LIGHTWEIGHT=1
before_script:
- npm install -g codeclimate-test-reporter browserstack-runner
script:
- $TRAVIS_BUILD_DIR/travis.sh
install: npm install
env:
global:
- BROWSERSTACK_USERNAME=danielhuigens2
- BROWSERSTACK_KEY=aW2q1ms393QRorwBnfmW

View File

@ -75,7 +75,9 @@ module.exports = function(config) {
browserStack: {
username: process.env.BROWSERSTACK_USERNAME,
accessKey: process.env.BROWSERSTACK_KEY,
project: `openpgpjs/${process.env.TRAVIS_EVENT_TYPE || 'push'}${process.env.LIGHTWEIGHT ? '/lightweight' : ''}`
build: process.env.GITHUB_SHA,
name: process.env.GITHUB_WORKFLOW,
project: `openpgpjs/${process.env.GITHUB_EVENT_NAME || 'push'}${process.env.LIGHTWEIGHT ? '/lightweight' : ''}`
},
// define browsers

View File

@ -1,65 +0,0 @@
#!/bin/bash
set -e
if [ $OPENPGPJSTEST = "coverage" ]; then
echo "Running OpenPGP.js unit tests on node.js with code coverage."
npm run coverage
codeclimate-test-reporter < coverage/lcov.info
elif [ $OPENPGPJSTEST = "lint" ]; then
echo "Running OpenPGP.js eslint."
npm run lint
elif [ $OPENPGPJSTEST = "test-type-definitions" ]; then
echo "Testing OpenPGP.js type definitions."
npm run test-type-definitions
elif [ $OPENPGPJSTEST = "unit" ]; then
echo "Running OpenPGP.js unit tests on node.js."
npm test ${LIGHTWEIGHT+ -- --grep lightweight}
elif [ $OPENPGPJSTEST = "browserstack" ]; then
echo "Running OpenPGP.js browser unit tests on Browserstack."
npm run build-test ${LIGHTWEIGHT+ -- --lightweight}
result=0
count=1
while [ $count -le 3 ]; do
[ $result -ne 0 ] && {
echo -e "\nThe command failed. Retrying, $count of 3.\n" >&2
}
npm run browserstack &
background_process_pid=$!
# https://github.com/travis-ci/travis-ci/issues/4190
seconds=0
limit=2000
while kill -0 $background_process_pid >/dev/null 2>&1; do
echo -n -e " \b" # never leave evidences!
if [ $seconds == $limit ]; then
echo -e "\nThe tests timed out.\n" >&2
exit 1
fi
seconds=$((seconds+1))
sleep 1
done
wait $background_process_pid && { result=0 && break; } || result=$?
[ $result -eq 0 ] && break
[ $seconds -gt 10 ] && break # If the tests took <10 seconds, assume they failed to launch and try again.
count=$(($count + 1))
done
[ $count -gt 3 ] && {
echo -e "\nThe command failed 3 times.\n" >&2
}
exit $result
fi