Skip to content

Restructure CI workflow to fix race conditions and Linux dependencies #68

Restructure CI workflow to fix race conditions and Linux dependencies

Restructure CI workflow to fix race conditions and Linux dependencies #68

Workflow file for this run

name: CI Workflow
# Trigger on PR events and direct pushes to main (but not PR merges)
on:
push:
branches:
- main
- feature/windows-linux-compability
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
# Define the jobs to run in the workflow
jobs:
build:
strategy:
matrix:
include:
- os: macos-latest
platform: macos
artifact: libLoopAlgorithmToPython.dylib
- os: ubuntu-latest
platform: linux
artifact: libLoopAlgorithmToPython.so
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Set up Swift
uses: swiftactions/setup-swift@v2
with:
swift-version: "6.0"
- name: Install additional Linux dependencies
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y libsqlite3-dev zlib1g-dev libncurses5-dev libicu-dev
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Build Swift library
run: |
chmod +x build.sh
./build.sh
# Debug: Check what files were actually generated
echo "Files in .build/release/:"
ls -la .build/release/ || echo "No .build/release directory"
echo "Files in loop_to_python_api/dlibs/:"
ls -la loop_to_python_api/dlibs/ || echo "No dlibs directory"
echo "${{ matrix.platform }} library file:"
ls -la loop_to_python_api/dlibs/${{ matrix.platform }}/ || echo "No ${{ matrix.platform }} dlibs"
- name: Set library path for testing
run: |
if [[ "${{ matrix.platform }}" == "linux" ]]; then
export LD_LIBRARY_PATH="${PWD}/loop_to_python_api/dlibs/linux:$LD_LIBRARY_PATH"
echo "LD_LIBRARY_PATH=${PWD}/loop_to_python_api/dlibs/linux:$LD_LIBRARY_PATH" >> $GITHUB_ENV
fi
- name: Run tests
run: |
pytest -v -s
- name: Upload library artifact
uses: actions/upload-artifact@v4
with:
name: library-${{ matrix.platform }}
path: loop_to_python_api/dlibs/${{ matrix.platform }}/${{ matrix.artifact }}
retention-days: 1
commit-libraries:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || !contains(github.event.head_commit.message, 'Merge pull request')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Download macOS library
uses: actions/download-artifact@v4
with:
name: library-macos
path: loop_to_python_api/dlibs/macos/
- name: Download Linux library
uses: actions/download-artifact@v4
with:
name: library-linux
path: loop_to_python_api/dlibs/linux/
- name: Commit and push libraries
run: |
git config --local user.name "GitHub Action"
git config --local user.email "action@github.com"
# Determine target branch
if [ "${{ github.event_name }}" = "pull_request" ]; then
TARGET_BRANCH="${{ github.event.pull_request.head.ref }}"
else
TARGET_BRANCH="${{ github.ref_name }}"
fi
# Fetch latest changes and checkout target branch
git fetch origin
git checkout -B $TARGET_BRANCH origin/$TARGET_BRANCH
# Add both library files
git add loop_to_python_api/dlibs/macos/libLoopAlgorithmToPython.dylib || echo "No macOS library to add"
git add loop_to_python_api/dlibs/linux/libLoopAlgorithmToPython.so || echo "No Linux library to add"
# Commit if there are changes
if git diff --staged --quiet; then
echo "No library changes to commit"
else
git commit -m "Update compiled libraries for macOS and Linux
🤖 Generated with [Claude Code](https://claude.ai/code)

Check failure on line 138 in .github/workflows/ci.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/ci.yml

Invalid workflow file

You have an error in your yaml syntax on line 138
Co-Authored-By: Claude <noreply@anthropic.com>"
git push origin $TARGET_BRANCH
fi