Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add sourcery assistant review workflow #1

Merged
merged 3 commits into from
Nov 14, 2023
Merged
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
63 changes: 63 additions & 0 deletions .github/workflows/sourcery_code_review.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Perform a code review on a pull request using the Sourcery Coding Assistant.

name: Sourcery Coding Assistant Review

on:
# Trigger the review on pull request events.
pull_request:
types:
# Trigger the review when either of these events occur:
#
# - a review is requested from any user
# - the "sourcery-review" label is added to the pull request: add this label
# to your pull request to trigger a review. To re-request reviews, remove the
# label and add it again.
#
# Feel free to edit this list to suit your team's needs. See the list of all
# activity types here:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
- review_requested
- labeled

permissions:
# Read the contents of the repository
contents: read
# Create a pull request review
pull-requests: write
brendanator marked this conversation as resolved.
Show resolved Hide resolved

jobs:
sourcery-coding-assistant-review:
# Only run this job when a review is requested or the "sourcery-review"
# label is added to the pull request.
if: |
github.event.action == 'review_requested' ||
brendanator marked this conversation as resolved.
Show resolved Hide resolved
brendanator marked this conversation as resolved.
Show resolved Hide resolved
brendanator marked this conversation as resolved.
Show resolved Hide resolved
github.event.label.name == 'sourcery-review'

runs-on: ubuntu-latest

steps:
- name: Install Sourcery
shell: bash
# Install the latest nightly version of Sourcery from PyPI.
brendanator marked this conversation as resolved.
Show resolved Hide resolved
brendanator marked this conversation as resolved.
Show resolved Hide resolved
# This gives you access to the latest features and bug fixes.
# To install the latest stable version, use `pip install sourcery`.
run: |
pip install --pre sourcery-nightly

- name: Log into Sourcery
shell: bash
# Log into Sourcery using the Sourcery token stored in the SOURCERY_TOKEN GitHub
# secret.
run: |
sourcery login \
brendanator marked this conversation as resolved.
Show resolved Hide resolved
--token ${{ secrets.SOURCERY_TOKEN }}

- name: Run Sourcery code review
# Run the Sourcery code review on the pull request that triggered this workflow.
shell: bash
run: |
sourcery assistant review pull-request \
brendanator marked this conversation as resolved.
Show resolved Hide resolved
--token ${{ github.token }} \
--repository ${{ github.repository }} \
--pull-request ${{ github.event.pull_request.number }} \
--commit ${{ github.event.pull_request.head.sha }}