Skip to content
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

no such file or directory errors fix #58

Merged
merged 11 commits into from
Jul 13, 2024

Conversation

Manik2708
Copy link
Contributor

Fixes: #8

  1. Now if go.mod and other languages entry file are not added to version control, error will be thrown
  2. Warning is also appended with the custom message.

This PR also focuses on one of the problem which I faced during contribution. I was not able to use debugger to test my changes. Rebuilding again and again can be tedious, so I tried to write test for git.go. This test is not a Unit Test as those includes mocking. Mocking git is complex and may include DI, so I approached it by another way. This test create a bsf-temp directory outside the project folder and delete it after the test is completed. I have to create it outside the project directory because the git tree of project should not be hampered. Now testing the git pkg is very simple. But this has some problems:

  1. bsf-temp could contain personal data of developer and tests include deleting this folder, so it may lead developer loosing data. But this can be fixed by creating random name folders for testing or asking the name of temp folder from developer during setup.
  2. Tests can be slow, on my machine 11 tests are taking 0.002 seconds.

If my approach is right, then I can work on testing build and init command as these commands are very much prone to changes.

And if there is some problem I can remove git_test.go from this PR

@dr-housemd
Copy link
Contributor

Hey @Manik2708 , thanks for contributing! Can you please follow this and make a dedicated commit for adding yourself to CONTRIBUTORS.md?
https://github.com/buildsafedev/bsf?tab=readme-ov-file#contributing

Signed-off-by: Manik2708 <Manik2708>
Signed-off-by: Manik2708 <[email protected]>
Signed-off-by: Manik2708 <Manik2708>
Signed-off-by: Manik2708 <[email protected]>
@Manik2708
Copy link
Contributor Author

@dr-housemd DCO is fixed, please run the workflow

@Manik2708
Copy link
Contributor Author

@dr-housemd @rakshitgondwal Please review this PR

pkg/nix/cmd/build.go Outdated Show resolved Hide resolved
pkg/nix/cmd/build.go Outdated Show resolved Hide resolved
pkg/nix/cmd/build.go Outdated Show resolved Hide resolved
pkg/git/git.go Outdated Show resolved Hide resolved
pkg/git/git.go Outdated Show resolved Hide resolved
pkg/git/git.go Outdated Show resolved Hide resolved
pkg/nix/cmd/build.go Outdated Show resolved Hide resolved
pkg/nix/cmd/build.go Outdated Show resolved Hide resolved
Signed-off-by: Manik2708 <[email protected]>
dr-housemd
dr-housemd previously approved these changes Jul 12, 2024
@dr-housemd
Copy link
Contributor

@Manik2708 thanks for the PR, this is a great contribution. Especially, impressed with the test coverage.
If you can resolve the errors issue, I'll merge this

Signed-off-by: Manik2708 <[email protected]>
@dr-housemd
Copy link
Contributor

@Manik2708 CI is failing. Can you-

  • Run "go mod tidy"
  • Run "go run main.go build"
  • Commit the files and push.

@Manik2708
Copy link
Contributor Author

I am little confused regarding the build in CI. It is using the build command of bsf itself to build the project, but the recent changes will throw the error if go.mod are not added to git before building!

Signed-off-by: Manik2708 <[email protected]>
@Manik2708
Copy link
Contributor Author

Manik2708 commented Jul 13, 2024

I finally got to know why this error was coming, go-git return file as UNTRACKED if it is committed. I have raised an issue in go-git but for now we will assume that if status map doesn't have a file then it is committed! As we are checking the language through langdetect, if it returns other than unknown, it will mean files are present, and if those files are absent in status map, means they are committed! Although I think go-git should track committed files also!

@Manik2708
Copy link
Contributor Author

Finally CI passed:)

@dr-housemd dr-housemd merged commit ddda3f9 into buildsafedev:main Jul 13, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no such file or directory errors
2 participants