-
Notifications
You must be signed in to change notification settings - Fork 256
177 lines (160 loc) · 5.61 KB
/
Copy pathintegration.yml
File metadata and controls
177 lines (160 loc) · 5.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Integration
on:
workflow_dispatch: {}
push:
branches:
- main
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
jobs:
validate-branch-name:
name: Validate Branch Name
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
contents: read
pull-requests: read
steps:
- name: Check branch name
run: |
branch_name="${{ github.head_ref }}"
if [[ ! $branch_name =~ ^(feature|feat|fix|hotfix|chore|refactor|codex)/.+ ]]; then
echo "❌ Branch name '$branch_name' does not follow the required pattern."
echo "Branch name must start with: feature/, feat/, fix/, hotfix/, chore/, refactor/, or codex/"
exit 1
fi
echo "✅ Branch name '$branch_name' is valid."
validate-pr-title:
name: Validate PR Title
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
contents: read
pull-requests: read
steps:
- name: Check PR title follows conventional commits
run: |
pr_title="${{ github.event.pull_request.title }}"
if [[ ! $pr_title =~ ^(feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert)(\(.+\))?!?:.+ ]]; then
echo "❌ PR title '$pr_title' does not follow conventional commits format."
echo "Expected format: type(optional-scope): description"
echo "Valid types: feat, fix, docs, style, refactor, perf, test, chore, ci, build, revert"
echo "Examples:"
echo " - feat: add user authentication"
echo " - fix(api): handle null response from external service"
echo " - feat!: breaking change to user API"
exit 1
fi
echo "✅ PR title '$pr_title' follows conventional commits format."
lint-python-black:
name: Check Python Formatting (Black)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Black
run: pip install black==25.12.0
- name: Get changed Python files
id: changed-files
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
git fetch origin ${{ github.base_ref }}
FILES=$(git diff --name-only --diff-filter=ACMRT origin/${{ github.base_ref }}...HEAD | grep '\.py$' || true)
else
FILES=$(git diff --name-only --diff-filter=ACMRT HEAD~1 | grep '\.py$' || true)
fi
if [ -z "$FILES" ]; then
echo "No Python files changed"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Changed Python files:"
echo "$FILES"
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "files<<EOF" >> $GITHUB_OUTPUT
echo "$FILES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Run Black check on changed files
if: steps.changed-files.outputs.has_changes == 'true'
run: |
echo "${{ steps.changed-files.outputs.files }}" | xargs black --check --diff
lint-python-ruff:
name: Lint Python Code (Ruff)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Ruff
run: pip install ruff==0.14.9
- name: Get changed Python files
id: changed-files
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
git fetch origin ${{ github.base_ref }}
FILES=$(git diff --name-only --diff-filter=ACMRT origin/${{ github.base_ref }}...HEAD | grep '\.py$' || true)
else
FILES=$(git diff --name-only --diff-filter=ACMRT HEAD~1 | grep '\.py$' || true)
fi
if [ -z "$FILES" ]; then
echo "No Python files changed"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Changed Python files:"
echo "$FILES"
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "files<<EOF" >> $GITHUB_OUTPUT
echo "$FILES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Run Ruff check on changed files
if: steps.changed-files.outputs.has_changes == 'true'
run: |
echo "${{ steps.changed-files.outputs.files }}" | xargs ruff check --output-format=github
run-tests:
permissions:
contents: read
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12']
dependencies: ['lightweight', 'extras']
env:
GOOGLE_API_KEY: ${{ vars.GOOGLE_API_KEY }}
OPENAI_API_KEY: ${{ vars.OPENAI_API_KEY }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
if [ "${{ matrix.dependencies }}" == "extras" ]; then
poetry install -E pyspark -E aws
else
poetry install
fi
- name: Run Tests
run: poetry run pytest tests/unit/