Skip to content

Commit e5dd981

Browse files
authored
feat: Add sourcery assistant review workflow (#1)
1 parent 40ff3c7 commit e5dd981

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Perform a code review on a pull request using the Sourcery Coding Assistant.
2+
3+
name: Sourcery Coding Assistant Review
4+
5+
on:
6+
# Trigger the review on pull request events.
7+
pull_request:
8+
types:
9+
# Trigger the review when either of these events occur:
10+
#
11+
# - a review is requested from any user
12+
# - the "sourcery-review" label is added to the pull request: add this label
13+
# to your pull request to trigger a review. To re-request reviews, remove the
14+
# label and add it again.
15+
#
16+
# Feel free to edit this list to suit your team's needs. See the list of all
17+
# activity types here:
18+
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
19+
- review_requested
20+
- labeled
21+
22+
permissions:
23+
# Read the contents of the repository
24+
contents: read
25+
# Create a pull request review
26+
pull-requests: write
27+
28+
jobs:
29+
sourcery-coding-assistant-review:
30+
# Only run this job when a review is requested or the "sourcery-review"
31+
# label is added to the pull request.
32+
if: |
33+
github.event.action == 'review_requested' ||
34+
github.event.label.name == 'sourcery-review'
35+
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: Install Sourcery
40+
shell: bash
41+
# Install the latest nightly version of Sourcery from PyPI.
42+
# This gives you access to the latest features and bug fixes.
43+
# To install the latest stable version, use `pip install sourcery`.
44+
run: |
45+
pip install --pre sourcery-nightly
46+
47+
- name: Log into Sourcery
48+
shell: bash
49+
# Log into Sourcery using the Sourcery token stored in the SOURCERY_TOKEN GitHub
50+
# secret.
51+
run: |
52+
sourcery login \
53+
--token ${{ secrets.SOURCERY_TOKEN }}
54+
55+
- name: Run Sourcery code review
56+
# Run the Sourcery code review on the pull request that triggered this workflow.
57+
shell: bash
58+
run: |
59+
sourcery assistant review pull-request \
60+
--token ${{ github.token }} \
61+
--repository ${{ github.repository }} \
62+
--pull-request ${{ github.event.pull_request.number }} \
63+
--commit ${{ github.event.pull_request.head.sha }}

0 commit comments

Comments
 (0)