-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (73 loc) · 2.92 KB
/
flow-openapi.yml
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
name: Flows OpenAPI Specs
on:
pull_request:
paths:
- 'flows/**'
jobs:
flow-openapi:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Checkout Visionatrix
uses: actions/checkout@v4
with:
path: src_visionatrix
repository: Visionatrix/Visionatrix
- name: Install Visionatrix
run: |
python3 -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
python3 -m pip install "src_visionatrix/."
python3 -m visionatrix install
- name: Get list of changed flow files
id: changed_files
run: |
git fetch origin ${{ github.base_ref }} --depth=1
git diff --name-only --diff-filter=AM origin/${{ github.base_ref }}...HEAD > changed_files_am.txt
grep '^flows/' changed_files_am.txt > flows_changed_files_am.txt || true
- name: Show changed flow files
run: cat flows_changed_files_am.txt
- name: Check if any flows were changed
id: check_flows
run: |
if [ -s flows_changed_files_am.txt ]; then
echo "flows_changed=true" >> $GITHUB_OUTPUT
else
echo "flows_changed=false" >> $GITHUB_OUTPUT
fi
- name: Install, check, and generate OpenAPI specs for flows
if: steps.check_flows.outputs.flows_changed == 'true'
run: |
mkdir -p flows_openapi
while read file; do
echo "Processing $file"
# Install and check the flow
VIX_MODE=SERVER VIX_SERVER_FULL_MODELS=0 python3 -m visionatrix install-flow --file="$file"
# Generate OpenAPI spec
flow_name=$(basename "$file")
openapi_file="flows_openapi/$flow_name"
python3 -m visionatrix openapi --only-flows --file="$openapi_file"
# Delete the file in vix_flows/
rm -f "vix_flows/$flow_name"
done < flows_changed_files_am.txt
- name: Upload OpenAPI specs as artifact
if: steps.check_flows.outputs.flows_changed == 'true'
uses: actions/upload-artifact@v3
with:
name: OpenAPI Specs
path: flows_openapi/
- name: Post comment on PR with artifact link
if: steps.check_flows.outputs.flows_changed == 'true'
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: ${{ github.event.pull_request.number }},
owner: context.repo.owner,
repo: context.repo.repo,
body: '✅ The generated OpenAPI specifications are available as artifacts in the [Actions tab](${{ github.run_url }}). Please download the "OpenAPI Specs" artifact to review them.'
})