Skip to content

Commit

Permalink
Merge pull request #111 from weichsel/development
Browse files Browse the repository at this point in the history
Prepare 0.9.9 Release
  • Loading branch information
weichsel committed Apr 10, 2019
2 parents d9bb1c4 + 2d847ba commit edbeaa3
Show file tree
Hide file tree
Showing 31 changed files with 592 additions and 207 deletions.
165 changes: 165 additions & 0 deletions .github/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
trigger:
- master

jobs:
- job: Linux_Swift_5_0
pool:
vmImage: 'Ubuntu 16.04'
container: swift:5.0
steps:
- script: swift test -c release -Xswiftc -enable-testing
displayName: Linux Swift 5.0

- job: Linux_Swift_4_2
pool:
vmImage: 'Ubuntu 16.04'
container: swift:4.2
steps:
- script: swift test -c release -Xswiftc -enable-testing
displayName: Linux Swift 4.2

- job: Linux_Swift_4_1
pool:
vmImage: 'Ubuntu 16.04'
container: swift:4.1
steps:
- script: swift test -c release -Xswiftc -enable-testing
displayName: Linux Swift 4.1

- job: Linux_Swift_4_0
pool:
vmImage: 'Ubuntu 16.04'
container: swift:4.0
steps:
- script: swift test -c release -Xswiftc -enable-testing
displayName: Linux Swift 4.0

- job: macOS_10_13
pool:
vmImage: 'macOS 10.13'
variables:
DEVELOPER_DIR: /Applications/Xcode_10.1.app
steps:
- task: Xcode@5
inputs:
actions: 'test'
packageApp: false
exportMethod: 'development'
exportOptionsPlist: ''
configuration: 'Release'
scheme: 'ZIPFoundation'
sdk: 'macosx'
destinationPlatformOption: 'macOS'
useXcpretty: true
publishJUnitResults: true
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: build/reports/**
failTaskOnFailedTests: true

- job: iOS_12_1
pool:
vmImage: 'macOS 10.13'
variables:
DEVELOPER_DIR: /Applications/Xcode_10.1.app
steps:
- task: Xcode@5
inputs:
actions: 'test'
packageApp: false
exportMethod: 'development'
exportOptionsPlist: ''
configuration: 'Release'
scheme: 'ZIPFoundation'
sdk: 'iphonesimulator'
destinationPlatformOption: 'iOS'
destinationTypeOption: 'simulators'
destinationSimulators: 'iPhone X'
useXcpretty: true
publishJUnitResults: true
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: build/reports/**
failTaskOnFailedTests: true

- job: watchOS_5_1
pool:
vmImage: 'macOS 10.13'
variables:
DEVELOPER_DIR: /Applications/Xcode_10.1.app
steps:
# We currently only perform a build-only script for watchOS (xcodebuild test is unable to find the XCTest module)
- task: Xcode@5
inputs:
actions: 'build'
packageApp: false
exportMethod: 'development'
exportOptionsPlist: ''
configuration: 'Release'
scheme: 'ZIPFoundation'
sdk: 'watchsimulator'
destinationPlatformOption: 'custom'
destinationTypeOption: 'simulators'
destinationSimulators: 'Apple Watch Series 3 - 38mm'

- job: tvOS_12_1
pool:
vmImage: 'macOS 10.13'
variables:
DEVELOPER_DIR: /Applications/Xcode_10.1.app
steps:
- task: Xcode@5
inputs:
actions: 'test'
packageApp: false
exportMethod: 'development'
exportOptionsPlist: ''
configuration: 'Release'
scheme: 'ZIPFoundation'
sdk: 'appletvsimulator'
destinationPlatformOption: 'tvOS'
destinationTypeOption: 'simulators'
destinationSimulators: 'Apple TV 4K'
useXcpretty: true
publishJUnitResults: true
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: build/reports/**
failTaskOnFailedTests: true

- job: SwiftLint
pool:
vmImage: 'macOS 10.13'
variables:
DEVELOPER_DIR: /Applications/Xcode_10.1.app
steps:
- script: xcodebuild -scheme ZIPFoundation clean build-for-testing > xcodebuild.log
displayName: Generate xcodebuild.log
- script: HOMEBREW_NO_AUTO_UPDATE=1 brew install https://raw.github.com/Homebrew/homebrew-core/master/Formula/swiftlint.rb
displayName: Install SwiftLint
- script: |
set -o pipefail
mkdir -p build/reports/
swiftlint lint --reporter junit > build/reports/swiftlint.xml
displayName: SwiftLint
- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: build/reports/**
failTaskOnFailedTests: true
- script: swiftlint analyze --strict --compiler-log-path xcodebuild.log
displayName: SwiftLint Analyze

- job: CodeCoverage
pool:
vmImage: 'macOS 10.13'
variables:
DEVELOPER_DIR: /Applications/Xcode_10.1.app
steps:
- script: xcodebuild test -destination 'platform=macOS,arch=x86_64' -scheme "ZIPFoundation" -derivedDataPath Build/
displayName: Generate xccovreport
- script: (xcrun xccov view --only-targets Build/Logs/Test/*.xcresult/*_Test/action.xccovreport | grep -Eq "ZIPFoundation.*100\.00%") && { exit 0; } || { echo '##vso[task.logissue type=error;]Please make sure that the test suite covers all framework code paths.'; exit 1; }
displayName: Check for full line coverage
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [0.9.9](https://github.com/weichsel/ZIPFoundation/releases/tag/0.9.9)

### Added
- Swift 5.0 support
- Optional `preferredEncoding` parameter to explicitly configure an encoding for filepaths

### Updated
- Fixed a library load error related to dylib versioning
- Fixed a hang during read when decoding small, `.deflate` compressed entries
- Improved Linux support
- Improved test suite on non-Darwin platforms

## [0.9.8](https://github.com/weichsel/ZIPFoundation/releases/tag/0.9.8)

### Updated
Expand All @@ -9,7 +21,7 @@

### Added
- App extension support
- Optional `compressionMethod` paramter for `zipItem:`
- Optional `compressionMethod` parameter for `zipItem:`

### Updated
- Fixed a path traversal attack vulnerability
Expand Down
25 changes: 16 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
// swift-tools-version:4.0
// swift-tools-version:5.0
import PackageDescription

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
let dependencies: [Package.Dependency] = []
#if canImport(Compression)
let targets: [Target] = [
.target(name: "ZIPFoundation"),
.testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"])
]
#else
let dependencies: [Package.Dependency] = [.package(url: "https://github.com/IBM-Swift/CZlib.git", .exact("0.1.2"))]
let targets: [Target] = [
.systemLibrary(name: "CZLib", pkgConfig: "zlib", providers: [.brew(["zlib"]), .apt(["zlib"])]),
.target(name: "ZIPFoundation", dependencies: ["CZLib"]),
.testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"])
]
#endif

let package = Package(
name: "ZIPFoundation",
platforms: [
.macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2)
],
products: [
.library(name: "ZIPFoundation", targets: ["ZIPFoundation"])
],
dependencies: dependencies,
targets: [
.target(name: "ZIPFoundation"),
.testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"])
]
targets: targets,
swiftLanguageVersions: [.v4, .v4_2, .v5]
)
20 changes: 20 additions & 0 deletions Package@swift-4.0.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// swift-tools-version:4.0
import PackageDescription

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
let dependencies: [Package.Dependency] = []
#else
let dependencies: [Package.Dependency] = [.package(url: "https://github.com/IBM-Swift/CZlib.git", .exact("0.1.2"))]
#endif

let package = Package(
name: "ZIPFoundation",
products: [
.library(name: "ZIPFoundation", targets: ["ZIPFoundation"])
],
dependencies: dependencies,
targets: [
.target(name: "ZIPFoundation"),
.testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"])
]
)
20 changes: 20 additions & 0 deletions Package@swift-4.1.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// swift-tools-version:4.1
import PackageDescription

#if canImport(Compression)
let dependencies: [Package.Dependency] = []
#else
let dependencies: [Package.Dependency] = [.package(url: "https://github.com/IBM-Swift/CZlib.git", .exact("0.1.2"))]
#endif

let package = Package(
name: "ZIPFoundation",
products: [
.library(name: "ZIPFoundation", targets: ["ZIPFoundation"])
],
dependencies: dependencies,
targets: [
.target(name: "ZIPFoundation"),
.testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"])
]
)
21 changes: 21 additions & 0 deletions Package@swift-4.2.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// swift-tools-version:4.2
import PackageDescription

#if canImport(Compression)
let dependencies: [Package.Dependency] = []
#else
let dependencies: [Package.Dependency] = [.package(url: "https://github.com/IBM-Swift/CZlib.git", .exact("0.1.2"))]
#endif

let package = Package(
name: "ZIPFoundation",
products: [
.library(name: "ZIPFoundation", targets: ["ZIPFoundation"])
],
dependencies: dependencies,
targets: [
.target(name: "ZIPFoundation"),
.testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"])
],
swiftLanguageVersions: [.v4, .v4_2]
)
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,17 @@ To learn more about the performance characteristics of the framework, you can re

- iOS 9.0+ / macOS 10.11+ / tvOS 9.0+ / watchOS 2.0+
- Or Linux with zlib development package
- Xcode 9.0
- Xcode 10.0
- Swift 4.0

## Installation

### Swift Package Manager
Swift Package Manager is a dependency manager currently under active development. To learn how to use the Swift Package Manager for your project, please read the [official documentation](https://github.com/apple/swift-package-manager/blob/master/Documentation/Usage.md).
The ZIP Foundation package uses the [V4 Package Description API](https://github.com/apple/swift-package-manager/blob/master/Documentation/PackageDescriptionV4.md).
To add ZIP Foundation as a dependency, you have to add it to the `dependencies` of your `Package.swift` file and refer to that dependency in your `target`.

```swift
// swift-tools-version:4.0
// swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "<Your Product Name>",
Expand Down
15 changes: 15 additions & 0 deletions Sources/CZLib/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// module.modulemap
// ZIPFoundation
//
// Copyright © 2017-2019 Thomas Zoechling, https://www.peakstep.com and the ZIP Foundation project authors.
// Released under the MIT License.
//
// See https://github.com/weichsel/ZIPFoundation/blob/master/LICENSE for license information.
//

module CZlib {
header "shim.h"
link "z"
export *
}
17 changes: 17 additions & 0 deletions Sources/CZLib/shim.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// shim.h
// ZIPFoundation
//
// Copyright © 2017-2019 Thomas Zoechling, https://www.peakstep.com and the ZIP Foundation project authors.
// Released under the MIT License.
//
// See https://github.com/weichsel/ZIPFoundation/blob/master/LICENSE for license information.
//

#ifndef zlib_shim_h
#define zlib_shim_h

#import <stdio.h>
#import <zlib.h>

#endif
10 changes: 5 additions & 5 deletions Sources/ZIPFoundation/Archive+Reading.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ extension Archive {
switch entry.type {
case .file:
guard !fileManager.fileExists(atPath: url.path) else {
throw CocoaError.error(.fileWriteFileExists, userInfo: [NSFilePathErrorKey: url.path], url: nil)
throw CocoaError(.fileWriteFileExists, userInfo: [NSFilePathErrorKey: url.path])
}
try fileManager.createParentDirectoryStructure(for: url)
let destinationRepresentation = fileManager.fileSystemRepresentation(withPath: url.path)
guard let destinationFile: UnsafeMutablePointer<FILE> = fopen(destinationRepresentation, "wb+") else {
throw CocoaError.error(.fileNoSuchFile)
throw CocoaError(.fileNoSuchFile)
}
defer { fclose(destinationFile) }
let consumer = { _ = try Data.write(chunk: $0, to: destinationFile) }
Expand All @@ -44,7 +44,7 @@ extension Archive {
checksum = try self.extract(entry, bufferSize: bufferSize, progress: progress, consumer: consumer)
case .symlink:
guard !fileManager.fileExists(atPath: url.path) else {
throw CocoaError.error(.fileWriteFileExists, userInfo: [NSFilePathErrorKey: url.path], url: nil)
throw CocoaError(.fileWriteFileExists, userInfo: [NSFilePathErrorKey: url.path])
}
let consumer = { (data: Data) in
guard let linkPath = String(data: data, encoding: .utf8) else { throw ArchiveError.invalidEntryPath }
Expand Down Expand Up @@ -104,9 +104,9 @@ extension Archive {
progress: Progress? = nil, with consumer: Consumer) throws -> CRC32 {
let size = Int(entry.centralDirectoryStructure.uncompressedSize)
return try Data.consumePart(of: size, chunkSize: Int(bufferSize), provider: { (_, chunkSize) -> Data in
if progress?.isCancelled == true { throw ArchiveError.cancelledOperation }
return try Data.readChunk(of: Int(chunkSize), from: self.archiveFile)
}, consumer: { (data) in
if progress?.isCancelled == true { throw ArchiveError.cancelledOperation }
try consumer(data)
progress?.completedUnitCount += Int64(data.count)
})
Expand All @@ -116,9 +116,9 @@ extension Archive {
progress: Progress? = nil, with consumer: Consumer) throws -> CRC32 {
let size = Int(entry.centralDirectoryStructure.compressedSize)
return try Data.decompress(size: size, bufferSize: Int(bufferSize), provider: { (_, chunkSize) -> Data in
if progress?.isCancelled == true { throw ArchiveError.cancelledOperation }
return try Data.readChunk(of: chunkSize, from: self.archiveFile)
}, consumer: { (data) in
if progress?.isCancelled == true { throw ArchiveError.cancelledOperation }
try consumer(data)
progress?.completedUnitCount += Int64(data.count)
})
Expand Down

0 comments on commit edbeaa3

Please sign in to comment.