Fix CI for Linux #260
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| name: Test (macOS) | |
| # The reusable workflow consumes secrets, | |
| # which are not available to fork PRs. | |
| # Limit this job to trusted, same-repo PRs. | |
| if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }} | |
| uses: huggingface/hf-workflows/.github/workflows/swift_transformers_unit_tests.yml@main | |
| with: | |
| # Use the PR merge ref, not the head. | |
| pr_number: ${{ github.event.pull_request.number }} | |
| secrets: | |
| HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }} | |
| test-linux: | |
| name: Test (Linux) | |
| runs-on: ubuntu-latest | |
| container: swift:6.2.3 | |
| steps: | |
| - name: Checkout PR merge ref if called from PR | |
| if: ${{ github.event.pull_request.number }} | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: refs/pull/${{ github.event.pull_request.number }}/merge | |
| fetch-depth: 0 | |
| - name: Checkout fallback | |
| if: ${{ !github.event.pull_request.number }} | |
| uses: actions/checkout@v6 | |
| - name: Build | |
| run: swift build | |
| - name: Run tests | |
| env: | |
| CI_DISABLE_NETWORK_MONITOR: "1" | |
| # Skip test targets that use URLSession on Linux due to a | |
| # FoundationNetworking race condition that crashes during teardown. | |
| # See: https://github.com/swiftlang/swift-corelibs-foundation/issues/3675 | |
| run: | | |
| swift test --skip HubTests --skip TokenizersTests | |
| lint: | |
| name: Lint | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout PR merge ref if called from PR | |
| if: ${{ github.event.pull_request.number }} | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: refs/pull/${{ github.event.pull_request.number }}/merge | |
| fetch-depth: 0 | |
| - name: Checkout fallback | |
| if: ${{ !github.event.pull_request.number }} | |
| uses: actions/checkout@v6 | |
| - run: | | |
| swift format lint --strict --recursive . | |
| - name: Suggest fixes (if check fails) | |
| if: failure() | |
| run: | | |
| echo "### Here's how to fix the formatting locally:" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo '```bash' >> $GITHUB_STEP_SUMMARY | |
| echo "# Format all Swift files" >> $GITHUB_STEP_SUMMARY | |
| echo 'swift format -i --recursive .' >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY |