-
Notifications
You must be signed in to change notification settings - Fork 2
172 lines (151 loc) · 6.55 KB
/
Copy pathci.yml
File metadata and controls
172 lines (151 loc) · 6.55 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
name: CI Workflow
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
jobs:
build-and-test:
strategy:
fail-fast: false # Prevents one OS from stopping others from building
matrix:
os: [macos-latest, ubuntu-latest, windows-2022]
runs-on: ${{ matrix.os }}
outputs:
target_branch: ${{ steps.vars.outputs.target_branch }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Set up Swift (macOS)
if: matrix.os == 'macos-latest'
run: |
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
swift --version
- name: Set up Swift (Linux)
if: matrix.os == 'ubuntu-latest'
uses: swift-actions/setup-swift@v2 # Corrected repository name
with:
swift-version: "6.0"
- name: Set up Swift (Windows)
if: matrix.os == 'windows-2022'
uses: SwiftyLab/setup-swift@latest
with:
swift-version: "6.0"
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install pytest
- name: Run build script (Unix)
if: matrix.os != 'windows-2022'
shell: bash
run: |
chmod +x build.sh
./build.sh
# Windows build temporarily disabled due to Swift toolchain circular dependency issue
# The Windows .dll exists in the repo but is not automatically updated like .dylib/.so files
# TODO: Re-enable when Swift Windows CI circular dependency is resolved
# - name: Run build script (Windows)
# if: matrix.os == 'windows-2022'
# shell: cmd
# run: |
# :: 1. Initialize MSVC with the stable Windows SDK positional arguments
# call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" x64 10.0.22621.0 -vcvars_ver=14.29
#
# :: 2. Explicitly set SDKROOT to the Swift Windows Platform SDK
# :: This ensures Swift finds the Standard Library while using the MSVC headers above
# set SDKROOT=C:\Users\runneradmin\AppData\Local\Programs\Swift\Platforms\6.0.3\Windows.platform\Developer\SDKs\Windows.sdk
#
# :: 3. Clear SWIFTFLAGS to prevent interference with the build process
# set SWIFTFLAGS=
#
# :: 4. Run the build
# bash ./build.sh
- name: Verify library was built
shell: bash
run: |
echo "Checking if library was built successfully..."
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
EXPECTED_LIB="loop_to_python_api/dlibs/macos/libLoopAlgorithmToPython.dylib"
elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
EXPECTED_LIB="loop_to_python_api/dlibs/linux/libLoopAlgorithmToPython.so"
elif [[ "${{ matrix.os }}" == "windows-2022" ]]; then
echo "Windows build disabled - using existing committed .dll for tests"
echo "Windows .dll file exists but is not automatically updated in CI"
ls -la "loop_to_python_api/dlibs/windows/libLoopAlgorithmToPython.dll" || echo "Note: Windows .dll should be committed to repo"
exit 0
fi
echo "Expected library: $EXPECTED_LIB"
if [ -f "$EXPECTED_LIB" ]; then
echo "✓ Library found: $EXPECTED_LIB"
ls -la "$EXPECTED_LIB"
else
echo "✗ Library NOT found: $EXPECTED_LIB"
echo "Contents of dlibs directory:"
find loop_to_python_api/dlibs/ -type f -name "*" 2>/dev/null || echo "No files found in dlibs/"
echo "Contents of .build/release/:"
find .build/release/ -name "*" -type f 2>/dev/null || echo "No files found in .build/release/"
exit 1
fi
- name: Run tests
shell: bash
run: |
# Help Linux find the shared library
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/loop_to_python_api/dlibs/linux/
# Help macOS find the shared library
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(pwd)/loop_to_python_api/dlibs/macos/
# Help Windows find the shared library
export PATH=$PATH:$(pwd)/loop_to_python_api/dlibs/windows/
pytest -v -s
- name: Upload Library Artifact
uses: actions/upload-artifact@v4
with:
name: library-${{ matrix.os }}
path: |
loop_to_python_api/dlibs/macos/*.dylib
loop_to_python_api/dlibs/linux/*.so
loop_to_python_api/dlibs/windows/*.dll
if-no-files-found: error
- name: Set Target Branch
id: vars
shell: bash
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "target_branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT
else
echo "target_branch=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
commit-generated-files:
needs: build-and-test
runs-on: ubuntu-latest
if: success() && (github.event_name == 'push' || github.event_name == 'pull_request')
steps:
- name: Checkout target branch
uses: actions/checkout@v4
with:
ref: ${{ needs.build-and-test.outputs.target_branch }}
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: temp_libs
- name: Organize and Commit
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
mkdir -p loop_to_python_api/dlibs/macos/
mkdir -p loop_to_python_api/dlibs/linux/
mkdir -p loop_to_python_api/dlibs/windows/
# Move files and clean up temp folders
find temp_libs/ -name "*.dylib" -exec mv {} loop_to_python_api/dlibs/macos/ \;
find temp_libs/ -name "*.so" -exec mv {} loop_to_python_api/dlibs/linux/ \;
find temp_libs/ -name "*.dll" -exec mv {} loop_to_python_api/dlibs/windows/ \;
git add loop_to_python_api/dlibs/
git commit -m "chore: update binaries for macOS, Linux, and Windows [skip ci]" || echo "No changes to commit"
git push origin ${{ needs.build-and-test.outputs.target_branch }}