Skip to content

Commit

Permalink
Merge pull request #16 from julien-capellari/feature/limit-files
Browse files Browse the repository at this point in the history
Limit files by pattern
  • Loading branch information
julien-capellari committed Mar 18, 2021
2 parents 8a4962a + a59009b commit 72bf878
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ jobs:
base: master
affected: true

- branch: test/test-a-affected
workspace: test-a
base: master
pattern: '*.ts'
affected: false

- branch: test/test-a-affected
workspace: test-b
base: master
Expand Down Expand Up @@ -117,6 +123,7 @@ jobs:
project-root: test-repo
workspace: ${{ matrix.workspace }}
base: ${{ matrix.base }}
pattern: ${{ matrix.pattern }}

- name: Should be affected
if: ${{ matrix.affected && !steps.affected.outputs.affected }}
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ inputs:
description: 'Base to compute diff'
required: true

pattern:
description: 'Files to search in the diff'
required: false
default: '**'

outputs:
affected:
description: 'true if workspace is affected'
Expand Down
2 changes: 1 addition & 1 deletion dist/bundle.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/glob": "^0.1.1",
"minimatch": "^3.0.4",
"simple-git": "^2.37.0"
},
"devDependencies": {
"@types/jest": "^26.0.21",
"@types/minimatch": "^3.0.3",
"@types/node": "^12.20.6",
"jest": "^26.6.3",
"ts-jest": "^26.5.4",
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as core from '@actions/core';
import minimatch from 'minimatch';
import simpleGit from 'simple-git';

import { Project } from './project';
Expand All @@ -10,6 +11,7 @@ import { Project } from './project';
projectRoot: core.getInput('project-root') || '.',
workspace: core.getInput('workspace', { required: true }),
base: core.getInput('base', { required: true }),
pattern: core.getInput('pattern') || '**'
};

// Load project
Expand Down Expand Up @@ -53,7 +55,9 @@ import { Project } from './project';
});

// Test if affected
const affected = diff.split('\n').some(l => l !== '');
const affected = diff.split('\n')
.filter(file => file !== '')
.some(minimatch.filter(inputs.pattern));

if (affected) {
core.setOutput('affected', true);
Expand Down
2 changes: 1 addition & 1 deletion src/project.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@actions/core';
import * as glob from '@actions/glob';
import * as path from 'path';
import path from 'path';

import { Workspace } from './workspace';

Expand Down
2 changes: 1 addition & 1 deletion src/workspace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { promises as fs } from 'fs';
import * as path from 'path';
import path from 'path';

import { Package } from './package';

Expand Down
2 changes: 1 addition & 1 deletion tests/project.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from 'path';
import path from 'path';

import { Project } from '../src/project';

Expand Down
2 changes: 1 addition & 1 deletion tests/workspace.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from 'path';
import path from 'path';

import { Workspace } from '../src/workspace';

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
// "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,11 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==

"@types/minimatch@^3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==

"@types/node@*":
version "14.14.33"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.33.tgz#9e4f8c64345522e4e8ce77b334a8aaa64e2b6c78"
Expand Down

0 comments on commit 72bf878

Please sign in to comment.