chore: apply spotless precommit (#35054)
## Description This change will remove applying spotless when compiling code and instead will apply spotless in the precommit hook. This will lead to faster build times and DX improvement as developer need not to manually run spotless anymore. Fixes https://github.com/appsmithorg/appsmith/issues/35056 ## Automation /test sanity ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10040567648> > Commit: 587204979ba0cb9991a599969351aa48e69900c5 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10040567648&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Mon, 22 Jul 2024 12:41:36 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **New Features** - Improved the formatting application process for server files, providing clearer feedback on success or failure. - **Bug Fixes** - Adjusted the build process to ensure a more streamlined execution of plugin goals. - **Chores** - Enhanced messaging and readability in scripts for better user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
ae9742194a
commit
d30191c287
|
|
@ -5,24 +5,33 @@ is_client_change=$(git diff --cached --name-only | grep -c "app/client")
|
|||
|
||||
is_merge_commit=$(git rev-parse -q --verify MERGE_HEAD)
|
||||
|
||||
# Function to apply Spotless and only commit staged files
|
||||
apply_spotless_and_commit_staged_files() {
|
||||
staged_server_files=$(git diff --cached --name-only | grep "app/server"| sed 's|app/server/||')
|
||||
mvn spotless:apply
|
||||
# Check if Spotless succeeded
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Spotless apply failed, Please run mvn spotless:apply"
|
||||
exit 1
|
||||
fi
|
||||
echo "$staged_server_files" | xargs git add
|
||||
echo "✔ Spotless applied successfully to server files"
|
||||
}
|
||||
|
||||
if [ "$is_merge_commit" ]; then
|
||||
echo "Skipping server and client checks for merge commit"
|
||||
else
|
||||
if [ "$is_server_change" -ge 1 ]; then
|
||||
echo "Running Spotless check ..."
|
||||
echo "Applying Spotless to server files..."
|
||||
pushd app/server > /dev/null
|
||||
if (mvn spotless:check 1> /dev/null && popd > /dev/null) then
|
||||
popd
|
||||
else
|
||||
echo "Spotless check failed, please run mvn spotless:apply"
|
||||
exit 1
|
||||
fi
|
||||
apply_spotless_and_commit_staged_files
|
||||
popd > /dev/null
|
||||
else
|
||||
echo "Skipping server side check..."
|
||||
echo "Skipping server side check..."
|
||||
fi
|
||||
|
||||
if [ "$is_client_change" -ge 1 ]; then
|
||||
echo "Running client check ..."
|
||||
if [ "$is_client_change" -ge 1 ]; then
|
||||
echo "Running client check..."
|
||||
npx lint-staged --cwd app/client
|
||||
else
|
||||
echo "Skipping client side check..."
|
||||
|
|
|
|||
|
|
@ -178,8 +178,6 @@
|
|||
<goals>
|
||||
<goal>apply</goal>
|
||||
</goals>
|
||||
<!-- This gets triggered automatically when we run the build script -->
|
||||
<phase>compile</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user