Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify swift version action and add swift 6 #10

Merged
merged 4 commits into from
Oct 27, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/swift-build-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
name: Swift-build-testing

on:
push:
branches: ["*"]
pull_request:
branches: [ "main" ]

Expand All @@ -15,12 +13,14 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
swift: ["5"]
swift: ["6.0", "5.9"]
runs-on: ${{ matrix.os }}
steps:
- uses: swift-actions/setup-swift@v2
- uses: SwiftyLab/setup-swift@latest
with:
swift-version: ${{ matrix.swift }}
swift-version: ${{ matrix.swift }}
Comment on lines +19 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

建议固定 Action 版本号

使用 @latest 标签可能导致工作流在 Action 更新时意外失败。建议:

将 Action 版本固定到特定版本号:

-      - uses: SwiftyLab/setup-swift@latest
+      - uses: SwiftyLab/setup-swift@v1
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: SwiftyLab/setup-swift@latest
with:
swift-version: ${{ matrix.swift }}
swift-version: ${{ matrix.swift }}
- uses: SwiftyLab/setup-swift@v1
with:
swift-version: ${{ matrix.swift }}

- name: Get swift version
run: swift --version
Comment on lines +22 to +23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

版本检查步骤可以优化

显示 Swift 版本是个好的做法,但建议增加版本验证逻辑,确保安装的版本符合预期。

建议修改为:

       - name: Get swift version
-        run: swift --version
+        run: |
+          SWIFT_VERSION=$(swift --version | grep -o 'Swift version [0-9.]*' | cut -d' ' -f3)
+          echo "Installed Swift version: $SWIFT_VERSION"
+          if [ "$SWIFT_VERSION" != "${{ matrix.swift }}" ]; then
+            echo "::error::Expected Swift ${{ matrix.swift }} but got $SWIFT_VERSION"
+            exit 1
+          fi

Committable suggestion was skipped due to low confidence.

- uses: actions/checkout@v4
- name: Run tests
run: swift test -v --enable-code-coverage
Expand Down
Loading