-
Notifications
You must be signed in to change notification settings - Fork 8
146 lines (125 loc) · 4.98 KB
/
Copy pathsync-postypes.yaml
File metadata and controls
146 lines (125 loc) · 4.98 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
name: Sync POS Tags from Kiwi Upstream
on:
schedule:
# Run weekly on Monday at 9:00 AM UTC
- cron: '0 9 * * 1'
workflow_dispatch:
inputs:
kiwi_version:
description: 'Kiwi version to sync (e.g., v0.23.2)'
required: false
default: ''
permissions:
contents: write
pull-requests: write
jobs:
check-and-sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m venv .venv
source .venv/bin/activate
pip install tree-sitter tree-sitter-cpp
- name: Get latest Kiwi version
id: get_version
run: |
if [ -n "${{ github.event.inputs.kiwi_version }}" ]; then
VERSION="${{ github.event.inputs.kiwi_version }}"
else
# Get latest release from GitHub API
VERSION=$(curl -s https://api.github.com/repos/bab2min/Kiwi/releases/latest | jq -r '.tag_name')
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Kiwi version: $VERSION"
- name: Extract POS tags
id: extract
run: |
source .venv/bin/activate
python scripts/extract_postags.py ${{ steps.get_version.outputs.version }}
# Check if there are changes
if diff -q postype.go postype_generated.go > /dev/null 2>&1; then
echo "changed=false" >> $GITHUB_OUTPUT
echo "No changes detected"
else
echo "changed=true" >> $GITHUB_OUTPUT
echo "Changes detected"
fi
- name: Generate diff summary
if: steps.extract.outputs.changed == 'true'
id: diff
run: |
# Generate diff summary
DIFF=$(diff -u postype.go postype_generated.go || true)
echo "diff<<EOF" >> $GITHUB_OUTPUT
echo "$DIFF" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Count changes
ADDED=$(diff postype.go postype_generated.go | grep "^>" | wc -l || echo "0")
REMOVED=$(diff postype.go postype_generated.go | grep "^<" | wc -l || echo "0")
echo "added=$ADDED" >> $GITHUB_OUTPUT
echo "removed=$REMOVED" >> $GITHUB_OUTPUT
- name: Update files
if: steps.extract.outputs.changed == 'true'
run: |
# Replace postype.go with generated version
mv postype_generated.go postype.go
# Update Makefile version
sed -i "s/KIWI_VERSION := .*/KIWI_VERSION := ${{ steps.get_version.outputs.version }}/" Makefile
# PRs opened with GITHUB_TOKEN do not trigger CI, so the generated code is
# verified here instead. Without this a non-compiling postype.go can be
# proposed and merged unnoticed.
- name: Verify generated code
if: steps.extract.outputs.changed == 'true'
run: |
make install-kiwi
make test
- name: Create Pull Request
if: steps.extract.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "sync: update POS tags from Kiwi ${{ steps.get_version.outputs.version }}"
branch: sync/postypes-${{ steps.get_version.outputs.version }}
delete-branch: true
title: "sync: update POS tags from Kiwi ${{ steps.get_version.outputs.version }}"
body: |
## POS Tag Sync from Kiwi ${{ steps.get_version.outputs.version }}
This PR was automatically generated by the POS tag sync workflow.
### Changes
- Added: ${{ steps.diff.outputs.added }} lines
- Removed: ${{ steps.diff.outputs.removed }} lines
### Diff Summary
```
${{ steps.diff.outputs.diff }}
```
### Verification
- [ ] POS tags match C++ source
- [ ] Tests pass
- [ ] No breaking changes
---
*This PR was created by [sync-postypes.yaml](.github/workflows/sync-postypes.yaml)*
labels: |
automated
- name: Summary
if: always()
run: |
echo "## Sync Summary" >> $GITHUB_STEP_SUMMARY
echo "- Kiwi Version: ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- Changes Detected: ${{ steps.extract.outputs.changed }}" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.extract.outputs.changed }}" == "true" ]; then
echo "- Added: ${{ steps.diff.outputs.added }} lines" >> $GITHUB_STEP_SUMMARY
echo "- Removed: ${{ steps.diff.outputs.removed }} lines" >> $GITHUB_STEP_SUMMARY
echo "- PR Created: Yes" >> $GITHUB_STEP_SUMMARY
else
echo "- Status: Already in sync" >> $GITHUB_STEP_SUMMARY
fi