You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Minor changes can be done directly by editing code on GitHub. GitHub automatically creates a temporary branch and
2
+
3
+
- Minor changes can be done directly by editing code on GitHub. GitHub automatically creates a temporary branch and
3
4
files a PR. This is only suitable for really small changes like: spelling fixes, variable name changes or error string
4
5
change etc. For larger commits, following steps are recommended.
5
-
* (Optional) If you want to discuss your implementation with the users of GoFr, use the GitHub discussions of this repo.
6
-
* Configure your editor to use goimport and golangci-lint on file changes. Any code which is not formatted using these
6
+
- (Optional) If you want to discuss your implementation with the users of GoFr, use the GitHub discussions of this repo.
7
+
- Configure your editor to use goimport and golangci-lint on file changes. Any code which is not formatted using these
7
8
tools, will fail on the pipeline.
8
-
* Contributors should begin working on an issue only after it has been assigned to them. To get an issue assigned, please comment on the GitHub thread
9
+
- Contributors should begin working on an issue only after it has been assigned to them. To get an issue assigned, please comment on the GitHub thread
9
10
and request assignment from a maintainer. This helps avoid duplicate or conflicting pull requests from multiple contributors.
10
-
* Issues labeled triage are not open for direct contributions. If you're interested in working on a triage issue, please reach out to the maintainers
11
-
to discuss it before proceeding in the Github thread.
11
+
- Issues labeled triage are not open for direct contributions. If you're interested in working on a triage issue, please reach out to the maintainers
12
+
to discuss it before proceeding in the Github thread.
12
13
<!-- spellchecker:off "favour" have to be ignored here -->
13
-
* We follow **American English** conventions in this project (e.g., *"favor"* instead of *"favour"*). Please keep this consistent across all code comments, documentation, etc.
14
+
- We follow **American English** conventions in this project (e.g., _"favor"_ instead of _"favour"_). Please keep this consistent across all code comments, documentation, etc.
14
15
<!-- spellchecker:on -->
15
-
* All code contributions should have associated tests and all new line additions should be covered in those testcases.
16
+
- All code contributions should have associated tests and all new line additions should be covered in those testcases.
16
17
No PR should ever decrease the overall code coverage.
17
-
* Once your code changes are done along with the testcases, submit a PR to development branch. Please note that all PRs
18
+
- Once your code changes are done along with the testcases, submit a PR to development branch. Please note that all PRs
18
19
are merged from feature branches to development first.
20
+
19
21
* PR should be raised only when development is complete and the code is ready for review. This approach helps reduce the number of open pull requests and facilitates a more efficient review process for the team.
20
22
* All PRs need to be reviewed by at least 2 GoFr developers. They might reach out to you for any clarification.
21
23
* Thank you for your contribution. :)
@@ -28,32 +30,28 @@ Testing is a crucial aspect of software development, and adherence to these guid
28
30
29
31
1.**Test Types:**
30
32
31
-
- Write unit tests for every new function or method.
32
-
- Include integration tests for any major feature added.
33
-
34
-
35
-
2.**Test Coverage:**
36
-
37
-
- No new code should decrease the existing code coverage for the packages and files.
38
-
> The `code-climate` coverage check will not pass if there is any decrease in the test-coverage before and after any new PR is submitted.
33
+
- Write unit tests for every new function or method.
34
+
- Include integration tests for any major feature added.
39
35
36
+
2.**Test Coverage:**
40
37
38
+
- No new code should decrease the existing code coverage for the packages and files.
39
+
> The `code-climate` coverage check will not pass if there is any decrease in the test-coverage before and after any new PR is submitted.
41
40
42
41
3.**Naming Conventions:**
43
42
44
-
- Prefix unit test functions with `Test`.
45
-
- Use clear and descriptive names.
43
+
- Prefix unit test functions with `Test`.
44
+
- Use clear and descriptive names.
45
+
46
46
```go
47
47
funcTestFunctionName(t *testing.T) {
48
48
// Test logic
49
49
}
50
50
```
51
51
52
-
53
-
54
52
4.**Table-Driven Tests:**
55
53
56
-
-Consider using table-driven tests for testing multiple scenarios.
54
+
- Consider using table-driven tests for testing multiple scenarios.
57
55
58
56
> [!NOTE]
59
57
> Some services will be required to pass the entire test suite. We recommend using docker for running those services.
@@ -96,46 +94,48 @@ docker run -d --name arangodb \
96
94
-e ARANGO_ROOT_PASSWORD=rootpassword \
97
95
--pull always \
98
96
arangodb:latest
97
+
docker run -it --rm -p 4443:4443 -e STORAGE_EMULATOR_HOST=0.0.0.0:4443 fsouza/fake-gcs-server:latest
99
98
```
100
99
101
100
> [!NOTE]
102
101
> Please note that the recommended local port for the services are different from the actual ports. This is done to avoid conflict with the local installation on developer machines. This method also allows a developer to work on multiple projects which uses the same services but bound on different ports. One can choose to change the port for these services. Just remember to add the same in configs/.local.env, if you decide to do that.
103
102
104
-
105
103
### Coding Guidelines
106
-
* Use only what is given to you as part of function parameter or receiver. No globals. Inject all dependencies including
104
+
105
+
- Use only what is given to you as part of function parameter or receiver. No globals. Inject all dependencies including
107
106
DB, Logger etc.
108
-
* No magic. So, no init. In a large project, it becomes difficult to track which package is doing what at the
107
+
- No magic. So, no init. In a large project, it becomes difficult to track which package is doing what at the
109
108
initialization step.
110
-
* Exported functions must have an associated godoc.
111
-
* Sensitive data(username, password, keys) should not be pushed. Always use environment variables.
112
-
* Take interfaces and return concrete types.
113
-
- Lean interfaces - take 'exactly' what you need, not more. Onus of interface definition is on the package who is
114
-
using it. so, it should be as lean as possible. This makes it easier to test.
115
-
- Be careful of type assertions in this context. If you take an interface and type assert to a type - then it's
116
-
similar to taking concrete type.
117
-
* Uses of context:
118
-
- We should use context as a first parameter.
119
-
- Can not use string as a key for the context. Define your own type and provide context accessor method to avoid
120
-
conflict.
121
-
* External Library uses:
122
-
- A little copying is better than a little dependency.
123
-
- All external dependencies should go through the same careful consideration, we would have done to our own written
124
-
code. We need to test the functionality we are going to use from an external library, as sometimes library
125
-
implementation may change.
126
-
- All dependencies must be abstracted as an interface. This will make it easier to switch libraries at later point
127
-
of time.
128
-
* Version tagging as per Semantic versioning (https://semver.org/)
109
+
- Exported functions must have an associated godoc.
110
+
- Sensitive data(username, password, keys) should not be pushed. Always use environment variables.
111
+
- Take interfaces and return concrete types.
112
+
- Lean interfaces - take 'exactly' what you need, not more. Onus of interface definition is on the package who is
113
+
using it. so, it should be as lean as possible. This makes it easier to test.
114
+
- Be careful of type assertions in this context. If you take an interface and type assert to a type - then it's
115
+
similar to taking concrete type.
116
+
- Uses of context:
117
+
- We should use context as a first parameter.
118
+
- Can not use string as a key for the context. Define your own type and provide context accessor method to avoid
119
+
conflict.
120
+
- External Library uses:
121
+
- A little copying is better than a little dependency.
122
+
- All external dependencies should go through the same careful consideration, we would have done to our own written
123
+
code. We need to test the functionality we are going to use from an external library, as sometimes library
124
+
implementation may change.
125
+
- All dependencies must be abstracted as an interface. This will make it easier to switch libraries at later point
126
+
of time.
127
+
- Version tagging as per Semantic versioning (https://semver.org/)
129
128
130
129
### Documentation
131
-
* After adding or modifying existing code, update the documentation too - [development/docs](https://github.com/gofr-dev/gofr/tree/development/docs).
132
-
* When you consider a new documentation page is needed, start by adding a new file and writing your new documentation. Then - add a reference to it in [navigation.js](https://gofr.dev/docs/navigation.js).
133
-
* If needed, update or add proper code examples for your changes.
134
-
* In case images are needed, add it to [docs/public](./docs/public) folder.
135
-
* Make sure you don't break existing links and references.
136
-
* Maintain Markdown standards, you can read more [here](https://www.markdownguide.org/basic-syntax/), this includes:
137
-
- Headings (`#`, `##`, etc.) should be placed in order.
138
-
- Use trailing white space or the <br> HTML tag at the end of the line.
139
-
- Use "`" sign to add single line code and "```" to add multi-line code block.
140
-
- Use relative references to images (in `public` folder as mentioned above.)
141
-
* The [gofr.dev documentation](https://gofr.dev/docs) site is updated upon push to `/docs` path in the repo. Verify your changes are live after next GoFr version.
130
+
131
+
- After adding or modifying existing code, update the documentation too - [development/docs](https://github.com/gofr-dev/gofr/tree/development/docs).
132
+
- When you consider a new documentation page is needed, start by adding a new file and writing your new documentation. Then - add a reference to it in [navigation.js](https://gofr.dev/docs/navigation.js).
133
+
- If needed, update or add proper code examples for your changes.
134
+
- In case images are needed, add it to [docs/public](./docs/public) folder.
135
+
- Make sure you don't break existing links and references.
136
+
- Maintain Markdown standards, you can read more [here](https://www.markdownguide.org/basic-syntax/), this includes:
137
+
- Headings (`#`, `##`, etc.) should be placed in order.
138
+
- Use trailing white space or the <br> HTML tag at the end of the line.
139
+
- Use "`" sign to add single line code and "```" to add multi-line code block.
140
+
- Use relative references to images (in `public` folder as mentioned above.)
141
+
- The [gofr.dev documentation](https://gofr.dev/docs) site is updated upon push to `/docs` path in the repo. Verify your changes are live after next GoFr version.
0 commit comments