Skip to content

Commit e8b10f5

Browse files
NathanTempestmeta-codesync[bot]
authored andcommitted
Document GitHub Action in CI setup guide
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
1 parent 89c9436 commit e8b10f5

1 file changed

Lines changed: 60 additions & 9 deletions

File tree

website/docs/installation.mdx

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,57 @@ This will add `# pyrefly: ignore` comments to your code, enabling you to silence
115115

116116
## Add Pyrefly to CI
117117

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.
119169

120170
Save your workflow in the following path within your repository:
121171

@@ -125,7 +175,7 @@ Save your workflow in the following path within your repository:
125175

126176
GitHub automatically detects `.yml` files within `.github/workflows/` and sets up the defined workflows.
127177

128-
```
178+
```yaml
129179
name: Pyrefly Type Check
130180
131181
on:
@@ -145,7 +195,7 @@ jobs:
145195
uses: actions/setup-python@v5
146196
147197
# Install Python dependencies and create environment
148-
- name: Install dependencies and run type checking
198+
- name: Install dependencies
149199
run: |
150200
python -m venv .venv
151201
source .venv/bin/activate
@@ -156,8 +206,8 @@ jobs:
156206
- name: Install Pyrefly
157207
run: pip install pyrefly
158208
159-
- name: Run Pyrefly Type Checker
160-
run: pyrefly check
209+
- name: Run Pyrefly Type Checker
210+
run: pyrefly check --output-format=github
161211
```
162212

163213
### Inline PR Annotations
@@ -167,18 +217,19 @@ Pyrefly can emit errors as [GitHub Actions workflow commands](https://docs.githu
167217
To enable this, pass `--output-format=github`:
168218

169219
```
170-
- name: Run Pyrefly Type Checker
171-
run: pyrefly check --output-format=github
220+
pyrefly check --output-format=github
172221
```
173222

223+
The GitHub Action enables this by default. For manual setups, add the flag to your workflow step.
224+
174225
### A few notes about this setup:
175226

176227
- Building your environment and installing dependencies will enhance type safety by checking the types of imports. *This is not required, but encouraged!*
177228
- Simply drop in `pyrefly check` to existing workflows that build and test your environment.
178229

179230
```
180-
- name: Run Pyrefly Type Checker
181-
run: pyrefly check
231+
- name: Run Pyrefly Type Checker
232+
run: pyrefly check
182233
```
183234

184235
- Your `pyrefly.toml` or Pyrefly configs in your `pyproject.toml` will be automatically detected. Learn how to [configure Pyrefly here](../configuration).

0 commit comments

Comments
 (0)