Skip to content

Commit 75e1b73

Browse files
authored
docs: adjust README.md and CONTRIBUTING.md (#279)
Signed-off-by: behnazh-w <behnaz.hassanshahi@oracle.com>
1 parent aedbc85 commit 75e1b73

File tree

3 files changed

+131
-222
lines changed

3 files changed

+131
-222
lines changed

CONTRIBUTING.md

Lines changed: 124 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing to Macaron
22

3-
Oracle welcomes contributions to this repository from anyone.
3+
We welcome contributions to this repository from anyone.
44

55
If you want to submit a pull request to fix a bug or enhance an existing feature, please first open an issue and link to that issue when you submit your pull request.
66

@@ -25,8 +25,8 @@ or `-s`, e.g.
2525
git commit --signoff
2626
```
2727

28-
Only pull requests from committers that can be verified as having signed the OCA
29-
can be accepted.
28+
Finally, make sure to sign your commits using a GPG key. See the instructions [here](https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key) for more information. A green `verified` label will appear next to your commit on GitHub if it is successfully signed.
29+
3030

3131
### Pull request process
3232

@@ -58,19 +58,136 @@ can be accepted.
5858

5959
- Each new feature or change PR should provide meaningful CI tests.
6060
- All the tests and security scanning checks in CI should pass and achieve the expected coverage.
61+
- To avoid unnecessary failures in GitHub Actions, make sure `make check` and `make test` work locally.
62+
See below for instructions to set up the development environment.
6163

6264
### Merging PRs
6365

64-
- Before a PR is merged, all commits in the PR should be rebased into meaningful commits.
66+
- Before a PR is merged, all commits in the PR should be meaningful.
6567
- Its commit message should be the same as the PR title if there only one commit.
66-
- PRs should be merged using the fast-forward only strategy.
67-
- This ensures a linear commit history for the project.
68-
- If the fast-forward merge does not work due to new commits on `main` (in this case the two branches diverge and the PR branch cannot be fast-forwarded), the PR branch should be rebased onto `main` first.
68+
- PRs should be merged using the `Squash and merge` strategy. In most cases a single commit with
69+
a detailed commit message body is preferred. Make sure to keep the `Signed-off-by` line in the body.
6970

7071
## Branching model
7172

7273
* The `main` branch is only used for releases and the `staging` branch is used for development. We only merge to `main` when we want to create a new release for Macaron.
7374

75+
## Setting up the development environment
76+
77+
### Prerequisites
78+
79+
- Python 3.11
80+
- Go 1.18
81+
- JDK 17
82+
83+
### Prepare the environment
84+
85+
To contribute to Macaron, clone the project and create a [virtual environment](https://docs.python.org/3/tutorial/venv.html) by using the [Makefile](https://www.gnu.org/software/make/manual/make.html#toc-An-Introduction-to-Makefiles):
86+
87+
```bash
88+
make venv # Create a new virtual environment in .venv folder using Python 3.11.
89+
```
90+
91+
or for a specific version of Python:
92+
93+
```bash
94+
PYTHON=python3.11 make venv # Same virtual environment for a different Python version.
95+
```
96+
97+
Activate the virtual environment:
98+
99+
```bash
100+
. .venv/bin/activate
101+
```
102+
103+
Finally, set up Macaron with all of its extras and initialize the local git hooks:
104+
105+
```bash
106+
make setup
107+
```
108+
109+
**Note**: Running the above command will prompt you for sudo access to install [Soufflé Datalog engine](https://github.com/souffle-lang/souffle). You can install Soufflé on your system before running `make setup` to avoid getting prompted.
110+
111+
With that in place, you’re ready to build and contribute to Macaron!
112+
113+
### Updating dependent packages
114+
115+
It’s likely that during development you’ll add or update dependent packages in the `pyproject.toml` or `go.mod` files, which requires an update to the environment:
116+
117+
```bash
118+
make upgrade
119+
```
120+
121+
### Running Macaron as a Python package
122+
123+
```bash
124+
usage: macaron [-h]
125+
```
126+
127+
### Obtaining the GitHub personal access token
128+
129+
To obtain a GitHub access token, please see the official instructions [here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token).
130+
131+
Ideally, the GitHub token must have **read** permissions for the repositories that you want to analyze:
132+
133+
- Every [fine-grained personal-access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-fine-grained-personal-access-token) should have read permission to public GitHub repositories. However, if you are analyzing a private repository, please select it in the ``Repository Access section``.
134+
- For [classic personal-access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic), the ``repo.public_repo`` scope must be selected. Please select the whole ``repo`` scope if you are running the analysis against private repositories.
135+
136+
After generating a GitHub personal-access token, please store its value in an environment variable called ``GITHUB_TOKEN``. This environment variable will be read by Macaron for its **analyze** command.
137+
138+
### Running checks and tests locally
139+
140+
#### Git hooks
141+
142+
Using the pre-commit tool and its `.pre-commit-config.yaml` configuration, a number of [pre-commit hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_committing_workflow_hooks) ensure that your code is formatted correctly.
143+
144+
You can also run these hooks manually, which comes in very handy during daily development tasks. For example
145+
146+
```bash
147+
make check-code
148+
```
149+
150+
runs all the code checks (i.e. `bandit`, `flake8`, `pylint`, `mypy`, `actionlint`), whereas
151+
152+
```bash
153+
make check
154+
```
155+
156+
runs _all_ installed git hooks over your code. For more control over the code checks, the Makefile also implements the `check-bandit`, `check-flake8`, `check-lint`, `check-mypy`, and `check-actionlint` goals.
157+
158+
159+
#### Testing
160+
161+
This repository is set up to test either standalone or as a pre-push git hook. Tests are stored in the `tests/` folder, and you can run them manually like so:
162+
```bash
163+
make test
164+
```
165+
which runs all unit tests in both your local environment. Test code and branch coverage is already tracked using [coverage](https://github.com/nedbat/coveragepy) and the [pytest-cov](https://github.com/pytest-dev/pytest-cov) plugin for pytest, and it measures how much code in the `src/package/` folder is covered by tests.
166+
167+
You can also run integration tests locally:
168+
```bash
169+
make integration-test
170+
```
171+
172+
Note that integration tests can take a long time to complete. Also the repositories that we clone for these tests will be stored under `output/` directory. If you do not remove/move this directory and run the pre-commit tool you might get errors.
173+
174+
175+
#### Generating documentation
176+
177+
As mentioned above, all package code should make use of [Python docstrings](https://www.python.org/dev/peps/pep-0257/) in [reStructured text format](https://www.python.org/dev/peps/pep-0287/). Using these docstrings and the documentation template in the `docs/source/` folder, you can then generate proper documentation in different formats using the [Sphinx](https://github.com/sphinx-doc/sphinx/) tool:
178+
179+
```bash
180+
make docs
181+
```
182+
183+
This example generates documentation in HTML, which can then be found here:
184+
185+
```bash
186+
open docs/_build/html/index.html
187+
```
188+
189+
For more information see the instructions [here](docs/README.md).
190+
74191
## Code of conduct
75192

76193
Follow the [Golden Rule](https://en.wikipedia.org/wiki/Golden_Rule). If you'd like more specific guidelines, see the [Contributor Covenant Code of Conduct][COC].

0 commit comments

Comments
 (0)