Skip to content

Commit

Permalink
Implement image diff plugin (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuliren authored Jan 7, 2023
1 parent f1fb044 commit 0ffd0e2
Show file tree
Hide file tree
Showing 24 changed files with 75,510 additions and 15,775 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
- name: Build
run: yarn build

- name: Download baseline logo image
run: curl https://stoat-dev--static.stoat.page/branding/128.png -o build/baseline-logo-128.png

- name: Run Stoat Action
uses: ./
if: always()
2 changes: 1 addition & 1 deletion .github/workflows/test-action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Setup cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Setup cache
Expand Down
6 changes: 6 additions & 0 deletions .stoat/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ plugins:
metadata:
name: Documentation
path: docs/build
image_diff:
compare_logo_image:
metadata:
name: Logo
image: docs/static/img/logo-128.png
baseline: docs/build/baseline-logo-128.png
41 changes: 20 additions & 21 deletions action/__tests__/templateHelpers.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, test } from '@jest/globals';

import { JsonPlugin, StaticHostingPlugin, StoatConfigSchema } from '../src/schemas/stoatConfigSchema';
import { ImageDiffPlugin, JsonPlugin, StaticHostingPlugin, StoatConfigSchema } from '../src/schemas/stoatConfigSchema';
import {
getLocalTemplate,
getPlugins,
Expand All @@ -27,6 +27,10 @@ const staticHosting2: StaticHostingPlugin = {
const json1: JsonPlugin = {
path: 'path1'
};
const imageDiff1: ImageDiffPlugin = {
image: 'path1',
baseline: 'baseline1'
};

describe('Read local template', () => {
test('getTemplate', async () => {
Expand All @@ -52,8 +56,14 @@ describe('Read local template', () => {
});

test('getLocalTemplate', () => {
expect(getLocalTemplate(template1Path)).toEqual({ template: template1, format: TemplateFormat.Handlebars });
expect(getLocalTemplate(template2Path)).toEqual({ template: template2, format: TemplateFormat.Jinja2 });
expect(getLocalTemplate(template1Path)).toEqual({
template: template1,
format: TemplateFormat.Handlebars
});
expect(getLocalTemplate(template2Path)).toEqual({
template: template2,
format: TemplateFormat.Jinja2
});
});
});

Expand All @@ -67,18 +77,13 @@ describe('Read remote default template', () => {
const stoatConfigWithOnePlugin: StoatConfigSchema = {
version: 1,
plugins: {
static_hosting: {
plugin1: staticHosting1
}
static_hosting: { plugin1: staticHosting1 }
}
};
const stoatConfigWithMultiPlugins: StoatConfigSchema = {
version: 1,
plugins: {
static_hosting: {
plugin1: staticHosting1,
plugin2: staticHosting2
}
static_hosting: { plugin1: staticHosting1, plugin2: staticHosting2 }
}
};

Expand Down Expand Up @@ -107,9 +112,7 @@ describe('getPlugins', () => {
getPlugins({
version: 1,
plugins: {
static_hosting: {
plugin1: staticHosting1
}
static_hosting: { plugin1: staticHosting1 }
}
})
).toEqual([Plugin.StaticHosting]);
Expand All @@ -120,15 +123,11 @@ describe('getPlugins', () => {
getPlugins({
version: 1,
plugins: {
static_hosting: {
plugin1: staticHosting1,
plugin2: staticHosting2
},
json: {
plugin3: json1
}
static_hosting: { plugin1: staticHosting1, plugin2: staticHosting2 },
json: { plugin3: json1 },
image_diff: { plugin4: imageDiff1 }
}
}).sort()
).toEqual([Plugin.Json, Plugin.StaticHosting].sort());
).toEqual([Plugin.Json, Plugin.StaticHosting, Plugin.ImageDiff].sort());
});
});
Loading

0 comments on commit 0ffd0e2

Please sign in to comment.