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
Summary:
Updates the "Add Pyrefly to CI" section in the installation docs to lead
with the new composite GitHub Action as the recommended approach, addressing
#11.
Restructures the section into three subsections:
- "Using the GitHub Action (Recommended)" — minimal 4-line workflow example,
version pinning, extra args, and an inputs reference table
- "Manual Setup" — the existing workflow content for users who need more
control or use non-GitHub CI systems (GitLab, Jenkins, etc.)
- "Inline PR Annotations" — updated to note the action enables this by
default; manual setup users add `--output-format=github`
Also fixes an indentation bug in the original YAML example and adds
`--output-format=github` to the manual workflow by default.
Reviewed By: rchen152
Differential Revision: D100068155
fbshipit-source-id: b099b99f09e812bf2fb307f6cb7e667b6b829d9d
Copy file name to clipboardExpand all lines: website/docs/installation.mdx
+60-9Lines changed: 60 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,7 +115,57 @@ This will add `# pyrefly: ignore` comments to your code, enabling you to silence
115
115
116
116
## Add Pyrefly to CI
117
117
118
-
After your project passes type checks without errors, you can prevent new bugs from being introduced. Enforce this through CI (Continuous Integration) to prevent other maintainers from merging code with errors. Here is an example for GitHub.
118
+
After your project passes type checks without errors, you can prevent new bugs from being introduced. Enforce this through CI (Continuous Integration) to prevent other maintainers from merging code with errors.
119
+
120
+
### Using the GitHub Action (Recommended)
121
+
122
+
The simplest way to add Pyrefly to GitHub Actions is with the official composite action. It handles Python setup, installation, and running the type checker with inline PR annotations enabled by default.
123
+
124
+
```yaml
125
+
- uses: facebook/pyrefly@main
126
+
```
127
+
128
+
Here is a complete workflow example:
129
+
130
+
```yaml
131
+
name: Pyrefly Type Check
132
+
133
+
on:
134
+
pull_request:
135
+
branches: [main]
136
+
137
+
jobs:
138
+
typecheck:
139
+
runs-on: ubuntu-latest
140
+
steps:
141
+
- uses: actions/checkout@v4
142
+
- uses: facebook/pyrefly@main
143
+
```
144
+
145
+
You can pin a specific Pyrefly version, set the Python version, or pass extra arguments:
146
+
147
+
```yaml
148
+
- uses: facebook/pyrefly@main
149
+
with:
150
+
version: "0.60.0"
151
+
python-version: "3.12"
152
+
args: "--summarize-errors"
153
+
```
154
+
155
+
The action accepts the following inputs:
156
+
157
+
| Input | Default | Description |
158
+
|-------|---------|-------------|
159
+
| `version` | latest | Pyrefly version to install (e.g., `0.60.0`) |
160
+
| `args` | | Extra arguments passed to `pyrefly check` |
161
+
| `python-version` | `3.x` | Python version for `actions/setup-python` |
162
+
| `working-directory` | `.` | Directory to run the type check in |
163
+
164
+
Type errors appear as inline annotations on pull requests automatically via `--output-format=github`.
165
+
166
+
### Manual Setup
167
+
168
+
If you need more control or use a non-GitHub CI system (GitLab CI, Jenkins, etc.), you can set up Pyrefly manually.
119
169
120
170
Save your workflow in the following path within your repository:
121
171
@@ -125,7 +175,7 @@ Save your workflow in the following path within your repository:
125
175
126
176
GitHub automatically detects `.yml` files within `.github/workflows/` and sets up the defined workflows.
127
177
128
-
```
178
+
```yaml
129
179
name: Pyrefly Type Check
130
180
131
181
on:
@@ -145,7 +195,7 @@ jobs:
145
195
uses: actions/setup-python@v5
146
196
147
197
# Install Python dependencies and create environment
148
-
- name: Install dependencies and run type checking
198
+
- name: Install dependencies
149
199
run: |
150
200
python -m venv .venv
151
201
source .venv/bin/activate
@@ -156,8 +206,8 @@ jobs:
156
206
- name: Install Pyrefly
157
207
run: pip install pyrefly
158
208
159
-
- name: Run Pyrefly Type Checker
160
-
run: pyrefly check
209
+
- name: Run Pyrefly Type Checker
210
+
run: pyrefly check --output-format=github
161
211
```
162
212
163
213
### Inline PR Annotations
@@ -167,18 +217,19 @@ Pyrefly can emit errors as [GitHub Actions workflow commands](https://docs.githu
167
217
To enable this, pass `--output-format=github`:
168
218
169
219
```
170
-
- name: Run Pyrefly Type Checker
171
-
run: pyrefly check --output-format=github
220
+
pyrefly check --output-format=github
172
221
```
173
222
223
+
The GitHub Action enables this by default. For manual setups, add the flag to your workflow step.
224
+
174
225
### A few notes about this setup:
175
226
176
227
- Building your environment and installing dependencies will enhance type safety by checking the types of imports. *This is not required, but encouraged!*
177
228
- Simply drop in `pyrefly check` to existing workflows that build and test your environment.
178
229
179
230
```
180
-
- name: Run Pyrefly Type Checker
181
-
run: pyrefly check
231
+
- name: Run Pyrefly Type Checker
232
+
run: pyrefly check
182
233
```
183
234
184
235
- Your `pyrefly.toml` or Pyrefly configs in your `pyproject.toml` will be automatically detected. Learn how to [configure Pyrefly here](../configuration).
0 commit comments