4
4
workflow_dispatch :
5
5
inputs :
6
6
pr :
7
- description : ' PR Number'
7
+ description : " PR Number"
8
8
type : string
9
9
required : true
10
10
comment-id :
11
- description : ' Comment ID (Optional)'
11
+ description : " Comment ID (Optional)"
12
12
type : string
13
13
required : false
14
14
@@ -20,152 +20,147 @@ jobs:
20
20
# Don't run on forks. Run on pushes to main, and on PRs that are not from forks.
21
21
strategy :
22
22
matrix :
23
- python-version : [
24
- ' 3.10' ,
25
- ]
26
- os : [
27
- Ubuntu,
28
- ]
23
+ python-version : ["3.10"]
24
+ os : [Ubuntu]
29
25
fail-fast : false
30
26
31
27
runs-on : " ${{ matrix.os }}-latest"
32
28
steps :
33
-
34
- # Custom steps to fetch the PR and checkout the code:
35
- - name : Checkout Airbyte
36
- uses : actions/checkout@v4
37
- with :
38
- # Important that this is set so that CI checks are triggered again
39
- # Without this we would be forever waiting on required checks to pass
40
- token : ${{ secrets.GH_PAT_APPROVINGTON_OCTAVIA }}
41
-
42
- - name : Checkout PR (${{ github.event.inputs.pr }})
43
- uses : dawidd6/action-checkout-pr@v1
44
- with :
45
- pr : ${{ github.event.inputs.pr }}
46
-
47
- - name : Get PR info
48
- id : pr-info
49
- run : |
50
- PR_JSON=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.inputs.pr }})
51
- echo "repo=$(echo "$PR_JSON" | jq -r .head.repo.full_name)" >> $GITHUB_OUTPUT
52
- echo "branch=$(echo "$PR_JSON" | jq -r .head.ref)" >> $GITHUB_OUTPUT
53
- env :
54
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
55
- shell : bash
56
-
57
- - name : Create URL to the run output
58
- id : vars
59
- run : echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT
60
-
61
- - name : Append comment with job run link
62
- id : first-comment-action
63
- uses : peter-evans/create-or-update-comment@v4
64
- with :
65
- comment-id : ${{ github.event.inputs.comment-id }}
66
- issue-number : ${{ github.event.inputs.pr }}
67
- body : |
68
- > **Auto-Fix Job Info**
69
- >
70
- > This job attempts to auto-fix any linting or formating issues. If any fixes are made,
71
- > those changes will be automatically committed and pushed back to the PR.
72
- >
73
- > Note: This job can only be run by maintainers. On PRs from forks, this command requires
74
- > that the PR author has enabled the `Allow edits from maintainers` option.
75
-
76
- > PR auto-fix job started... [Check job output.][1]
77
-
78
- [1]: ${{ steps.vars.outputs.run-url }}
79
-
80
- - name : Set up Poetry
81
- uses : Gr1N/setup-poetry@v9
82
- with :
83
- poetry-version : " 1.7.1"
84
- - name : Set up Python
85
- uses : actions/setup-python@v5
86
- with :
87
- python-version : ${{ matrix.python-version }}
88
- cache : ' poetry'
89
- - name : Install dependencies
90
- run : poetry install --all-extras
91
-
92
- # Fix any lint or format issues
93
-
94
- - name : Auto-Fix Ruff Lint Issues
95
- run : poetry run ruff check --fix . || true
96
- - name : Auto-Fix Ruff Format Issues
97
- run : poetry run ruff format . || true
98
-
99
- # Check for changes in git
100
-
101
- - name : Check for changes
102
- id : git-diff
103
- run : |
104
- git diff --quiet && echo "No changes to commit" || echo "changes=true" >> $GITHUB_OUTPUT
105
- shell : bash
106
-
107
- # Commit changes (if any)
108
-
109
- - name : Commit changes
110
- if : steps.git-diff.outputs.changes == 'true'
111
- run : |
112
- git config --global user.name "octavia-squidington-iii"
113
- git config --global user.email "[email protected] "
114
- git add .
115
- git commit -m "Auto-fix lint and format issues"
116
-
117
- # Fix any further 'unsafe' lint issues in a separate commit
118
-
119
- - name : Auto-Fix Ruff Lint Issues (Unsafe)
120
- run : poetry run ruff check --fix --unsafe-fixes . || true
121
- - name : Auto-Fix Ruff Format Issues
122
- run : poetry run ruff format . || true
123
-
124
- # Check for changes in git (2nd time, for 'unsafe' lint fixes)
125
-
126
- - name : Check for changes ('unsafe' fixes)
127
- id : git-diff-2
128
- run : |
129
- git diff --quiet && echo "No changes to commit" || echo "changes=true" >> $GITHUB_OUTPUT
130
- shell : bash
131
-
132
- - name : Commit 'unsafe' lint fixes
133
- if : steps.git-diff-2.outputs.changes == 'true'
134
- run : |
135
- git config --global user.name "octavia-squidington-iii"
136
- git config --global user.email "[email protected] "
137
- git add .
138
- git commit -m "Auto-fix lint issues (unsafe)"
139
-
140
- - name : Push changes to '(${{ steps.pr-info.outputs.repo }})'
141
- if : steps.git-diff.outputs.changes == 'true' || steps.git-diff-2.outputs.changes == 'true'
142
- run : |
143
- git remote add contributor https://github.com/${{ steps.pr-info.outputs.repo }}.git
144
- git push contributor HEAD:${{ steps.pr-info.outputs.branch }}
145
-
146
- - name : Append success comment
147
- uses : peter-evans/create-or-update-comment@v4
148
- if : steps.git-diff.outputs.changes == 'true' || steps.git-diff-2.outputs.changes == 'true'
149
- with :
150
- comment-id : ${{ steps.first-comment-action.outputs.comment-id }}
151
- reactions : hooray
152
- body : |
153
- > ✅ Changes applied successfully.
154
-
155
- - name : Append success comment (no-op)
156
- uses : peter-evans/create-or-update-comment@v4
157
- if : steps.git-diff.outputs.changes != 'true' && steps.git-diff-2.outputs.changes != 'true'
158
- with :
159
- comment-id : ${{ steps.first-comment-action.outputs.comment-id }}
160
- reactions : " +1"
161
- body : |
162
- > 🟦 Job completed successfully (no changes).
163
-
164
- - name : Append failure comment
165
- uses : peter-evans/create-or-update-comment@v4
166
- if : failure()
167
- with :
168
- comment-id : ${{ steps.first-comment-action.outputs.comment-id }}
169
- reactions : confused
170
- body : |
171
- > ❌ Job failed.
29
+ # Custom steps to fetch the PR and checkout the code:
30
+ - name : Checkout Airbyte
31
+ uses : actions/checkout@v4
32
+ with :
33
+ # Important that this is set so that CI checks are triggered again
34
+ # Without this we would be forever waiting on required checks to pass
35
+ token : ${{ secrets.GH_PAT_APPROVINGTON_OCTAVIA }}
36
+
37
+ - name : Checkout PR (${{ github.event.inputs.pr }})
38
+ uses : dawidd6/action-checkout-pr@v1
39
+ with :
40
+ pr : ${{ github.event.inputs.pr }}
41
+
42
+ - name : Get PR info
43
+ id : pr-info
44
+ run : |
45
+ PR_JSON=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.inputs.pr }})
46
+ echo "repo=$(echo "$PR_JSON" | jq -r .head.repo.full_name)" >> $GITHUB_OUTPUT
47
+ echo "branch=$(echo "$PR_JSON" | jq -r .head.ref)" >> $GITHUB_OUTPUT
48
+ env :
49
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
50
+ shell : bash
51
+
52
+ - name : Create URL to the run output
53
+ id : vars
54
+ run : echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT
55
+
56
+ - name : Append comment with job run link
57
+ id : first-comment-action
58
+ uses : peter-evans/create-or-update-comment@v4
59
+ with :
60
+ comment-id : ${{ github.event.inputs.comment-id }}
61
+ issue-number : ${{ github.event.inputs.pr }}
62
+ body : |
63
+ > **Auto-Fix Job Info**
64
+ >
65
+ > This job attempts to auto-fix any linting or formating issues. If any fixes are made,
66
+ > those changes will be automatically committed and pushed back to the PR.
67
+ >
68
+ > Note: This job can only be run by maintainers. On PRs from forks, this command requires
69
+ > that the PR author has enabled the `Allow edits from maintainers` option.
70
+
71
+ > PR auto-fix job started... [Check job output.][1]
72
+
73
+ [1]: ${{ steps.vars.outputs.run-url }}
74
+
75
+ - name : Set up Poetry
76
+ uses : Gr1N/setup-poetry@v9
77
+ with :
78
+ poetry-version : " 1.7.1"
79
+ - name : Set up Python
80
+ uses : actions/setup-python@v5
81
+ with :
82
+ python-version : ${{ matrix.python-version }}
83
+ cache : " poetry"
84
+ - name : Install dependencies
85
+ run : poetry install --all-extras
86
+
87
+ # Fix any lint or format issues
88
+
89
+ - name : Auto-Fix Ruff Lint Issues
90
+ run : poetry run ruff check --fix . || true
91
+ - name : Auto-Fix Ruff Format Issues
92
+ run : poetry run ruff format . || true
93
+
94
+ # Check for changes in git
95
+
96
+ - name : Check for changes
97
+ id : git-diff
98
+ run : |
99
+ git diff --quiet && echo "No changes to commit" || echo "changes=true" >> $GITHUB_OUTPUT
100
+ shell : bash
101
+
102
+ # Commit changes (if any)
103
+
104
+ - name : Commit changes
105
+ if : steps.git-diff.outputs.changes == 'true'
106
+ run : |
107
+ git config --global user.name "octavia-squidington-iii"
108
+ git config --global user.email "[email protected] "
109
+ git add .
110
+ git commit -m "Auto-fix lint and format issues"
111
+
112
+ # Fix any further 'unsafe' lint issues in a separate commit
113
+
114
+ - name : Auto-Fix Ruff Lint Issues (Unsafe)
115
+ run : poetry run ruff check --fix --unsafe-fixes . || true
116
+ - name : Auto-Fix Ruff Format Issues
117
+ run : poetry run ruff format . || true
118
+
119
+ # Check for changes in git (2nd time, for 'unsafe' lint fixes)
120
+
121
+ - name : Check for changes ('unsafe' fixes)
122
+ id : git-diff-2
123
+ run : |
124
+ git diff --quiet && echo "No changes to commit" || echo "changes=true" >> $GITHUB_OUTPUT
125
+ shell : bash
126
+
127
+ - name : Commit 'unsafe' lint fixes
128
+ if : steps.git-diff-2.outputs.changes == 'true'
129
+ run : |
130
+ git config --global user.name "octavia-squidington-iii"
131
+ git config --global user.email "[email protected] "
132
+ git add .
133
+ git commit -m "Auto-fix lint issues (unsafe)"
134
+
135
+ - name : Push changes to '(${{ steps.pr-info.outputs.repo }})'
136
+ if : steps.git-diff.outputs.changes == 'true' || steps.git-diff-2.outputs.changes == 'true'
137
+ run : |
138
+ git remote add contributor https://github.com/${{ steps.pr-info.outputs.repo }}.git
139
+ git push contributor HEAD:${{ steps.pr-info.outputs.branch }}
140
+
141
+ - name : Append success comment
142
+ uses : peter-evans/create-or-update-comment@v4
143
+ if : steps.git-diff.outputs.changes == 'true' || steps.git-diff-2.outputs.changes == 'true'
144
+ with :
145
+ comment-id : ${{ steps.first-comment-action.outputs.comment-id }}
146
+ reactions : hooray
147
+ body : |
148
+ > ✅ Changes applied successfully.
149
+
150
+ - name : Append success comment (no-op)
151
+ uses : peter-evans/create-or-update-comment@v4
152
+ if : steps.git-diff.outputs.changes != 'true' && steps.git-diff-2.outputs.changes != 'true'
153
+ with :
154
+ comment-id : ${{ steps.first-comment-action.outputs.comment-id }}
155
+ reactions : " +1"
156
+ body : |
157
+ > 🟦 Job completed successfully (no changes).
158
+
159
+ - name : Append failure comment
160
+ uses : peter-evans/create-or-update-comment@v4
161
+ if : failure()
162
+ with :
163
+ comment-id : ${{ steps.first-comment-action.outputs.comment-id }}
164
+ reactions : confused
165
+ body : |
166
+ > ❌ Job failed.
0 commit comments