-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Home
This repository is contribution-friendly 😃. If you're an algorithms enthusiast and want to add or improve an algorithm your contribution is welcome! Please be sure to include tests 😘
Algorithms$ ./gradlew build
The procedure to add a new algorithm or snippet of code is:
- If there doesn't already exist an issue, then file a new issue explaining the algorithm/change you want to do.
- Make sure the algorithm doesn't already exist! We don't want duplicate algorithms 😬
- Identify the category folder your algorithm belongs to. For example, a matrix multiplication snippet would belong to the
src/main/java/com/williamfiset/algorithms/linearalgebra
folder. You may also create a new category folder if appropriate. - Add the algorithm implementation to:
src/main/java/com/williamfiset/algorithms/category/FooAlgorithm.java
- Add tests for FooAlgorithm in:
src/test/java/com/williamfiset/algorithms/category/FooAlgorithmTest.java
- Test your algorithm thoroughly (see testing section below)
- Run
./gradlew spotlessApply
to format all Java code according to Google Style Guide. - Send pull request for review 😮
This repository places a large emphasis on good testing practice to ensure that published algorithms are bug free and high quality. You will not be able to submit your pull request without providing tests to prove your algorithm's functionality. Testing is done using the Mockito and the Google Truth frameworks.
Algorithms$ ./gradlew --info test
However, when developing you likely do not want to run all tests but only a subset of them. For example, if you want to run the FloydWarshallSolverTest.java file under src/main/test/com/williamfiset/algorithms/graphtheory/FloydWarshallSolverTest.java you can execute:
Algorithms$ ./gradlew test --info --tests "com.williamfiset.algorithms.graphtheory.FloydWarshallSolverTest" --info
See more on gradle test filtering here
Look at the Actions tab on Github and look through the broken workflow(s) for why the build is red.
Common errors:
- The Java formatter was not run and there are formatting diffs. Run
./gradlew spotlessApply
to resolve fix up the Java files and re-commit. - Tests are broken. Run
./gradlew test
locally to identify the breaking test(s)