Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:

- name: Lint
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_BASE_REF: ${{ github.base_ref }}
GITHUB_HEAD_REF: ${{ github.head_ref }}
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
GITHUB_TOKEN: ${{ github.token }}
GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: mise run lint
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,17 @@ run = "flint run --fix"

- name: Lint
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_BASE_REF: ${{ github.base_ref }}
GITHUB_HEAD_REF: ${{ github.head_ref }}
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
GITHUB_TOKEN: ${{ github.token }}
GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: mise run lint
```

`GITHUB_HEAD_SHA` tells flint which commit is the PR head when running in CI.
`fetch-depth: 0` is required for merge-base detection.
The GitHub environment variables let flint remap base-branch links to the PR
branch when link checking. `fetch-depth: 0` is required for merge-base
detection.

---

Expand Down
5 changes: 4 additions & 1 deletion src/init/scaffold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ jobs:
{rust_steps}
- name: Lint
env:
GITHUB_REPOSITORY: ${{{{ github.repository }}}}
GITHUB_BASE_REF: ${{{{ github.base_ref }}}}
GITHUB_HEAD_REF: ${{{{ github.head_ref }}}}
PR_HEAD_REPO: ${{{{ github.event.pull_request.head.repo.full_name || github.repository }}}}
GITHUB_TOKEN: ${{{{ github.token }}}}
GITHUB_HEAD_SHA: ${{{{ github.event.pull_request.head.sha }}}}
run: mise run lint
"#
);
Expand Down
7 changes: 7 additions & 0 deletions src/init/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,13 @@ fn generate_lint_workflow_writes_file() {
assert!(content.contains("fetch-depth: 0"));
assert!(content.contains("persist-credentials: false"));
assert!(content.contains("mise-action"));
assert!(content.contains("GITHUB_REPOSITORY: ${{ github.repository }}"));
assert!(content.contains("GITHUB_BASE_REF: ${{ github.base_ref }}"));
assert!(content.contains("GITHUB_HEAD_REF: ${{ github.head_ref }}"));
assert!(content.contains(
"PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name || github.repository }}"
));
assert!(!content.contains("GITHUB_HEAD_SHA"));
assert!(content.contains("github.token"));
assert!(!content.contains("rust-cache"));
assert!(!content.contains("rustup component"));
Expand Down
Loading