Skip to content
Merged
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
25 changes: 25 additions & 0 deletions frontend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,30 @@ tasks.register('lintFrontend', NpmTask) {
inputs.files fileTree(dir: '.', include: buildInputs, exclude: buildExclusions)
}

tasks.register('checkGeneratedFilesTracked', Exec) {
dependsOn 'buildFrontend'
group = 'check'
description = 'Verifies there are no untracked files in src/generated directory'
workingDir = rootProject.rootDir

standardOutput = System.out
errorOutput = System.err

commandLine 'bash', '-c', '''
changed=$(git diff --name-only -- frontend/src/generated/)
untracked=$(git ls-files --others --exclude-standard -- frontend/src/generated/)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Script will check for diff and untracked files, which is good. How will we handle cases where new generated files are added ?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the are part of a commit on the branch they will not fail in either of these checks. The nature of the problem is that there were api changes and they didn't got through code review but instead were automatically picked up during the auto-generation process.

if [ -n "$changed$untracked" ]; then
echo "Error: Unstaged or untracked files under frontend/src/generated/:"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we modify the error message to be something like "Please commit the following generated files:..."

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated response to include resolution message

> Task :frontend:checkGeneratedFilesTracked FAILED
Error: Unstaged or untracked files under frontend/src/generated/:
frontend/src/generated/api/types.gen.ts
Please run ./gradlew frontend:generateBackendClient and commit the updated files

[ -n "$changed" ] && echo "$changed"
[ -n "$untracked" ] && echo "$untracked"
echo "Please run ./gradlew frontend:generateBackendClient and commit the updated files"
exit 1
else
echo "OK: No unstaged or untracked files under frontend/src/generated/"
fi
'''
}

tasks.register('cleanFrontend', Delete) {
delete buildOutputs
}
Expand Down Expand Up @@ -104,4 +128,5 @@ The following is a list of npm commands to execute:

assemble.dependsOn 'buildFrontend'
check.dependsOn 'lintFrontend'
check.dependsOn 'checkGeneratedFilesTracked'
clean.dependsOn 'cleanFrontend'