mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-13 11:50:02 +01:00
try moving to Github Actions from Travis for CI (#1783)
* try moving to Github Actions from Travis for CI * npm install * add apt-get prereqs * Update continuous-integration.yml * Update .github/workflows/continuous-integration.yml Co-authored-by: Barun Acharya <47106543+daemon1024@users.noreply.github.com> * use resemblejs in gif-tests * trying `npm run setup` * fix: use ubuntu latest for github actions Co-authored-by: Barun Acharya <47106543+daemon1024@users.noreply.github.com> * Update .github/workflows/continuous-integration.yml * fix: try more changes - fix: install `libcairo2-dev` explicitly with apt. - fix: use Ubuntu 18.04 * fix<actions>: merge dependency installs in one command * fix<actions>: include more dependencies * GitHub actions running parallel (#1787) * try running tests parallely * setup composite actions * Update continuous-integration.yml * setup all jobs * just install instead of setup * trying ci without ubuntu package deps * cache node modules in ci * remove action.yml * name change for brevity * add recommended deps for tape-run * xvfb-run --auto-servernum npm run core-tests Co-authored-by: Barun Acharya <47106543+daemon1024@users.noreply.github.com> Co-authored-by: daemon1024 <barun1024@gmail.com> Co-authored-by: Harsh Khandeparkar <34770591+HarshKhandeparkar@users.noreply.github.com>
This commit is contained in:
209
.github/workflows/tests.yml
vendored
Normal file
209
.github/workflows/tests.yml
vendored
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
name: tests
|
||||||
|
on: [pull_request]
|
||||||
|
jobs:
|
||||||
|
base-tests:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '12'
|
||||||
|
check-latest: true
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-node-modules
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||||
|
${{ runner.os }}-build-
|
||||||
|
${{ runner.os }}-
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: "Base istanbul/tape node tests"
|
||||||
|
run: npm test
|
||||||
|
|
||||||
|
benchmark-tests:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '12'
|
||||||
|
check-latest: true
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-node-modules
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||||
|
${{ runner.os }}-build-
|
||||||
|
${{ runner.os }}-
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: "Benchmark tests"
|
||||||
|
run: npm run benchmark
|
||||||
|
|
||||||
|
gif-tests:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '12'
|
||||||
|
check-latest: true
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-node-modules
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||||
|
${{ runner.os }}-build-
|
||||||
|
${{ runner.os }}-
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: "Gif tests"
|
||||||
|
run: npm run gif-test
|
||||||
|
|
||||||
|
browserify-core-tests:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '12'
|
||||||
|
check-latest: true
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-node-modules
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||||
|
${{ runner.os }}-build-
|
||||||
|
${{ runner.os }}-
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm install
|
||||||
|
- run: sudo apt-get install xvfb
|
||||||
|
- name: "Browserify core tests and run"
|
||||||
|
run: grunt tests && xvfb-run --auto-servernum npm run core-tests
|
||||||
|
|
||||||
|
jsmine-ui-tests:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '12'
|
||||||
|
check-latest: true
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-node-modules
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||||
|
${{ runner.os }}-build-
|
||||||
|
${{ runner.os }}-
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: "Jasmine UI tests (mocked browser env)"
|
||||||
|
run: npm run test-ui
|
||||||
|
|
||||||
|
jest-ui-tests:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '12'
|
||||||
|
check-latest: true
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-node-modules
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||||
|
${{ runner.os }}-build-
|
||||||
|
${{ runner.os }}-
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: "jest-puppeteer UI tests (full browser env)"
|
||||||
|
run: npm run test-ui-2
|
||||||
|
|
||||||
|
cli-tests:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '12'
|
||||||
|
check-latest: true
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-node-modules
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||||
|
${{ runner.os }}-build-
|
||||||
|
${{ runner.os }}-
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: "CLI tests"
|
||||||
|
run: npm run test-cli
|
||||||
|
|
||||||
|
grunt-build-test:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '12'
|
||||||
|
check-latest: true
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-node-modules
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
||||||
|
${{ runner.os }}-build-
|
||||||
|
${{ runner.os }}-
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: "Grunt build test of dev environment"
|
||||||
|
run: grunt build
|
||||||
|
|
||||||
|
## Cache NPM folder
|
||||||
|
# cache:
|
||||||
|
# directories:
|
||||||
|
# - ~/.npm
|
||||||
|
# - ~/.cache
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
"test-ui-2": "node ./node_modules/.bin/jest",
|
"test-ui-2": "node ./node_modules/.bin/jest",
|
||||||
"test-cli": "node test/cli/*.js | tap-spec",
|
"test-cli": "node test/cli/*.js | tap-spec",
|
||||||
"setup": "npm i && npm i -g grunt grunt-cli && npm rebuild --build-from-source && grunt build",
|
"setup": "npm i && npm i -g grunt grunt-cli && npm rebuild --build-from-source && grunt build",
|
||||||
"start": "grunt serve"
|
"start": "grunt serve"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.js": [
|
"*.js": [
|
||||||
@@ -106,6 +106,7 @@
|
|||||||
"lint-staged": "^10.0.3",
|
"lint-staged": "^10.0.3",
|
||||||
"looks-same": "^7.0.0",
|
"looks-same": "^7.0.0",
|
||||||
"matchdep": "^2.0.0",
|
"matchdep": "^2.0.0",
|
||||||
|
"resemblejs": "^3.2.5",
|
||||||
"tap-spec": "^5.0.0",
|
"tap-spec": "^5.0.0",
|
||||||
"tape": "^4.9.2",
|
"tape": "^4.9.2",
|
||||||
"tape-run": "^8.0.0",
|
"tape-run": "^8.0.0",
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
const test = require('tape'),
|
const test = require('tape'),
|
||||||
base64Img = require('base64-img');
|
base64Img = require('base64-img');
|
||||||
|
|
||||||
|
const compare = require('resemblejs').compare;
|
||||||
|
|
||||||
const ImageSequencer = require('../../../src/ImageSequencer');
|
const ImageSequencer = require('../../../src/ImageSequencer');
|
||||||
|
|
||||||
const test_gif = require('../images/test.gif.js');
|
const test_gif = require('../images/test.gif.js');
|
||||||
@@ -15,19 +17,37 @@ target = 'test_outputs';
|
|||||||
* @param {String} [input="test_gif"] optional input image. Default is a test gif.
|
* @param {String} [input="test_gif"] optional input image. Default is a test gif.
|
||||||
*/
|
*/
|
||||||
module.exports = (moduleName, options, benchmark, input) => {
|
module.exports = (moduleName, options, benchmark, input) => {
|
||||||
let sequencer = ImageSequencer({ui: false});
|
let sequencer = ImageSequencer({ ui: false });
|
||||||
sequencer.loadImages(input || test_gif);
|
sequencer.loadImages(input || test_gif);
|
||||||
sequencer.addSteps(moduleName, options);
|
sequencer.addSteps(moduleName, options);
|
||||||
test(`${moduleName} module works correctly`, t => {
|
test(`${moduleName} module works correctly`, (t) => {
|
||||||
sequencer.run({mode: 'test'}, () => {
|
sequencer.run({ mode: 'test' }, () => {
|
||||||
let result = sequencer.steps[1].output.src;
|
let result = sequencer.steps[1].output.src;
|
||||||
|
|
||||||
base64Img.imgSync(result, target, `${moduleName}-result`);
|
base64Img.imgSync(result, target, `${moduleName}-result`);
|
||||||
base64Img.imgSync(benchmark, target, `${moduleName}-benchmark`);
|
base64Img.imgSync(benchmark, target, `${moduleName}-benchmark`);
|
||||||
|
|
||||||
t.equal(result === benchmark, true, `${moduleName} module works correctly with Gif`);
|
let mismatch = 100;
|
||||||
|
compare(
|
||||||
|
result,
|
||||||
|
benchmark,
|
||||||
|
{ returnEarlyThreshold: 5 },
|
||||||
|
(err, { rawMisMatchPercentage }) => {
|
||||||
|
if (err) {
|
||||||
|
console.log('An error while comparing!');
|
||||||
|
} else {
|
||||||
|
mismatch = rawMisMatchPercentage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
t.equal(
|
||||||
|
mismatch < 5,
|
||||||
|
true,
|
||||||
|
`${moduleName} module works correctly with Gif`
|
||||||
|
);
|
||||||
sequencer = null;
|
sequencer = null;
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user