-
Notifications
You must be signed in to change notification settings - Fork 40
Add a dedicated CI workflow for data loader CLI #2761
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
Conversation
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.
Pull Request Overview
This PR introduces a dedicated CI workflow to build the Data Loader CLI and fixes a unit test issue related to directory permissions. Key changes include:
- Adding a new workflow in .github/workflows/data-loader-ci.yaml to build the Data Loader CLI.
- Updating the unit test in DirectoryUtilsTest.java to handle non-writable directory scenarios with a fallback for non-POSIX systems.
- Modifying the Gradle build script to ensure the shadowJar task runs after distZip and distTar.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| data-loader/cli/src/test/java/com/scalar/db/dataloader/cli/util/DirectoryUtilsTest.java | Updated unit test to set directory permissions and skip reliably on systems that do not support POSIX. |
| data-loader/cli/build.gradle | Added a mustRunAfter dependency to enforce task ordering for shadowJar relative to distZip and distTar. |
| .github/workflows/data-loader-ci.yaml | New CI workflow file to build the Data Loader CLI. |
Comments suppressed due to low confidence (2)
data-loader/cli/src/test/java/com/scalar/db/dataloader/cli/util/DirectoryUtilsTest.java:64
- The fallback using toFile().setWritable(false) may not reliably enforce non-writability on all platforms, potentially leading to skipped tests. Consider documenting the known limitations for non-POSIX systems or exploring a more robust approach.
Assumptions.assumeFalse(isWritable, "Directory is still writable; skipping test.");
data-loader/cli/build.gradle:37
- Ensure that the tasks 'distZip' and 'distTar' are consistently defined in the build configuration, as the ordering dependency here relies on their existence and proper configuration.
mustRunAfter distZip, distTar
|
|
||
| // Build a fat jar | ||
| shadowJar { | ||
| mustRunAfter distZip, distTar |
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.
Is added via other PR so can be ignored here.
| - name: Cleanup Gradle cache | ||
| run: | | ||
| rm -f ~/.gradle/caches/modules-2/modules-2.lock | ||
| rm -f ~/.gradle/caches/modules-2/gc.properties No newline at end of file |
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.
Can you add a newline?
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.
Added
| steps: | ||
| - uses: actions/checkout@v2 | ||
|
|
||
| - name: Set version |
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.
I might be missing something, but why is this needed?
Also, there are some differences between the original ci.yaml's check job and this new workflow. Can you update this workflow based on the original ci.yaml? I guess it might fix the weird write permission issue.
| 11 | ||
| 8 |
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.
Why is it necessary to set up both Java 8 and 11 ?
| - name: Cache Gradle packages | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.gradle/caches | ||
| ~/.gradle/wrapper | ||
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-gradle- |
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.
I may miss something, but if you don't require a custom caching logic, using the setup-gradle action is usually preferred for a grade build compared to using the action/cache action.
| - name: Cache Gradle packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 |
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.
Updated
| - name: Cleanup Gradle cache | ||
| run: | | ||
| rm -f ~/.gradle/caches/modules-2/modules-2.lock | ||
| rm -f ~/.gradle/caches/modules-2/gc.properties No newline at end of file |
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.
If you follow my suggestion of using gradle/actions/setup-gradle@v4, this is not necessary.
| - name: Cleanup Gradle cache | |
| run: | | |
| rm -f ~/.gradle/caches/modules-2/modules-2.lock | |
| rm -f ~/.gradle/caches/modules-2/gc.properties |
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.
Updated
Co-authored-by: Mitsunori Komatsu <[email protected]>
Torch3333
left a comment
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.
LGTM, thank you!
brfrn169
left a comment
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.
LGTM! Thank you!
| Path readOnlyDirectory = Files.createDirectory(Paths.get(tempDir.toString(), "readOnlyDir")); | ||
| readOnlyDirectory.toFile().setWritable(false); | ||
|
|
||
| // Try to make it read-only using POSIX if supported |
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.
Seems like the cause of the test failure is still unclear, so I think we shouldn't merge this kind of ad-hoc workaround.
I ran ./gradlew :data-loader:cli:build --no-daemon --stacktrace without this workaround with the latest data-loader-ci.yaml, but it didn't fail
https://github.com/scalar-labs/scalardb/actions/runs/15702570827/job/44240661813. I guess the updated workflow file may have resolved the issue. Can you try without this workaround again just in case?
Even if it still fails, the unit tests should be already executed in ci.yaml's check job, so I think we can skip the unit tests in data-loader-ci.yaml by using ./gradlew -x test like ./gradlew -x test :data-loader:cli:build.
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.
@inv-jishnu (If you missed this)
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.
@komamitsu san (cc @ypeckstadt ),
Sorry I missed this. You are right about the tests already executing in check job. And as I mentioned, since the test failure only occurs on my local environment with act, it might be some issue with my environment and we can ignore that.
Thank you for pointing this out.
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.
The change above was reverted by @ypeckstadt san in this commit 6def419.
|
@inv-jishnu I have restored the changes to the test file and please test again if you can run the action without any problems without any additional fixes this time. If so, we can just treat this PR as the title suggests. |
I have tested with act in local (there was issues in using v4 with act, so I had to change it to v3) and the CI failed with reverted test changes with the same issue as before. When I updated the test, with the fix and re ran it, the CI workflow was completed successfully. So we need to add the fix for unit test. |
@inv-jishnu It looks like the CI finished successfully |
@komamitsu san, I tested the workflow in my local environment with act. There may be some issue with act or with some configuration set in my local environment. The issue I faced can be ignored as it is working as expected in the actual workflow run. I have added a snippet from log for reference. |
komamitsu
left a comment
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.
LGTM! 👍
feeblefakie
left a comment
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.
LGTM! Thank you!
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.
LGTM. Thank you.
Co-authored-by: Peckstadt Yves <[email protected]>
Description
This PR adds a dedicated CI workflow just for the data loader CLI. The main CI.yaml file only runs
checkand for the data loader CLI build errors made it's way into the master branch. To avoid this, we like to run the build command for the data loader in the CI as well.After adding and testing this workflow, it was also apparent that one of the unit tests was failing when running in certain environments. (only failing when running in the workflows) A test for a read only folder that failed with it's directory permissions. This PR also fixes this unit test to make sure the build is ok.
Based on PR comment.
Related issues and/or PRs
Please review and merge this PR after the following PR is merged.
Changes made
I have tested the CI with act in my local machine and confirmed the CI is working.
Checklist
Additional notes (optional)
Release notes
Add a CI workflow for data loader CLI build