diff --git a/.github/workflows/Coverage.yml b/.github/workflows/Coverage.yml index 014f242..2dc8bb3 100644 --- a/.github/workflows/Coverage.yml +++ b/.github/workflows/Coverage.yml @@ -3,7 +3,7 @@ name: Coverage on: push: branches: - - master + - main jobs: coverage: @@ -20,6 +20,5 @@ jobs: run: xcrun llvm-cov export -format="lcov" .build/debug/HwpKitPackageTests.xctest/Contents/MacOS/HwpKitPackageTests -instr-profile .build/debug/codecov/default.profdata > info.lcov - name: Upload to Codecov run: bash <(curl https://codecov.io/bash) - env: + env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml index 6fe3b7c..e79ef37 100644 --- a/.github/workflows/Documentation.yml +++ b/.github/workflows/Documentation.yml @@ -3,7 +3,7 @@ name: Documentation on: push: branches: - - master + - main jobs: documentation: diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml index b342044..d8c9f5b 100644 --- a/.github/workflows/Lint.yml +++ b/.github/workflows/Lint.yml @@ -1,6 +1,12 @@ name: Lint -on: [ push, pull_request ] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: lint: diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index 1e9ed47..2ef27ef 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -1,22 +1,29 @@ name: Test -on: [ push, pull_request ] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: test: - name: Test on ${{ matrix.os }} and swift ${{ matrix.swift }} - runs-on: ${{ matrix.os }} + name: Test on Xcode ${{ matrix.xcode }} + runs-on: macos-latest strategy: matrix: - os: [macOS-latest] - swift: ["5.1", "5.2"] + xcode: ["11.7", "11.3.1"] steps: - uses: actions/checkout@v2 - - name: Setup Swift - uses: fwal/setup-swift@v1.2.0 - with: - swift-version: ${{ matrix.swift }} + - name: Set Xcode version + run: | + sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/ + export TOOLCHAINS=swift + - name: Get Swift version + run: swift --version - name: Build run: swift build -v - name: Run tests diff --git a/README.md b/README.md index d30ddf5..fa886e5 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,6 @@ ![Coverage](https://github.com/sboh1214/HwpKit/workflows/Coverage/badge.svg) ![Documentation](https://github.com/sboh1214/HwpKit/workflows/Documentation/badge.svg) ![Lint](https://github.com/sboh1214/HwpKit/workflows/Lint/badge.svg) -[![codecov](https://codecov.io/gh/sboh1214/HwpKit/branch/master/graph/badge.svg)](https://codecov.io/gh/sboh1214/HwpKit) - -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=sboh1214_HwpKit&metric=alert_status)](https://sonarcloud.io/dashboard?id=sboh1214_HwpKit) -[![CodeFactor](https://www.codefactor.io/repository/github/sboh1214/hwpkit/badge)](https://www.codefactor.io/repository/github/sboh1214/hwpkit) Swift Package for Reading & Writing HWP File @@ -17,6 +13,40 @@ Swift Package for Reading & Writing HWP File ### Swift Package Manager +Go to ```File``` > ```Swift Packages``` > ```Add Package Dependency...``` in Xcode. + +Or add dependency manually. +```swift +dependencies: [ + .package(url: "https://github.com/sboh1214/HwpKit.git", .branch("main")), +], +``` + +## Contribute + +[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=sboh1214_HwpKit&metric=ncloc)](https://sonarcloud.io/dashboard?id=sboh1214_HwpKit) + +### Code Quality + +[![codecov](https://codecov.io/gh/sboh1214/HwpKit/branch/master/graph/badge.svg)](https://codecov.io/gh/sboh1214/HwpKit) +[![CodeFactor](https://www.codefactor.io/repository/github/sboh1214/hwpkit/badge)](https://www.codefactor.io/repository/github/sboh1214/hwpkit) + +[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=sboh1214_HwpKit&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=sboh1214_HwpKit) +[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=sboh1214_HwpKit&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=sboh1214_HwpKit) +[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=sboh1214_HwpKit&metric=security_rating)](https://sonarcloud.io/dashboard?id=sboh1214_HwpKit) + + + +### Test on Linux + +Currently, this project does not support Linux due to dependency [DataCompression](https://github.com/mw99/DataCompression). +You should install [Sourcery](https://github.com/krzysztofzablocki/Sourcery) to create LinuxMain.swift and test. + +```bash +$ sourcery --sources Tests --templates Tests/LinuxMain.stencil +$ swift test +``` + ## License ![GitHub](https://img.shields.io/github/license/sboh1214/HwpKit) diff --git a/Tests/HwpKitTests/Blank/BlankTests.swift b/Tests/HwpKitTests/Blank/BlankTests.swift index dbaa354..134d9a0 100644 --- a/Tests/HwpKitTests/Blank/BlankTests.swift +++ b/Tests/HwpKitTests/Blank/BlankTests.swift @@ -31,11 +31,4 @@ final class BlankTests: XCTestCase { let hwp = try openHwp() XCTAssertEqual(hwp.fileHeader.encryptVersion, 4) } - - static var allTests = [ - ("testOpen", testOpen), - ("testSignature", testSignature), - ("testHwpVersion", testHwpVersion), - ("testEncryptVersion", testEncryptVersion) - ] } diff --git a/Tests/HwpKitTests/HwpUtilTests.swift b/Tests/HwpKitTests/HwpUtilTests.swift index 3e321f8..8ca83cc 100644 --- a/Tests/HwpKitTests/HwpUtilTests.swift +++ b/Tests/HwpKitTests/HwpUtilTests.swift @@ -7,8 +7,4 @@ final class HwpUtilTests: XCTestCase { let bits = [false, true, false, false, true, false, true, false].reversed() as [Bool] XCTAssertEqual(bits, byte.bits) } - - static var allTests = [ - ("testBitsFromInt8", testBitsFromInt8) - ] } diff --git a/Tests/HwpKitTests/Noori/NooriDocInfoTests.swift b/Tests/HwpKitTests/Noori/NooriDocInfoTests.swift index 338426a..39249e8 100644 --- a/Tests/HwpKitTests/Noori/NooriDocInfoTests.swift +++ b/Tests/HwpKitTests/Noori/NooriDocInfoTests.swift @@ -93,16 +93,4 @@ final class NooriDocInfoTests: XCTestCase { let hwp = try openHwp() XCTAssertEqual(hwp.sectionArray[0].paragraph[2].ctrlHeaderArray![0].ctrlId, 1885826672) } - - static var allTests = [ - ("testSectionSize", testSectionSize), - ("testStartingIndex", testStartingIndex), - ("testCaratLocation", testCaratLocation), - ("testBinData", testBinData), - ("testFaceName", testFaceName), - ("testBorderFill", testBorderFill), - ("testCharShape", testCharShape), - ("testTabDef", testTabDef), - ("testCtrlHeader", testCtrlHeader) - ] } diff --git a/Tests/HwpKitTests/Noori/NooriSectionTests.swift b/Tests/HwpKitTests/Noori/NooriSectionTests.swift index 820a3fb..19b2257 100644 --- a/Tests/HwpKitTests/Noori/NooriSectionTests.swift +++ b/Tests/HwpKitTests/Noori/NooriSectionTests.swift @@ -53,11 +53,4 @@ final class NooriSectionTests: XCTestCase { XCTAssertNotNil(hwp.sectionArray[0].paragraph[20].paraLineSegArray![0]) } - - static var allTests = [ - ("testParagraph", testParagraph), - ("testParaText", testParaText), - ("testParaCharShape", testParaCharShape), - ("testParaLineSeg", testParaLineSeg) - ] } diff --git a/Tests/HwpKitTests/XCTestManifests.swift b/Tests/HwpKitTests/XCTestManifests.swift deleted file mode 100644 index 22834bb..0000000 --- a/Tests/HwpKitTests/XCTestManifests.swift +++ /dev/null @@ -1,13 +0,0 @@ -import XCTest - -#if !canImport(ObjectiveC) - public func allTests() -> [XCTestCaseEntry] { - [ - testCase(BasicTests.allTests), - testCase(NooriDocInfoTests.allTests), - testCase(NooriSectionTests.allTests), - testCase(VersionTests.allTests), - testCase(HwpUtilTests.allTests) - ] - } -#endif diff --git a/Tests/LinuxMain.stencil b/Tests/LinuxMain.stencil new file mode 100644 index 0000000..bd960be --- /dev/null +++ b/Tests/LinuxMain.stencil @@ -0,0 +1,16 @@ +import XCTest +import HwpKitTests + +{% for type in types.classes|based:"XCTestCase" %} +{% if not type.annotations.disableTests %}extension {{ type.name }} { + static var allTests: [(String, ({{ type.name }}) -> () throws -> Void)] = [ + {% for method in type.methods %}{% if method.parameters.count == 0 and method.shortName|hasPrefix:"test" %} ("{{ method.shortName }}", {{ method.shortName }}){{ ',' if not forloop.last }} + {% endif %}{% endfor %}] +} +{% endif %}{% endfor %} + +// swiftlint:disable trailing_comma +XCTMain([ +{% for type in types.classes|based:"XCTestCase" %}{% if not type.annotations.disableTests %} testCase({{ type.name }}.allTests), +{% endif %}{% endfor %}]) +// swiftlint:enable trailing_comma diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100644 index 521339c..0000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,6 +0,0 @@ -import XCTest -import HwpKitTests - -var tests = [XCTestCaseEntry]() -tests += HwpKitTests.allTests() -XCTMain(tests)