-
Notifications
You must be signed in to change notification settings - Fork 138
Using DangerJS to check changes coupling of implementation files to test or documentation files #2523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Using DangerJS to check changes coupling of implementation files to test or documentation files #2523
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
720aa39
Add files
KevinEyo1 aff8a1d
Add workflow and dangerfile
KevinEyo1 552c4b0
Update couplings
KevinEyo1 bf88848
Fix lint
KevinEyo1 43a9479
Change to warn
KevinEyo1 f303416
Update coupling
KevinEyo1 26aa011
Remove coupling
KevinEyo1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
'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', | ||
], | ||
}; | ||
yucheng11122017 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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)); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.