Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sourcery-ai/action
A GitHub Action for running Sourcery.
https://github.com/sourcery-ai/action
action actions ci continuous-delivery continuous-integration github github-actions
Last synced: 4 days ago
JSON representation
A GitHub Action for running Sourcery.
- Host: GitHub
- URL: https://github.com/sourcery-ai/action
- Owner: sourcery-ai
- License: mit
- Created: 2022-11-07T12:14:49.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T08:49:47.000Z (11 months ago)
- Last Synced: 2024-03-15T12:21:18.468Z (8 months ago)
- Topics: action, actions, ci, continuous-delivery, continuous-integration, github, github-actions
- Homepage:
- Size: 14.6 KB
- Stars: 25
- Watchers: 3
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sourcery GitHub Action
## Overview
Run [Sourcery](https://sourcery.ai/) as a GitHub Action that you can easily add to your
Continuous Integration.This action performs the following operations:
* Installs Sourcery on your worker machine
* Logs in to Sourcery using your access token
* Reviews your code> **Note**: the Sourcery GitHub Action is FREE for open-source projects.
> **Note**: for private repositories, a
> [TEAM subscription](https://docs.sourcery.ai/Product/Plans/#team) is required.
> Check out our [pricing page](https://sourcery.ai/pricing/) to sign up.## Usage
### Check your entire codebase
To run Sourcery over your entire codebase whenever a push is done to the `main` branch:
```yaml
name: Check codebase using Sourceryon:
push:
branches: [main]jobs:
review-with-sourcery:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3- uses: actions/setup-python@v4
with:
python-version: '3.10'- uses: sourcery-ai/action@v1
with:
token: ${{ secrets.SOURCERY_TOKEN }}
```We recommend you store your Sourcery token as a
[GitHub secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets) on
your repository. In the example above, that secret was stored as `SOURCERY_TOKEN`.You can retrieve your Sourcery token from your
[dashboard](https://sourcery.ai/dashboard/profile).### Check your PR
To run Sourcery only on the changed code in a PR:
```yaml
name: Check PR using Sourceryon: pull_request
jobs:
review-with-sourcery:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0- uses: actions/setup-python@v4
with:
python-version: '3.10'- uses: sourcery-ai/action@v1
with:
token: ${{ secrets.SOURCERY_TOKEN }}
diff_ref: ${{ github.event.pull_request.base.sha }}
```Note here that we pass the `fetch-depth: 0` option to
[`actions/checkout@v3`](https://github.com/actions/checkout). This is necessary because
Sourcery needs access to both the current branch and the main branch in order to compute
diffs.## Inputs
### `token`
> **Type**: string
>
> **CLI equivalent**: `--token `A Sourcery token. You can retrieve yours at the
[Sourcery dashboard](https://sourcery.ai/dashboard/profile).We recommend you to store your token as a
[GitHub secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets).### `target`
> **Type**: string
>
> **Default**: `.`
>
> **CLI equivalent**: `--target `File(s) or directory(ies) for Sourcery to review.
This defaults to `"."`, meaning that Sourcery will review your entire project.
To review only the directories `dir1/` and `dir2/` along with the files `file1.py` and
`file2.py`, pass them as space-separated strings:```yaml
- uses: sourcery-ai/action@v1
with:
token: ${{ secrets.SOURCERY_TOKEN }}
target: dir1 dir2 file1.py file2.py
```### `version`
> **Type**: string
>
> **Default**: The latest Sourcery version available
>
> **CLI equivalent**: NoneThe Sourcery CLI version to use.
This defaults to the latest version available.
To choose a specific version (let's say `v1.5.0`):
```yaml
- uses: sourcery-ai/action@v1
with:
token: ${{ secrets.SOURCERY_TOKEN }}
version: 1.5.0
```We recommend you _not_ to this option unless strictly necessary. Pinning a Sourcery
version may leave you out from the awesome features we are working on - as well as
bugfixes ;)### `verbose`
> **Type**: either `true` or `false`
>
> **Default**: `true`
>
> **CLI equivalent**: `--verbose`Enable or disable Sourcery's verbose output.
### `check`
> **Type**: either `true` or `false`
>
> **Default**: `true`
>
> **CLI equivalent**: `--check`Whether Sourcery should return an error code or not if issues are found in the code.
This defaults to `true`, and hence the Sourcery CI step will fail in case Sourcery finds
issues in your code. You can pass `false` to prevent that behavior.### `fix`
> **Type**: either `true` or `false`
>
> **Default**: `false`
>
> **CLI equivalent**: `--fix`Whether Sourcery should automatically fix and modify the reviewed files in-place or not.
### `config`
> **Type**: string
>
> **Default**: None
>
> **CLI equivalent**: `--config `Path to a valid Sourcery configuration file.
By default, this searches the current directory and its parents for a `.sourcery.yaml`
file.To use a configuration file located elsewhere (for instance, at
**`config_files/.my-team-rules.yaml`**):```yaml
- uses: sourcery-ai/action@v1
with:
token: ${{ secrets.SOURCERY_TOKEN }}
config: config_files/.my-team-rules.yaml
```### `diff_ref`
> **Type**: string
>
> **Default**: None
>
> **CLI equivalent**: `--diff="git diff "`A reference to compute a `git diff`.
This is not used by default. In this case, Sourcery will run over the entire
[`target`](#target) files.To run Sourcery only on the changed lines in a PR, use:
```yaml
- uses: sourcery-ai/action@v1
with:
token: ${{ secrets.SOURCERY_TOKEN }}
diff_ref: ${{ github.event.pull_request.base.sha }}
```