https://github.com/stringbean/scalafmt-action
https://github.com/stringbean/scalafmt-action
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/stringbean/scalafmt-action
- Owner: stringbean
- License: apache-2.0
- Created: 2021-02-16T13:26:38.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-02-20T13:16:07.000Z (about 3 years ago)
- Last Synced: 2024-10-12T11:08:39.782Z (over 1 year ago)
- Language: TypeScript
- Size: 1.29 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# scalafmt GitHub Action
GitHub Action for checking Scala source files are correctly formatted using
[scalafmt](https://scalameta.org/scalafmt/).
## Usage
Add a job that calls the action:
```yaml
jobs:
lint:
steps:
- uses: stringbean/scalafmt-action@v3
with:
compare-branch: main
```
Any scalafmt errors will then get annotated in the action results.
### Minimising git fetch
You can reduce the amount of git history that is fetched by manually fetching the head and base refs:
```yaml
jobs:
lint:
name: Scalafmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout branches
run: |
git remote set-branches origin "${{github.base_ref}}" "${{github.head_ref}}"
git fetch --depth 1
git checkout "${{github.head_ref}}"
- uses: stringbean/scalafmt-action@v3
with:
use-gitignore: true
compare-branch: 'origin/${{github.base_ref}}'
```
> **Note**
> You _must_ include `origin/` in the `compare-branch` if you are performing a partial fetch otherwise
> scalafmt will not find the branch.
## Options
| Name | Description | Default |
| ---------------- | ---------------------------------------------------------------------------------------------- | ------------------- |
| `version` | Version of scalafmt to run with - if `auto` then the version in `.scalafmt.conf` will be used. | `auto` |
| `format-files` | If `true` then the code will be reformatted instead of checked. | `false` |
| `compare-branch` | Name of a branch to compare differences to. If set then only changed files will be scanned. | _none_ |
| `use-gitignore` | Whether scalafmt should read the `.gitignore` file (only supported for scalafmt 2.x). | `true` |
| `path` | Path to Scala sources to scan. | `.` (repo root dir) |
| `github-token` | GitHub access token to fetch changed files using. | (autodetected) |
> **Warning**
> This action uses the native version of scalafmt which cannot switch versions at runtime. The
> version specified in the action _must_ match the one in `.scalafmt.conf` or the action will fail.