Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions action/dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -61523,7 +61523,7 @@ async function downloadS3Directory(bucketName, s3Prefix, localDir) {
info(`Downloaded ${objects.length} file(s) to ${localDir}`);
}
async function uploadLocalDirectory(localDir, bucketName, s3Prefix) {
const files = await glob("**/*", {
const files = await glob("**/*.png", {
cwd: localDir,
nodir: true,
absolute: false
Expand Down Expand Up @@ -65565,7 +65565,6 @@ var run = async () => {
return;
}
const hash = commitHash || diffId;
const screenshotsDirectory = getInput("screenshots-directory");
const useBaseImages = getBooleanInput("use-base-images") ?? true;
if (useBaseImages) {
await downloadBaseImages();
Expand All @@ -65576,8 +65575,11 @@ var run = async () => {
const numVisualTestFailures = visualTestExitCode.filter(
(code) => code !== 0
).length;
const screenshotsDirectory = getInput("screenshots-directory");
const screenshotsPath = path6.join(process.cwd(), screenshotsDirectory);
const filesInScreenshotDirectory = sync(`${screenshotsPath}/**`, { absolute: false }) || [];
const filesInScreenshotDirectory = await glob(`${screenshotsPath}/**/*.png`, {
absolute: false
});
const diffFilePaths = filesInScreenshotDirectory.filter(
(file) => file.endsWith("diff.png")
);
Expand Down
2 changes: 1 addition & 1 deletion action/dist/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion action/dist/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -30784,7 +30784,7 @@ var post = async () => {
info("Cleaning up PNG files in screenshots directory...");
const screenshotsDirectory = getInput("screenshots-directory");
try {
const pngFiles = sync(`${screenshotsDirectory}/**/*.png`);
const pngFiles = await glob(`${screenshotsDirectory}/**/*.png`);
await (0, import_bluebird.map)(pngFiles, (file) => (0, import_promises2.rm)(file, { force: true }));
info(`Removed ${pngFiles.length} PNG file(s) from ${screenshotsDirectory}`);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion action/dist/post.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions action/src/post.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { info, getInput } from '@actions/core';
import { rm } from 'fs/promises';
import { sync as globSync } from 'glob';
import { glob } from 'glob';
import { map } from 'bluebird';

const post = async () => {
Expand All @@ -9,7 +9,7 @@ const post = async () => {
const screenshotsDirectory = getInput('screenshots-directory');

try {
const pngFiles = globSync(`${screenshotsDirectory}/**/*.png`);
const pngFiles = await glob(`${screenshotsDirectory}/**/*.png`);
await map(pngFiles, file => rm(file, { force: true }));

info(`Removed ${pngFiles.length} PNG file(s) from ${screenshotsDirectory}`);
Expand Down
10 changes: 5 additions & 5 deletions action/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { exec } from '@actions/exec';
import { octokit } from './octokit';
import { context } from '@actions/github';
import * as path from 'path';
import { sync } from 'glob';
import { glob } from 'glob';
import { unlinkSync } from 'fs';
import { createGithubComment } from './comment';
import { getLatestVisualRegressionStatus } from './get-latest-visual-regression-status';
Expand All @@ -40,8 +40,6 @@ export const run = async () => {

const hash = commitHash || diffId;

const screenshotsDirectory = getInput('screenshots-directory');

const useBaseImages = getBooleanInput('use-base-images') ?? true;
if (useBaseImages) {
await downloadBaseImages();
Expand All @@ -54,9 +52,11 @@ export const run = async () => {
code => code !== 0
).length;

const screenshotsDirectory = getInput('screenshots-directory');
const screenshotsPath = path.join(process.cwd(), screenshotsDirectory);
const filesInScreenshotDirectory =
sync(`${screenshotsPath}/**`, { absolute: false }) || [];
const filesInScreenshotDirectory = await glob(`${screenshotsPath}/**/*.png`, {
absolute: false
});
const diffFilePaths = filesInScreenshotDirectory.filter(file =>
file.endsWith('diff.png')
);
Expand Down
2 changes: 1 addition & 1 deletion action/src/s3-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async function uploadLocalDirectory(
bucketName: string,
s3Prefix: string
): Promise<void> {
const files = await glob('**/*', {
const files = await glob('**/*.png', {
cwd: localDir,
nodir: true,
absolute: false
Expand Down
48 changes: 25 additions & 23 deletions action/test/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ mock.module('../src/disable-auto-merge', () => ({
disableAutoMerge: disableAutoMergeMock
}));

const globSyncMock = mock();
const globMock = mock();
mock.module('glob', () => ({
sync: globSyncMock
glob: globMock
}));

const getInputMock = mock();
Expand Down Expand Up @@ -159,6 +159,8 @@ describe('main', () => {
unlinkSyncMock.mockReturnValue(undefined);
rmMock.mockResolvedValue(undefined);

globMock.mockResolvedValue([]);

s3OperationCalls = [];
});

Expand Down Expand Up @@ -211,7 +213,7 @@ describe('main', () => {
};
getInputMock.mockImplementation(name => extendedInputMap[name]);
execMock.mockResolvedValue(0);
globSyncMock.mockReturnValue(['path/to/screenshots/base.png']);
globMock.mockResolvedValue(['path/to/screenshots/base.png']);
await runAction();
expect(setFailedMock).not.toHaveBeenCalled();
expect(createCommitStatusMock).toHaveBeenCalledWith({
Expand All @@ -233,7 +235,7 @@ describe('main', () => {

it('should pass if visual tests pass and no diffs or new images', async () => {
execMock.mockResolvedValue(0);
globSyncMock.mockReturnValue(['path/to/screenshots/base.png']);
globMock.mockResolvedValue(['path/to/screenshots/base.png']);
await runAction();
expect(setFailedMock).not.toHaveBeenCalled();
expect(createCommitStatusMock).toHaveBeenCalledWith({
Expand All @@ -249,15 +251,15 @@ describe('main', () => {
it('should pass if visual tests pass and no diffs or new images with diff-id input', async () => {
getInputMock.mockImplementation(name => diffIdInputMap[name]);
execMock.mockResolvedValue(0);
globSyncMock.mockReturnValue(['path/to/screenshots/base.png']);
globMock.mockResolvedValue(['path/to/screenshots/base.png']);
await runAction();
expect(setFailedMock).not.toHaveBeenCalled();
assertNoOctokitCalls();
});

it('should fail if visual tests pass and some diff images were created', async () => {
execMock.mockResolvedValue(1);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/base.png',
'path/to/screenshots/diff.png',
'path/to/screenshots/new.png',
Expand Down Expand Up @@ -287,7 +289,7 @@ describe('main', () => {
it('should fail if visual tests pass and some diff images were created', async () => {
getInputMock.mockImplementation(name => diffIdInputMap[name]);
execMock.mockResolvedValue(1);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/base.png',
'path/to/screenshots/diff.png',
'path/to/screenshots/new.png',
Expand All @@ -312,7 +314,7 @@ describe('main', () => {
name => multiLineInputMapMultipleCommands[name]
);
execMock.mockResolvedValue(1);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/base.png',
'path/to/screenshots/diff.png',
'path/to/screenshots/new.png'
Expand All @@ -338,7 +340,7 @@ describe('main', () => {
name => multiLineInputMapMultipleCommands[name]
);
execMock.mockResolvedValue(1);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/base.png',
'path/to/screenshots/diff.png',
'path/to/screenshots/new.png'
Expand All @@ -350,7 +352,7 @@ describe('main', () => {

it('should pass if visual tests initially fail but pass on retry', async () => {
execMock.mockResolvedValue(0);
globSyncMock.mockReturnValue(['path/to/screenshots/diff.png']);
globMock.mockResolvedValue(['path/to/screenshots/diff.png']);
await runAction();
expect(setFailedMock).not.toHaveBeenCalled();
expect(unlinkSyncMock).toHaveBeenCalledWith('path/to/screenshots/diff.png');
Expand All @@ -367,7 +369,7 @@ describe('main', () => {
it('should pass if visual tests initially fail but pass on retry with diff-id input', async () => {
getInputMock.mockImplementation(name => diffIdInputMap[name]);
execMock.mockResolvedValue(0);
globSyncMock.mockReturnValue(['path/to/screenshots/diff.png']);
globMock.mockResolvedValue(['path/to/screenshots/diff.png']);
await runAction();
expect(setFailedMock).not.toHaveBeenCalled();
expect(unlinkSyncMock).toHaveBeenCalledWith('path/to/screenshots/diff.png');
Expand All @@ -376,7 +378,7 @@ describe('main', () => {

it('should pass and upload base images if visual tests pass and only new images were created', async () => {
execMock.mockResolvedValue(0);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/existingTest/base.png',
'path/to/screenshots/newTest1/new.png',
'path/to/screenshots/newTest2/new.png'
Expand All @@ -401,7 +403,7 @@ describe('main', () => {
it('should pass and upload base images if visual tests pass and only new images were created with diff-id input', async () => {
getInputMock.mockImplementation(name => diffIdInputMap[name]);
execMock.mockResolvedValue(0);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/existingTest/base.png',
'path/to/screenshots/newTest1/new.png',
'path/to/screenshots/newTest2/new.png'
Expand All @@ -422,7 +424,7 @@ describe('main', () => {
'package-paths': 'path/1,path/2'
};
getInputMock.mockImplementation(name => extendedInputMap[name]);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/base.png',
'path/to/screenshots/diff.png',
'path/to/screenshots/new.png'
Expand All @@ -439,7 +441,7 @@ describe('main', () => {
'package-paths': 'path/1,path/2'
};
getInputMock.mockImplementation(name => extendedInputMap[name]);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/base.png',
'path/to/screenshots/diff.png',
'path/to/screenshots/new.png'
Expand All @@ -455,7 +457,7 @@ describe('main', () => {
execMock.mockResolvedValue(0);
getInputMock.mockImplementation(name => inputMap[name]);
getBooleanInputMock.mockImplementation(() => downloadBaseImages);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/base.png',
'path/to/screenshots/diff.png',
'path/to/screenshots/new.png'
Expand All @@ -469,7 +471,7 @@ describe('main', () => {
execMock.mockResolvedValue(0);
getInputMock.mockImplementation(name => inputMap[name]);
getBooleanInputMock.mockImplementation(() => downloadBaseImages);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/base.png',
'path/to/screenshots/diff.png',
'path/to/screenshots/new.png'
Expand All @@ -496,7 +498,7 @@ describe('main', () => {
'package-paths': 'path/1,path/2'
};
getInputMock.mockImplementation(name => extendedInputMap[name]);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/base.png',
'path/to/screenshots/diff.png',
'path/to/screenshots/new.png'
Expand All @@ -508,7 +510,7 @@ describe('main', () => {

it('should not set successful commit status or create comment if the latest Visual Regression status is failure', async () => {
execMock.mockResolvedValue(0);
globSyncMock.mockReturnValue(['path/to/screenshots/base.png']);
globMock.mockResolvedValue(['path/to/screenshots/base.png']);
listCommitStatusesForRefMock.mockImplementationOnce(() => ({
data: [
{
Expand Down Expand Up @@ -536,7 +538,7 @@ describe('main', () => {

it('should not set successful commit status if the latest Visual Regression status has been set', async () => {
execMock.mockResolvedValue(0);
globSyncMock.mockReturnValue(['path/to/screenshots/base.png']);
globMock.mockResolvedValue(['path/to/screenshots/base.png']);
listCommitStatusesForRefMock.mockImplementationOnce(() => ({
data: [
{
Expand All @@ -562,7 +564,7 @@ describe('main', () => {

it('should not set commit status or create comment if the latest Visual Regression status is failure because tests failed to execute successfully', async () => {
execMock.mockResolvedValue(1);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/base.png',
'path/to/screenshots/diff.png',
'path/to/screenshots/new.png'
Expand Down Expand Up @@ -596,7 +598,7 @@ describe('main', () => {
it('should set successful commit status (and disable auto merge) if a visual test failed to execute but this is a re-run', async () => {
githubContext.runAttempt = 2;
execMock.mockResolvedValue(0);
globSyncMock.mockReturnValue(['path/to/screenshots/base.png']);
globMock.mockResolvedValue(['path/to/screenshots/base.png']);
listCommitStatusesForRefMock.mockImplementationOnce(() => ({
data: [
{
Expand Down Expand Up @@ -625,7 +627,7 @@ describe('main', () => {
it('should set failure commit status (and not disable auto merge) if a visual test failed to execute but this is a re-run', async () => {
githubContext.runAttempt = 2;
execMock.mockResolvedValue(1);
globSyncMock.mockReturnValue([
globMock.mockResolvedValue([
'path/to/screenshots/base.png',
'path/to/screenshots/diff.png',
'path/to/screenshots/new.png'
Expand Down
Loading