diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0e5e3cd --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,71 @@ +name: Tests + +on: + push: + branches: [ main ] + paths-ignore: [ README.md ] + pull_request: + branches: [ main ] + paths-ignore: [ README.md ] + workflow_dispatch: + +jobs: + formatlint: + name: Format linting + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Pull formatting docker image + run: docker pull ghcr.io/nicklockwood/swiftformat:latest + - name: Run format linting + run: docker run --rm -v ${{ github.workspace }}:/repo ghcr.io/nicklockwood/swiftformat:latest /repo --lint + + macos: + name: Test on macOS + runs-on: macOS-latest + steps: + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + - uses: actions/checkout@v3 + - name: Build and test + run: swift test --parallel --enable-test-discovery + + linux: + name: Test on Linux + runs-on: ubuntu-latest + steps: + - uses: swift-actions/setup-swift@v2 + - uses: actions/checkout@v3 + - name: Test + run: swift test --parallel --enable-code-coverage + - name: Get test coverage html + run: | + llvm-cov show \ + $(swift build --show-bin-path)/DataLoaderPackageTests.xctest \ + --instr-profile $(swift build --show-bin-path)/codecov/default.profdata \ + --ignore-filename-regex="\.build|Tests" \ + --format html \ + --output-dir=.test-coverage + - name: Upload test coverage html + uses: actions/upload-artifact@v3 + with: + name: test-coverage-report + path: .test-coverage + + backcompat-ubuntu-22_04: + name: Test Swift ${{ matrix.swift }} on Ubuntu 22.04 + runs-on: ubuntu-22.04 + strategy: + matrix: + swift: ["5.7", "5.8", "5.9", "5.10"] + steps: + - uses: swift-actions/setup-swift@v2 + with: + swift-version: ${{ matrix.swift }} + - uses: actions/checkout@v3 + - name: Test + run: swift test --parallel \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 148e958..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Test - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] -jobs: - formatlint: - name: Format linting - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Pull formatting docker image - run: docker pull ghcr.io/nicklockwood/swiftformat:latest - - name: Run format linting - run: docker run --rm -v ${{ github.workspace }}:/repo ghcr.io/nicklockwood/swiftformat:latest /repo --lint - macos-build: - name: Build and test on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-latest] - steps: - - uses: actions/checkout@v2 - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - name: Build - run: swift build - - name: Run tests - run: swift test - - # ubuntu-latest is ubuntu-22.04 currently. Swift versions older than 5.7 don't have builds for 22.04. https://www.swift.org/download/ - ubuntu-old: - name: Build ${{ matrix.swift }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04] - swift: ["5.4", "5.5", "5.6"] - steps: - - uses: swift-actions/setup-swift@v1 - with: - swift-version: ${{ matrix.swift }} - - uses: actions/checkout@v3 - - name: Test - run: swift test - - ubuntu-latest: - name: Build ${{ matrix.swift }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - swift: ["5.7"] - steps: - - uses: swift-actions/setup-swift@v1 - with: - swift-version: ${{ matrix.swift }} - - uses: actions/checkout@v3 - - name: Test - run: swift test - diff --git a/.gitignore b/.gitignore index 7674fe7..29cc641 100644 --- a/.gitignore +++ b/.gitignore @@ -87,4 +87,7 @@ fastlane/test_output # After new code Injection tools there's a generated folder /iOSInjectionProject # https://github.com/johnno1962/injectionforxcode -iOSInjectionProject/ \ No newline at end of file +iOSInjectionProject/ + +# VS Code +.vscode/ diff --git a/Tests/DataLoaderTests/DataLoaderAbuseTests.swift b/Tests/DataLoaderTests/DataLoaderAbuseTests.swift index 04203fe..f99e0e3 100644 --- a/Tests/DataLoaderTests/DataLoaderAbuseTests.swift +++ b/Tests/DataLoaderTests/DataLoaderAbuseTests.swift @@ -19,7 +19,10 @@ class DataLoaderAbuseTests: XCTestCase { let value = try identityLoader.load(key: 1, on: eventLoopGroup) - XCTAssertThrowsError(try value.wait(), "Did not return value for key: 1") + XCTAssertThrowsError( + try value.wait(), + "Did not return value for key: 1" + ) } func testBatchFuntionMustPromiseAnArrayOfCorrectLength() throws { @@ -53,7 +56,9 @@ class DataLoaderAbuseTests: XCTestCase { if key == 1 { results.append(DataLoaderFutureValue.success(key)) } else { - results.append(DataLoaderFutureValue.failure("Test error")) + results.append( + DataLoaderFutureValue.failure(DataLoaderError.typeError("Test error")) + ) } } @@ -83,7 +88,9 @@ class DataLoaderAbuseTests: XCTestCase { if key == 1 { results.append(DataLoaderFutureValue.success(key)) } else { - results.append(DataLoaderFutureValue.failure("Test error")) + results.append( + DataLoaderFutureValue.failure(DataLoaderError.typeError("Test error")) + ) } } @@ -98,5 +105,3 @@ class DataLoaderAbuseTests: XCTestCase { XCTAssertTrue(try value1.wait() == 1) } } - -extension String: Error {}