Skip to content

Commit a2875af

Browse files
committed
Simplify and update DEVELOP.md with latest changes in the repository.
1 parent d65fedc commit a2875af

File tree

1 file changed

+80
-75
lines changed

1 file changed

+80
-75
lines changed

DEVELOP.md

Lines changed: 80 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,130 @@
11
# Developer Guide for cratedb-sqlparse
22

3-
About building locally, or using a different CrateDB version.
3+
Libraries in this repository are not usable without building the necessary files with `setup_grammar.py`,
4+
this is because the generated parser is not uploaded to the repository. Every target language, e.g:
5+
Python or JavaScript, needs to be built independently.
46

5-
> The generated parser is not uploaded to the repository because it is huge.
6-
> To use the package locally or to build a different version use the build script.
7+
The build script should not have any side effect, meaning you should be able to re-build with
8+
a different CrateDB version without any extra work.
79

8-
## Setup
9-
10-
To start things off, bootstrap the sandbox environment.
10+
## Running the build script.
1111

1212
### Acquire sources
1313
```shell
1414
git clone [email protected]:crate/cratedb-sqlparse.git
1515
cd cratedb-sqlparse
1616
```
1717

18-
### Install dependencies
19-
```
20-
pip install -r requirements.txt
21-
```
18+
### Setup uv
19+
[uv](https://docs.astral.sh/uv/) is used across the project and is the recommended dependency tool, both for building the
20+
project's grammar and the development of the Python target.
2221

23-
### Generate grammar files
22+
macOS and Linux:
2423
```shell
25-
poe generate
24+
curl -LsSf https://astral.sh/uv/install.sh | sh
2625
```
2726

27+
Windows:
28+
```shell
29+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
30+
```
2831

29-
## Running Tests for Python
30-
31-
First, navigate to the corresponding subdirectory:
32-
33-
cd cratedb_sqlparse_py
34-
35-
Verify code by running all linters and software tests:
36-
37-
poe check
32+
If those options don't work, see https://docs.astral.sh/uv/getting-started/installation/
3833

39-
Run specific tests:
34+
### Install dependencies
35+
```shell
36+
pip install -r requirements.txt
37+
```
4038

41-
pytest -k enricher
42-
pytest -k lexer
39+
or uv
4340

44-
Format code:
41+
```shell
42+
uv pip install -r requirements.txt
43+
```
4544

46-
poe format
45+
### Generate grammar files
4746

47+
Python:
48+
```shell
49+
uv run python setup_grammar.py python
50+
```
4851

49-
## Running Tests for JavaScript
52+
Javascript:
53+
```shell
54+
uv run python setup_grammar.py javascript
55+
```
5056

51-
First, navigate to the corresponding subdirectory:
57+
Now libraries that were built are ready to use, every library e.g. `cratedb_sqlparse_js`
58+
are on themselves different projects, with their own dependencies and
59+
dependency management systems.
5260

53-
cd cratedb_sqlparse_js
61+
## Setting up cratedb_sqlparse_py
5462

55-
Set up project:
63+
In `./cratedb_sqlparse_py` run
5664

57-
npm install
5865

59-
Verify code by running all linters and software tests:
66+
### Set up dependencies
6067

61-
npm test
68+
```shell
69+
uv sync --all-groups
70+
```
6271

63-
Run specific tests:
72+
### Run tests
6473

65-
???
74+
```shell
75+
uv run pytest
76+
```
6677

67-
Format code:
78+
### Format code:
79+
```shell
80+
uv run poe format
81+
```
82+
83+
## Running Tests for JavaScript
84+
In `./cratedb_sqlparse_js` run:
6885

69-
???
86+
## Setup dependencies
87+
```shell
88+
npm install
89+
```
7090

91+
## Run tests
92+
```shell
93+
npm test
94+
```
7195

96+
## Releasing libraries.
97+
Releases are done on GitHub, by creating a [new release](https://github.com/crate/cratedb-sqlparse/releases)
98+
every library will be built and published.
7299

73-
## Running a Release
100+
1. Make sure that in `setup_grammar.py` the CrateDB version matches the one you want.
101+
2. On GitHub create a new release, creating the appropriate tag and adapting the changelog.
74102

75103
### Python
104+
Releases to https://pypi.org/project/cratedb-sqlparse/
76105

77106
Overview:
78107
- Versioning happens automatically based on the `versioningit` package.
79-
You just need to tag the repository.
80-
- Package building and publishing happens automatically, being staged
81-
through GHA to PyPI.
82-
83-
On branch `main`:
84-
- Add a section for the new version in the `CHANGES.md` file.
85-
- Commit your changes with a message like `Release vx.y.z`.
86-
- Create a tag, and push to remote.
87-
This will trigger a GitHub action which releases the new version to PyPI.
88-
```shell
89-
git tag v0.0.3
90-
git push --tags
91-
```
92-
- On GitHub, designate a new release, copying in the relevant section
93-
from the CHANGELOG.
94-
https://github.com/crate/cratedb-sqlparse/releases
95108

109+
#### Manual release.
96110
Optionally, build the package and upload to PyPI manually.
97111
```shell
98-
poe release
112+
uv run poe release
99113
```
100114

101-
102115
### JavaScript
116+
Releases to https://www.npmjs.com/package/@cratedb/cratedb-sqlparse
103117

104118
Overview:
105-
- Versioning happens manually on behalf of the `package.json` file.
106-
- Package building and publishing to npmjs.com happens manually, using
107-
the `npm` program.
108-
109-
On branch `main`:
110-
- Make sure to run `poe generate` on the root folder first.
111-
- Adjust version number in `package.json`.
112-
- Generate `package-lock.json`.
119+
- Versioning is manual.
113120

114-
npm install --package-lock-only
121+
#### Manual release
122+
Make sure to run `poe generate` on the root folder first and adjust version number in `package.json`.
115123

116-
- Commit your changes with a message like `Release vx.y.z`.
117-
- Create a tag, and push to remote.
118-
- Build package.
119-
120-
npm run build
121-
122-
- Publish package.
123-
124-
npm login
125-
npm publish
124+
Then run:
125+
```shell
126+
npm install --package-lock-only &&
127+
npm run build &&
128+
npm login &&
129+
npm publish
130+
```

0 commit comments

Comments
 (0)