Skip to content

Workflow test fix

Workflow test fix #69

Workflow file for this run

name: CI Workflow
on:
push:
branches: [main, feature/windows-linux-compability]
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
jobs:
build-and-test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
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
uses: swiftactions/setup-swift@v2
with:
swift-version: '6.0'
- name: Install dependencies
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
run: |
chmod +x build.sh
./build.sh
- name: Run tests
run: pytest -v -s
# Save the library files so the next job can commit them
- 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
- name: Set Target Branch
id: vars
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
# Only push on direct pushes or specific PR actions to avoid loops
if: 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"
# Move files from artifact folders back to the correct repo structure
mkdir -p loop_to_python_api/dlibs/macos/
mkdir -p loop_to_python_api/dlibs/linux/
# Copy downloaded files (adjusting for nested folder structure created by download-artifact)
find temp_libs/library-macos-latest -name "*.dylib" -exec cp {} loop_to_python_api/dlibs/macos/ \;
find temp_libs/library-ubuntu-latest -name "*.so" -exec cp {} loop_to_python_api/dlibs/linux/ \;
git add loop_to_python_api/dlibs/
git commit -m "chore: update cross-platform binaries [skip ci]" || echo "No changes to commit"
git push origin ${{ needs.build-and-test.outputs.target_branch }}