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
add management command for importing an existing installation (#11)
* add management command for importing an existing installation
* add integration tests for management command and adjust command
also some docs
* remove abc from typevar
* add types for cli
* add test stubs for new method
* tweak documentation
* adjust documentation
* fix command
* tweakssss
* expand
* add integration test job
* add note about ci
* add check for secret
* remove check
* add tests for refresh and adjust fail floor for coverage
* add test for calling management command
* start import section in README
* remove titel
* add new model method to docs
* swap for coverage
* pare back endpoints to ones actually used
* fix types by switching account type to enum
* adjust installation instructions in README
* adjust formatting
* change to subsections
* update changelog
* update changelog
* update docs
* update docs
* adjust
* adjust wording
* explicit name of command
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+96-10Lines changed: 96 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ We adhere to Django's Code of Conduct in all interactions and expect all contrib
20
20
21
21
### `Justfile`
22
22
23
-
The repository includes a `Justfile` that provides all common development tasks with a consistent interface. Running `just` without arguments shows all available commands and their descriptions:
23
+
The repository includes a `Justfile` that provides all common development tasks with a consistent interface. Running `just` without arguments shows all available commands and their descriptions.
24
24
25
25
<!-- [[[cog
26
26
import subprocess
@@ -70,16 +70,17 @@ The following instructions will use `uv` and assume a Unix-like operating system
70
70
71
71
Windows users will need to adjust commands accordingly, though the core workflow remains the same.
72
72
73
-
Alternatively, any Python package manager that supports installing from `pyproject.toml` ([PEP 621](https://peps.python.org/pep-0621/)) can be used. If not using `uv`, ensure you have Python installed from [python.org](https://www.python.org/).
73
+
Alternatively, any Python package manager that supports installing from `pyproject.toml` ([PEP 621](https://peps.python.org/pep-0621/)) can be used. If not using `uv`, ensure you have Python installed from [python.org](https://www.python.org/) or another source such as [`pyenv`](https://github.com/pyenv/pyenv).
74
74
75
75
1. Fork the repository and clone it locally.
76
-
2. Use `uv` too bootstrap your development environment:
77
76
78
-
```bash
79
-
uv python install
80
-
uv sync --locked
81
-
# just bootstrap
82
-
```
77
+
2. Use `uv` to bootstrap your development environment.
78
+
79
+
```bash
80
+
uv python install
81
+
uv sync --locked
82
+
# just bootstrap
83
+
```
83
84
84
85
This will install the correct Python version, create and configure a virtual environment, and install all dependencies.
85
86
@@ -101,7 +102,7 @@ uv run nox --session tests
101
102
# just testall
102
103
```
103
104
104
-
Both can be passed additional arguments that will be provided to `pytest`:
105
+
Both can be passed additional arguments that will be provided to `pytest`.
105
106
106
107
```bash
107
108
uv run nox --session test -- -v --last-failed
@@ -123,6 +124,91 @@ uv run nox --session coverage
123
124
124
125
All pull requests must include tests to maintain 100% coverage. Coverage configuration can be found in the `[tools.coverage.*]` sections of [`pyproject.toml`](pyproject.toml).
125
126
127
+
### Integration Tests
128
+
129
+
Integration tests in [`tests/integration`](tests/integration) verify actual interactions with GitHub's API and webhooks. These tests are skipped by default and require:
130
+
131
+
- A GitHub App in your account
132
+
- Environment variables configured with the App's credentials
133
+
134
+
To enable integration tests, pass `--integration` to any test command:
135
+
136
+
```bash
137
+
uv run nox --session test -- --integration
138
+
# just test --integration
139
+
```
140
+
141
+
#### Setting up a Test GitHub App
142
+
143
+
1. Create a new GitHub App.
144
+
145
+
- Go to GitHub Developer Settings > GitHub Apps > New GitHub App
146
+
- Name: `@<username> - django-github-app tests` (must be unique on GitHub, max 34 characters)
147
+
- Homepage URL: Your fork's URL (e.g., `https://github.com/<username>/django-github-app`)
148
+
- Webhooks: Disable by unchecking "Active" (no webhook tests currently implemented)
149
+
- Permissions:
150
+
- Repository: Metadata (Read-only)
151
+
- Installation: "Only on this account"
152
+
153
+
2. After creation, collect these values:
154
+
155
+
- App ID (from app settings)
156
+
- Client ID (from app settings)
157
+
- Private key (generate and download)
158
+
- Installation ID (from URL after installing: `https://github.com/settings/installations/<ID>`)
159
+
160
+
3. Configure environment variables.
161
+
162
+
Using direnv (recommended):
163
+
164
+
```bash
165
+
cp .env.example .env
166
+
```
167
+
168
+
Edit the new `.env` file with the values collected above.
169
+
170
+
Or manually export:
171
+
172
+
```bash
173
+
export TEST_ACCOUNT_NAME="<username>"
174
+
# etc...
175
+
```
176
+
177
+
See [`.env.example`](.env.example) for all required variables.
178
+
179
+
#### Setting up CI Integration Tests
180
+
181
+
If you want integration tests to run in CI on your fork:
182
+
183
+
1. Go to your fork's repository settings on GitHub
184
+
185
+
2. Under "Environments", create a new environment named `integration`
186
+
187
+
3. Add the following secrets and variables to the environment:
188
+
189
+
- Secrets
190
+
-`TEST_PRIVATE_KEY`
191
+
-`TEST_WEBHOOK_SECRET`
192
+
- Variables
193
+
-`TEST_ACCOUNT_NAME`
194
+
-`TEST_ACCOUNT_TYPE`
195
+
-`TEST_APP_ID`
196
+
-`TEST_CLIENT_ID`
197
+
-`TEST_INSTALLATION_ID`
198
+
-`TEST_NAME`
199
+
200
+
> [!NOTE]
201
+
> Integration tests in CI will only run with access to these environment secrets. This is a security feature - fork PRs cannot access these secrets unless explicitly granted by repository maintainers.
202
+
203
+
#### Security Considerations
204
+
205
+
The integration test setup is designed to be secure:
206
+
207
+
- The test GitHub App requires minimal permissions (read-only metadata access)
208
+
- It's installed only on your personal account
209
+
- In CI, tests run in a protected GitHub Environment with restricted secret access
210
+
- Fork PRs cannot access integration test secrets (managed automatically by GitHub Actions)
211
+
126
212
## Linting and Formatting
127
213
128
214
This project enforces code quality standards using [`pre-commit`](https://github.com/pre-commit/pre-commit).
@@ -155,7 +241,7 @@ Configuration for these tools can be found in:
155
241
156
242
## Continuous Integration
157
243
158
-
This project uses GitHub Actions for CI/CD. The workflows can be found in [`.github/workflows/`](.github/workflows/):
244
+
This project uses GitHub Actions for CI/CD. The workflows can be found in [`.github/workflows/`](.github/workflows/).
159
245
160
246
-[`test.yml`](.github/workflows/test.yml) - Runs on pushes to the `main` branch and on all PRs
0 commit comments