File tree Expand file tree Collapse file tree 4 files changed +1685
-154
lines changed Expand file tree Collapse file tree 4 files changed +1685
-154
lines changed Original file line number Diff line number Diff line change
1
+ name : " Check File Differences"
2
+ on :
3
+ pull_request :
4
+
5
+ concurrency :
6
+ group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
7
+ cancel-in-progress : true
8
+
9
+ jobs :
10
+ check-couplings :
11
+ runs-on : ubuntu-latest
12
+ permissions :
13
+ contents : read
14
+ steps :
15
+ - uses : actions/checkout@v3
16
+ - uses : actions/setup-node@v3
17
+ with :
18
+ node-version : ' 16'
19
+ - run : npm run setup
20
+ - name : Run Danger
21
+ run : npx danger ci
22
+ env :
23
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
1
+ import { danger } from 'danger' ;
2
+ import * as logger from '@markbind/core/src/utils/logger' ;
3
+
4
+ interface Couplings {
5
+ [ key : string ] : string [ ] ;
6
+ }
7
+
8
+ const couplings : Couplings = {
9
+ 'packages/core/src/html/CustomListIconProcessor.ts' : [
10
+ 'docs/userGuide/syntax/lists.md' ,
11
+ 'packages/cli/test/functional/test_site/testList.md' ,
12
+ ] ,
13
+ 'package.json' : [ 'package-lock.json' ] ,
14
+ } ;
15
+
16
+ const { git } = danger ;
17
+
18
+ Promise . resolve ( ) . then ( ( ) => {
19
+ const allModifiedFiles = [ ...git . modified_files , ...git . created_files ] ;
20
+ const messages : string [ ] = [ ] ;
21
+
22
+ Object . entries ( couplings ) . forEach ( ( [ implementationFile , dependentFiles ] ) => {
23
+ dependentFiles . forEach ( ( dependentFile ) => {
24
+ if ( allModifiedFiles . includes ( implementationFile ) && ! allModifiedFiles . includes ( dependentFile ) ) {
25
+ messages . push ( `Changes to ${ implementationFile } should include changes to ${ dependentFile } ` ) ;
26
+ }
27
+ } ) ;
28
+ } ) ;
29
+
30
+ if ( messages . length > 0 ) {
31
+ logger . warn ( `Detected issues with file couplings:\n${ messages . join ( '\n' ) } ` ) ;
32
+ logger . warn ( 'Please ensure implementation changes are accompanied '
33
+ + 'by corresponding test or documentation updates.' ) ;
34
+ } else {
35
+ logger . info ( 'All file couplings are correctly updated.' ) ;
36
+ }
37
+ } ) . catch ( ( err : Error ) => logger . error ( err ) ) ;
You can’t perform that action at this time.
0 commit comments