Skip to content

Commit

Permalink
fix: update swift version to 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
飞澋 authored and JacksonTian committed May 14, 2024
1 parent 615dfd7 commit 9fde4a3
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 45 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Swift

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
defaults:
run:
shell: bash
working-directory: swift

jobs:
build-ubuntu-latest:
name: Swift ${{ matrix.swift }} on ubuntu-latest
strategy:
matrix:
# ubuntu swift5.6及以下版本下载会报gpg签名错误,已知bug等官方解决
swift: ["5.7", "5.8", "5.9", "5.10"]
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v4
- name: Build
run: swift build -v
- name: Run tests
run: swift test -v

build-macos-latest:
name: Swift ${{ matrix.swift }} on macos-latest
strategy:
matrix:
swift: ["5.9", "5.10"]
fail-fast: false
runs-on: macos-latest
steps:
- uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v4
- name: Verify Xcode Version
run: xcodebuild -version
- name: Build
run: swift build -v
- name: Run tests
run: swift test -v

build-macos-11:
name: Swift ${{ matrix.swift }} on macos-11
strategy:
matrix:
swift: ["5.6", "5.7", "5.8"]
fail-fast: false
runs-on: macos-11
steps:
- uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v4
- name: Build
run: swift build -v
- name: Run tests
run: swift test -v
20 changes: 15 additions & 5 deletions swift/Package.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
// swift-tools-version:5.1
// swift-tools-version:5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "TeaFileForm",
platforms: [.macOS(.v10_15),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6)],
products: [
.library(
name: "TeaFileForm",
targets: ["TeaFileForm"])
],
dependencies: [
.package(url: "https://github.com/aliyun/tea-swift.git", from: "0.3.0")
.package(url: "https://github.com/aliyun/tea-swift.git", from: "1.0.0"),
],
targets: [
.target(
name: "TeaFileForm",
dependencies: ["Tea"]),
dependencies: [
.product(name: "Tea", package: "tea-swift")
]),
.testTarget(
name: "TeaFileFormTests",
dependencies: ["TeaFileForm", "Tea"]),
]
dependencies: [
"TeaFileForm",
.product(name: "Tea", package: "tea-swift")
]),
],
swiftLanguageVersions: [.v5]
)
18 changes: 4 additions & 14 deletions swift/Sources/TeaFileForm/TeaFileForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,30 +123,20 @@ public class TeaFileForm {
}

public class FileField: TeaModel {
@objc public var filename: String?
@objc public var contentType: String?
@objc public var content: Data?
public var filename: String?
public var contentType: String?
public var content: Data?

public override init() {
super.init()
self.__name = [
"filename": "filename",
"contentType": "contentType",
"content": "content"
];
self.__required = [
"filename": true,
"contentType": true,
"content": true
]
}
}

extension String {
static func randomString(len: Int, randomDict: String = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") -> String {
var ranStr = ""
for _ in 0..<len {
let index = Int(arc4random_uniform(UInt32(randomDict.count)))
let index = Int.random(in: 0..<randomDict.count)
ranStr.append(randomDict[randomDict.index(randomDict.startIndex, offsetBy: index)])
}
return ranStr
Expand Down
12 changes: 6 additions & 6 deletions swift/TeaFileForm.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Pod::Spec.new do |spec|

spec.ios.framework = 'Foundation'

spec.ios.deployment_target = '8.0'
spec.osx.deployment_target = '10.11'
spec.watchos.deployment_target = '2.0'
spec.tvos.deployment_target = '9.0'
spec.ios.deployment_target = '13.0'
spec.osx.deployment_target = '10.15'
spec.watchos.deployment_target = '6.0'
spec.tvos.deployment_target = '13.0'

spec.dependency 'Tea', '~> 0.3.0'
spec.swift_version = '5.1'
spec.dependency 'Tea', '~> 1.0.0'

spec.swift_version='5.6'
end
7 changes: 0 additions & 7 deletions swift/Tests/LinuxMain.swift

This file was deleted.

4 changes: 0 additions & 4 deletions swift/Tests/TeaFileFormTests/TeaFileFormTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ final class TeaFileFormTests: XCTestCase {
let target: String = "--testBoundary\r\nContent-Disposition: form-data; name=\"haveFile\"; filename=haveContent\r\nContent-Type: contentType\r\n\r\nThis is file test. This sentence must be long\r\n--testBoundary\r\nContent-Disposition: form-data; name=\"key\"\r\n\r\nvalue\r\n\r\n\r\n\r\n--testBoundary\r\nContent-Disposition: form-data; name=\"testKey\"\r\n\r\ntestValue\r\n\r\n\r\n--testBoundary--\r\n"
XCTAssertEqual(target, result)
}

static var allTests = [
("testFileFromStream", testFileFromStream)
]
}

class TestObject {
Expand Down
9 changes: 0 additions & 9 deletions swift/Tests/TeaFileFormTests/XCTestManifests.swift

This file was deleted.

0 comments on commit 9fde4a3

Please sign in to comment.