Skip to content

Commit b13ac21

Browse files
authored
docs: add contributing guides
1 parent 069c011 commit b13ac21

4 files changed

Lines changed: 98 additions & 85 deletions

File tree

CONTRIBUTING.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Contributing
2+
3+
Thanks for your interest in improving the PostHog Elixir SDK.
4+
5+
## Developing locally
6+
7+
Fetch dependencies and run the test suite from the repository root:
8+
9+
```bash
10+
mix deps.get
11+
mix test
12+
```
13+
14+
### Integration tests
15+
16+
To run the integration test suite that sends real events to the API:
17+
18+
1. Create a test PostHog project and obtain an API key.
19+
2. Create `config/integration.exs` from the example file:
20+
21+
```bash
22+
cp config/integration.example.exs config/integration.exs
23+
```
24+
25+
3. Put your API key into `config/integration.exs`.
26+
4. Run the integration tests:
27+
28+
```bash
29+
mix test --only integration
30+
```
31+
32+
### Local development config
33+
34+
If you want to play with PostHog events in IEx, create `config/dev.override.exs` and point it at the instance of your choosing. This file is gitignored. A minimal example:
35+
36+
```elixir
37+
# config/dev.override.exs
38+
import Config
39+
40+
config :posthog,
41+
enable: true,
42+
api_host: "https://us.i.posthog.com",
43+
api_key: "phc_XXXX"
44+
```
45+
46+
## Pull requests
47+
48+
1. Fork the repository and create your feature branch.
49+
2. Make your changes and ensure tests pass with `mix test`.
50+
3. Run `mix format` and `mix credo --strict` to ensure code quality.
51+
4. Open a pull request.

README.md

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -253,52 +253,6 @@ and using a different HTTP library entirely.
253253
If your app works with multiple PostHog projects, PostHog can accommodate you. For
254254
setup instructions, consult the [advanced configuration guide](guides/advanced-configuration.md).
255255

256-
## Developing locally
257-
258-
You should be able to fetch dependencies and run tests right away:
259-
260-
```
261-
mix deps.get
262-
mix test
263-
```
264-
265-
To run integration test suite that sends real events to the API:
266-
267-
1. Create a test PostHog project and obtain an API key.
268-
2. Create `config/integration.exs` config that will be used for integration tests:
269-
270-
```
271-
cp config/integration.example.exs config/integration.exs
272-
```
273-
274-
3. Put API key into `config/integration.exs`
275-
4. Run integration tests
276-
277-
```
278-
mix test --only integration
279-
```
280-
281-
If you want to play with PostHog events in IEx, just create
282-
`config/dev.override.exs` and tweak it to point to the instance of your liking.
283-
This config will be gitignored. Here's a minimal example:
284-
285-
```elixir
286-
# config/dev.override.exs
287-
import Config
288-
289-
config :posthog,
290-
enable: true
291-
api_host: "https://us.i.posthog.com",
292-
api_key: "phc_XXXX"
293-
```
294-
295256
## Contributing
296257

297-
We welcome contributions! Here's how to get started:
298-
299-
1. Fork the repository and create your feature branch
300-
2. Make your changes and ensure tests pass with `mix test`
301-
3. Run `mix format` and `mix credo --strict` to ensure code quality
302-
4. Open a Pull Request
303-
304-
For changeset and release instructions, see [RELEASING.md](RELEASING.md).
258+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local setup, integration test, and pull request guidelines.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Contributing
2+
3+
This package contains the PostHog Elixir SDK compliance adapter used with the PostHog SDK Test Harness.
4+
5+
## Running tests
6+
7+
Tests run automatically in CI via GitHub Actions.
8+
9+
### Locally with Docker Compose
10+
11+
Run the full compliance suite from the `sdk_compliance_adapter` directory:
12+
13+
```bash
14+
docker-compose up --build --abort-on-container-exit
15+
```
16+
17+
This will:
18+
19+
1. Build the Elixir SDK adapter
20+
2. Pull the test harness image
21+
3. Run all compliance tests
22+
4. Show the results
23+
24+
### Manually with Docker
25+
26+
```bash
27+
# Create network
28+
docker network create test-network
29+
30+
# Build and run adapter
31+
docker build -f sdk_compliance_adapter/Dockerfile -t posthog-elixir-adapter .
32+
docker run -d --name sdk-adapter --network test-network -p 8080:8080 posthog-elixir-adapter
33+
34+
# Run test harness
35+
docker run --rm \
36+
--name test-harness \
37+
--network test-network \
38+
ghcr.io/posthog/sdk-test-harness:latest \
39+
run --adapter-url http://sdk-adapter:8080 --mock-url http://test-harness:8081
40+
41+
# Cleanup
42+
docker stop sdk-adapter && docker rm sdk-adapter
43+
docker network rm test-network
44+
```

sdk_compliance_adapter/README.md

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,9 @@
22

33
This adapter wraps the posthog-elixir SDK for compliance testing with the [PostHog SDK Test Harness](https://github.com/PostHog/posthog-sdk-test-harness).
44

5-
## Running Tests
5+
## Contributing
66

7-
Tests run automatically in CI via GitHub Actions. See the test harness repo for details.
8-
9-
### Locally with Docker Compose
10-
11-
```bash
12-
# From the posthog-elixir/sdk_compliance_adapter directory
13-
docker-compose up --build --abort-on-container-exit
14-
```
15-
16-
This will:
17-
18-
1. Build the Elixir SDK adapter
19-
2. Pull the test harness image
20-
3. Run all compliance tests
21-
4. Show results
22-
23-
### Manually with Docker
24-
25-
```bash
26-
# Create network
27-
docker network create test-network
28-
29-
# Build and run adapter
30-
docker build -f sdk_compliance_adapter/Dockerfile -t posthog-elixir-adapter .
31-
docker run -d --name sdk-adapter --network test-network -p 8080:8080 posthog-elixir-adapter
32-
33-
# Run test harness
34-
docker run --rm \
35-
--name test-harness \
36-
--network test-network \
37-
ghcr.io/posthog/sdk-test-harness:latest \
38-
run --adapter-url http://sdk-adapter:8080 --mock-url http://test-harness:8081
39-
40-
# Cleanup
41-
docker stop sdk-adapter && docker rm sdk-adapter
42-
docker network rm test-network
43-
```
7+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local build and compliance test instructions.
448

459
## Implementation
4610

0 commit comments

Comments
 (0)