Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
23 changes: 23 additions & 0 deletions .github/workflows/check-file-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Check File Differences"
on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
check-couplings:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
- run: npm run setup
- name: Run Danger
run: npx danger ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45 changes: 45 additions & 0 deletions dangerfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { danger } from 'danger';
import * as logger from '@markbind/core/src/utils/logger';

interface Couplings {
[key: string]: string[];
}

const couplings: Couplings = {
'packages/core/src/html/CustomListIconProcessor.ts': [
'docs/userGuide/syntax/lists.md',
'packages/cli/test/functional/test_site/testList.md',
'packages/cli/test/functional/test_site/expected/testList.html',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm tbh i feel like there isn't a need to add the .html and .page-vue-render.js files here. Because they will have to updated otherwise the tests will fail automatically.

'packages/cli/test/functional/test_site/expected/testList.page-vue-render.js',
],
'package.json': ['package-lock.json'],
'packages/core/template/project/developerGuide/Configuration.md': [
'packages/cli/test/functional/test_site_templates/test_project/'
+ 'expected/developerGuide/Configuration.html',
'packages/cli/test/functional/test_site_templates/test_project/'
+ 'expected/developerGuide/Configuration.page-vue-render.js',
],
};

const { git } = danger;

Promise.resolve().then(() => {
const allModifiedFiles = [...git.modified_files, ...git.created_files];
const messages: string[] = [];

Object.entries(couplings).forEach(([implementationFile, dependentFiles]) => {
dependentFiles.forEach((dependentFile) => {
if (allModifiedFiles.includes(implementationFile) && !allModifiedFiles.includes(dependentFile)) {
messages.push(`Changes to ${implementationFile} should include changes to ${dependentFile}`);
}
});
});

if (messages.length > 0) {
logger.warn(`Detected issues with file couplings:\n${messages.join('\n')}`);
logger.warn('Please ensure implementation changes are accompanied '
+ 'by corresponding test or documentation updates.');
} else {
logger.info('All file couplings are correctly updated.');
}
}).catch((err: Error) => logger.error(err));
Loading