Skip to content

Commit 290a8eb

Browse files
Minor documentation and CI improvements (#747)
1 parent 616e664 commit 290a8eb

24 files changed

+575
-597
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ on:
1212
- 'src/**'
1313
- 'Dockerfile'
1414
- 'pyproject.toml'
15-
- 'pdm.lock'
15+
# NOTE: Dumped with `pdm run update`
16+
- 'requirements.txt'
1617
- '.github/workflows/build.yml'
1718

1819
jobs:

.github/workflows/docs.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# NOTE: to run pipeline in act
2-
# change ${{ secrets.GITHUB_TOKEN }} to $GITHUB_TOKEN
3-
# and uncommit Install GH
1+
# NOTE: To run this pipeline in act replace secrets.GITHUB_TOKEN with $GITHUB_TOKEN and uncomment the first step
42

53
name: Docs
64
concurrency:
@@ -26,6 +24,16 @@ jobs:
2624
name: Docs
2725
runs-on: ubuntu-22.04
2826
steps:
27+
# NOTE: Uncomment for local testing with act
28+
# - name: Install GitHub CLI (act only)
29+
# run: |
30+
# type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
31+
# curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
32+
# && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
33+
# && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
34+
# && sudo apt update \
35+
# && sudo apt install gh -y
36+
2937
- name: Check out the repo
3038
uses: actions/checkout@v3
3139

@@ -41,15 +49,6 @@ jobs:
4149
- name: Install project
4250
run: pdm install
4351

44-
# - name: Install GH
45-
# run: |
46-
# type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
47-
# curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
48-
# && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
49-
# && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
50-
# && sudo apt update \
51-
# && sudo apt install gh -y
52-
5352
- name: Clone frontend
5453
run: |
5554
gh auth setup-git

.github/workflows/installer.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
push:
77
paths:
88
- 'src/**'
9-
- 'scripts/install.py'
109
- 'pyproject.toml'
1110
- 'pdm.lock'
1211
- '.github/workflows/installer.yml'

.github/workflows/release.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,20 @@ jobs:
2727
with:
2828
install: true
2929

30-
- name: Log in to the registry
30+
- name: Log in to Docker Hub
3131
uses: docker/login-action@v1
3232
with:
3333
username: ${{ secrets.DOCKER_USERNAME }}
3434
password: ${{ secrets.DOCKER_PASSWORD }}
3535

36-
- name: Log in to the registry
36+
- name: Log in to GHCR
3737
uses: docker/login-action@v1
3838
with:
3939
registry: ${{ env.DOCKER_REGISTRY }}
4040
username: ${{ github.actor }}
4141
password: ${{ secrets.GITHUB_TOKEN }}
4242

43-
- name: Tag image for ghcr registry
44-
uses: docker/metadata-action@v3
45-
with:
46-
images: dipdup/dipdup
47-
flavor: |
48-
latest=false
49-
tags: |
50-
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}/dipdup
51-
52-
- name: Set up metadata
43+
- name: Set up Docker metadata
5344
id: meta
5445
uses: docker/metadata-action@v3
5546
with:

CONTRIBUTING.md

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22

33
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt).
44

5-
## General
5+
## For contributors
6+
7+
### General
68

79
- All code in this repository MUST be licensed under the [MIT License](./LICENSE.md).
810
- Python code in this repository MUST run on Python 3.11. Using modern language features is encouraged.
911
- Python code in this repository MUST run in Linux, macOS, Docker, and `amd64`/`arm64` environments. Windows SHOULD be supported as well.
10-
- We use the [Poetry](https://python-poetry.org/docs/#installation) package manager and GNU Make to set up the development environment. You SHOULD install both tools and run `make help` to see available shortcuts.
11-
- Developers SHOULD have fun while contributing to the project.
12+
- We use the PDM package manager to set up the development environment. You SHOULD install it and run `pdm run -l` to see available shortcuts.
13+
- Have fun!
1214

13-
## GitHub
15+
### Git workflow
1416

15-
- Branch names MUST follow `prefix/short-description` format. Prefixes currently in use: `feat` for features, `fix` for bugfixes, `docs` for documentation, `exp` for experiments, `aux` for everything else.
17+
- Branch names MUST follow `prefix/short-description` format. Prefixes currently in use: `feat` for features, `fix` for bugfixes, `docs` for documentation, `exp` for experiments, `ci` for GHA and Docker stuff, `aux` for everything else.
1618
- Commits in pull requests MUST be squashed when merging to `next`.
1719
- Issues and pull requests MUST have a descriptive title; they SHOULD be linked to each other, appropriately labeled, and assigned to maintainers while in progress.
1820

19-
## Codestyle
21+
### Codestyle
2022

2123
We use `isort` and `black` for autoformatting, `ruff` for linting, and `mypy` for typechecking. All checks MUST pass before merging the code to default branch. Everything not enforced by these tools is up to the developer. But here are some recommendations:
2224

@@ -26,13 +28,13 @@ We use `isort` and `black` for autoformatting, `ruff` for linting, and `mypy` fo
2628
- Some methods and attributes made private to avoid polluting the public API. Feel free to access them from the outside if you know what you are doing.
2729
- Finally, about exact language features. F-string formatting is preferred over other syntax. Be careful with walrus operator. Don't forget else in conditional expressions. Listen to you mom. We have no consensus about the match-case yet.
2830

29-
## Packaging
31+
### Packaging
3032

3133
- All dependencies MUST be declared in `pyproject.toml` file.
3234
- Non-development dependencies MUST be pinned to non-breaking versions (e.g. `^1.2.3`).
3335
- Core dependencies that we patch MUST be pinned to specific versions (e.g. `1.2.3`).
3436

35-
## Changelog
37+
### Changelog
3638

3739
- All changes that affect user (developer) experience MUST be documented in the CHANGELOG.md file.
3840
- Changes that significantly affect DipDup maintainers' experience MAY be documented in the CHANGELOG.md file.
@@ -42,47 +44,41 @@ We use `isort` and `black` for autoformatting, `ruff` for linting, and `mypy` fo
4244
## Documentation
4345

4446
- A page in Release Notes SHOULD accompany all major releases.
45-
- All internal links MUST be created with `{{ #summary ...` shortcodes.
46-
- All values used in project templates MUST be replaced with `{{ #cookiecutter ...` shortcodes.
4747

48-
# DipDup maintainer guide
48+
## For maintainers
4949

50-
## Security
50+
### Security
5151

5252
- GitHub alerts about dependencies that contain vulnerabilities MUST be investigated and resolved as soon as possible.
5353
- Security-related bugfixes MUST be mentioned in the changelog under the "Security" section.
5454

55-
## Privacy
55+
### Privacy
5656

5757
- Crash reporting MUST be opt-in (disabled by default) both in config and project templates.
5858
- Sentry events and crash reports MUST NOT contain any sensitive information (IP addresses, hostnames, etc.)
5959
- DipDup SHOULD NOT perform network requests to APIs not defined in config as datasources. Current exceptions: GitHub.
6060

61-
## Docker images
61+
### Docker images
6262

63-
- DipDup dockerfiles use autogenerated `requirements.txt` files. Maintainers MUST run `make update` script on every change in dependencies.
63+
- DipDup dockerfiles use autogenerated `requirements.txt` files. Maintainers MUST run `pdm run update` script on every change in dependencies.
6464
- Docker images for stable releases MUST be published on Docker Hub. They MAY also be published on GHCR.
6565
- Maintainers MAY publish arbitrary images on GHCR and remove them when not needed.
6666

67-
## Installer
67+
### Installer
6868

6969
- Installer module MUST depend on Python stdlib only.
7070

71-
## Scaffolding
71+
### Scaffolding
7272

7373
- Project templates SHOULD cover all index types available in DipDup.
7474
- They also MAY contain additional features and integrations.
7575

76-
## Demo projects
76+
### Demo projects
7777

78-
- Demos are stored in `demos` root directory. They MUST be generated automatically from project templates using replay files.
79-
- Maintainers SHOULD run `make demos replays` command regularly to ensure that demo projects are up to date.
78+
- Demos are stored in `src` directory. They MUST be generated automatically from project templates using replay files.
79+
- Maintainers SHOULD run `pdm demos` command regularly to ensure that demo projects are up to date.
8080

81-
## Releases
81+
### Releases
8282

8383
- Release versions MUST conform to [Semantic Versioning](https://semver.org/). Releases that introduce breaking changes MUST be major ones.
8484
- Only the latest major version is supported in general. Critical fixes MAY be backported to the previous major release. To do so, create an `aux/X.Y.Z` branch from the latest stable tag, bump the DipDup version manually, and add a new tag.
85-
86-
## Tests
87-
88-
## Code Review

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ DipDup is a Python framework for building smart contract indexers. It helps deve
2323

2424
This project is maintained by the [Baking Bad](https://bakingbad.dev/) team.
2525
<br>
26-
Development is supported by [Tezos Foundation](https://tezos.foundation/) and [OnlyDust](https://www.onlydust.xyz)
26+
Development is supported by [Tezos Foundation](https://tezos.foundation/) and [OnlyDust](https://www.onlydust.xyz).
2727

2828
## Thanks
2929

docs/0.quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A modern Linux/macOS distribution with Python 3.11 installed is required to run
2121
You can initialize a hello-world project interactively by choosing configuration options in the terminal. The following command will install DipDup for the current user:
2222

2323
```shell [Terminal]
24-
curl -Lsf https://dipdup.io/install.py | python3.11
24+
curl -Lsf https://dipdup.io/install.py | python3
2525
```
2626

2727
Now, let's create a new project:

docs/1.getting-started/4.package.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Package"
33
description: "Each DipDup project consists of a YAML config and a Python package of a specific structure. It could be placed anywhere, but needs to be importable. The package name is defined in the config file."
44
---
55

6-
# Package structure
6+
# Project package
77

88
Each DipDup project consists of a YAML config and a Python package of a specific structure. It could be placed anywhere, but needs to be importable. The package name is defined in the config file.
99

docs/1.getting-started/8.handlers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Handlers"
33
description: "After defining the index in the configuration file and initializing the project, you can start implementing handlers. DipDup generates callback stubs for all handlers specified in the configuration file. You can find them in the handlers directory."
44
---
55

6-
# Implementing handlers
6+
# Handlers
77

88
After defining the index in the configuration file and initializing the project, you can start implementing handlers. DipDup generates callback stubs for all handlers specified in the configuration file. You can find them in the `handlers`{lang="python"} directory.
99

docs/13.faq.md renamed to docs/12.faq.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ nested: Resources
88

99
This page contains answers to the most popular questions about DipDup guts. If you landed here - congrats, you're writing a pretty advanced indexer!
1010

11-
## How to index similar but not identical contracts as a single entity?
11+
## Indexing
12+
13+
### How to index similar but not identical contracts as a single entity?
1214

1315
Multiple contracts can provide the same interface (like FA1.2 and FA2 standard tokens) but have a different storage structure. If you try to use the same typename for them, indexing will fail. However, you can modify typeclasses manually. Modify `types/<typename>/storage.py` file and comment out unique fields that are not important for your index:
1416

@@ -24,23 +26,25 @@ class ContractStorage(BaseModel):
2426

2527
Don't forget `Extra.ignore` Pydantic hint, otherwise storage deserialization will fail. To restore the original typeclass, remove modified file and run `dipdup init` again. You can also add `--force` flag to overwrite all ABIs and typeclasses.
2628

27-
## How to use off-chain datasources?
29+
### How to use off-chain datasources?
2830

2931
DipDup provides convenient helpers to process off-chain data like market quotes or IPFS metadata. Follow the tips below to use them most efficiently.
3032

3133
- Do not perform off-chain requests in handers until necessary. Handlers need to be as fast as possible not to block the database transaction. Use hooks instead, enriching indexed data on-demand.
3234
- Use generic `http` datasource for external APIs instead of plain `aiohttp` requests. It makes available the same features DipDup uses for internal requests: retry with backoff, rate limiting, Prometheus integration etc.
3335
- Database tables that store off-chain data can be marked as immune, to speed up reindexing.
3436

35-
## How to process indexes in a specific order?
37+
### How to process indexes in a specific order?
3638

3739
Indexes of all kinds are fully independent. They are processed in parallel, have their own message queues, and don't share any state. It is one of the essential DipDup concepts, so there's no "official" way to manage the order of indexing.
3840

3941
Avoid using sync primitives like `asyncio.Event` or `asyncio.Lock` in handlers. Indexing will be stuck forever, waiting for the database transaction to complete.
4042

4143
Instead, save raw data in handlers and process it later with hooks when all conditions are met. For example, process data batch only when all indexes in the `dipdup_index` table have reached a specific level.
4244

43-
## How to perform database migrations?
45+
## Database
46+
47+
### How to perform database migrations?
4448

4549
DipDup does not provide any tooling for database migrations. The reason is that schema changes almost always imply reindexing when speaking about indexers. However, you can perform migrations yourself using any tool you like. First, disable schema hash check in config:
4650

@@ -75,7 +79,7 @@ diff old-schema.sql new-schema.sql
7579

7680
Now you can prepare and execute an `ALTER TABLE` query manually or using SQL hooks.
7781

78-
## I get `schema_modified` error, but I didn't change anything
82+
### I get `schema_modified` error, but I didn't change anything
7983

8084
DipDup compares the current schema hash with the one stored in the database. If they don't match, it throws an error. If models were not modified, most likely the reason is incorrect model definitions. e.g. if you define a timestamp field like this…
8185

@@ -104,7 +108,7 @@ You need to make the following change in models.py:
104108

105109
We plan to improve field classes in future releases to accept callables as default values.
106110

107-
## Why am I getting `decimal.InvalidOperation` error?
111+
### Why am I getting `decimal.InvalidOperation` error?
108112

109113
If your models contain `DecimalField`s, you may encounter this error when performing arithmetic operations. It's because the value is too big to fit into the current decimal context.
110114

0 commit comments

Comments
 (0)