Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ run:

test: xcbeautify
set -o pipefail \
&& swift test --disable-automatic-resolution --sanitize=thread \
&& swift test --disable-automatic-resolution --sanitize=thread --parallel \
2>&1 | ./xcbeautify --renderer github-actions

test-query-performance: xcbeautify
Expand All @@ -50,7 +50,7 @@ test-query-performance: xcbeautify
test-fast:
@echo Skipping image snapshot tests
@echo Running without --sanitize=thread
swift test --disable-automatic-resolution
swift test --disable-automatic-resolution --parallel

xcbeautify:
rm -rf .build/checkouts/xcbeautify
Expand Down
4 changes: 2 additions & 2 deletions Sources/App/configure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Vapor


@discardableResult
public func configure(_ app: Application) async throws -> String {
public func configure(_ app: Application, databasePort: Int? = nil) async throws -> String {
#if DEBUG && os(macOS)
// The bundle is only loaded if /Applications/InjectionIII.app exists on the local development machine.
// Requires InjectionIII 4.7.3 or higher to be loaded for compatibility with Package.swift files.
Expand Down Expand Up @@ -55,7 +55,7 @@ public func configure(_ app: Application) async throws -> String {
// Setup database connection
guard
let host = Environment.get("DATABASE_HOST"),
let port = Environment.get("DATABASE_PORT").flatMap(Int.init),
let port = databasePort ?? Environment.get("DATABASE_PORT").flatMap(Int.init),
let username = Environment.get("DATABASE_USERNAME"),
let password = Environment.get("DATABASE_PASSWORD"),
let database = Environment.get("DATABASE_NAME")
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/API+PackageController+GetRouteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import XCTest


class API_PackageController_GetRouteTests: AppTestCase {
class API_PackageController_GetRouteTests: ParallelizedAppTestCase {

typealias PackageResult = PackageController.PackageResult

Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/API+PackageControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Dependencies
import Vapor


class API_PackageControllerTests: AppTestCase {
class API_PackageControllerTests: ParallelizedAppTestCase {

typealias BuildDetails = (reference: Reference, platform: Build.Platform, swiftVersion: SwiftVersion, status: Build.Status)

Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/API_DependencyControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import XCTVapor


final class API_DependencyControllerTests: AppTestCase {
final class API_DependencyControllerTests: ParallelizedAppTestCase {

func test_query() async throws {
// setup
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/AnalyzeErrorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import ShellOut
//
// We analyze two packages where the first package is set up to encounter
// various error states and ensure the second package is successfully processed.
final class AnalyzeErrorTests: AppTestCase {
final class AnalyzeErrorTests: ParallelizedAppTestCase {

let badPackageID: Package.Id = .id0
let goodPackageID: Package.Id = .id1
Expand Down
4 changes: 2 additions & 2 deletions Tests/AppTests/AnalyzerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Vapor
@preconcurrency import ShellOut


class AnalyzerTests: AppTestCase {
class AnalyzerTests: ParallelizedAppTestCase {

@MainActor
func test_analyze() async throws {
Expand Down Expand Up @@ -1569,7 +1569,7 @@ class AnalyzerTests: AppTestCase {
}
}
}
}
}

}

Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/AnalyzerVersionThrottlingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import XCTest
import Dependencies


class AnalyzerVersionThrottlingTests: AppTestCase {
class AnalyzerVersionThrottlingTests: ParallelizedAppTestCase {

func test_throttle_keep_old() async throws {
// Test keeping old when within throttling window
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/ApiTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import SnapshotTesting
import XCTVapor


class ApiTests: AppTestCase {
class ApiTests: ParallelizedAppTestCase {

func test_version() throws {
try app.test(.GET, "api/version", afterResponse: { res in
Expand Down
4 changes: 2 additions & 2 deletions Tests/AppTests/AppTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class AppTestCase: XCTestCase {

extension AppTestCase {

static func setupApp(_ environment: Environment) async throws -> Application {
static func setupApp(_ environment: Environment, databasePort: Int? = nil) async throws -> Application {
let app = try await Application.make(environment)
try await configure(app)
try await configure(app, databasePort: databasePort)

// Silence app logging
app.logger = .init(label: "noop") { _ in SwiftLogNoOpLogHandler() }
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/AppTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Vapor
import XCTest


class AppTests: AppTestCase {
class AppTests: ParallelizedAppTestCase {

func test_migrations() async throws {
try await XCTAssertNoThrowAsync(try await app.autoRevert())
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/ArrayVersionExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import XCTest
import SemanticVersion
import SPIManifest

class ArrayVersionExtensionTests: AppTestCase {
class ArrayVersionExtensionTests: ParallelizedAppTestCase {

func test_Array_canonicalDocumentationTarget() async throws {
let pkg = try await savePackage(on: app.db, "1".url)
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/AuthorControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Dependencies
import Vapor


class AuthorControllerTests: AppTestCase {
class AuthorControllerTests: ParallelizedAppTestCase {

func test_query() async throws {
// setup
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/BadgeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import XCTest


class BadgeTests: AppTestCase {
class BadgeTests: ParallelizedAppTestCase {

func test_badgeMessage_swiftVersions() throws {
XCTAssertEqual(Badge.badgeMessage(swiftVersions: [.v1, .v2, .v3, .v4]), "6.0 | 5.10 | 5.9 | 5.8")
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/BlogActionsModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import XCTest
import Dependencies


class BlogActionsModelTests: AppTestCase {
class BlogActionsModelTests: ParallelizedAppTestCase {

func test_init_loadSummaries() async throws {
try withDependencies {
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/BuildIndexModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Plot
import XCTVapor


class BuildIndexModelTests: AppTestCase {
class BuildIndexModelTests: ParallelizedAppTestCase {

func test_init_no_name() async throws {
// Tests behaviour when we're lacking data
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/BuildMonitorControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Dependencies
import Vapor


class BuildMonitorControllerTests: AppTestCase {
class BuildMonitorControllerTests: ParallelizedAppTestCase {

func test_show_owner() async throws {
try await withDependencies {
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/BuildMonitorIndexModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import Plot
import XCTVapor

class BuildMonitorIndexModelTests: AppTestCase {
class BuildMonitorIndexModelTests: ParallelizedAppTestCase {

func test_init_from_Build() async throws {
do {
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/BuildResultTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import XCTVapor


class BuildResultTests: AppTestCase {
class BuildResultTests: ParallelizedAppTestCase {

func test_query() async throws {
// setup
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/BuildShowModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import XCTVapor


class BuildShowModelTests: AppTestCase {
class BuildShowModelTests: ParallelizedAppTestCase {

typealias Model = BuildShow.Model

Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/BuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import SQLKit
import XCTVapor


class BuildTests: AppTestCase {
class BuildTests: ParallelizedAppTestCase {

func test_save() async throws {
// setup
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/BuildTriggerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import SQLKit
import Vapor


class BuildTriggerTests: AppTestCase {
class BuildTriggerTests: ParallelizedAppTestCase {

func test_BuildTriggerInfo_emptyPair() throws {
XCTAssertNotNil(BuildTriggerInfo(versionId: .id0, buildPairs: Set([BuildPair(.iOS, .v1)])))
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/CustomCollectionControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Fluent
import Vapor


class CustomCollectionControllerTests: AppTestCase {
class CustomCollectionControllerTests: ParallelizedAppTestCase {

func test_query() async throws {
// setup
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/CustomCollectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import XCTest
import Dependencies


class CustomCollectionTests: AppTestCase {
class CustomCollectionTests: ParallelizedAppTestCase {

func test_CustomCollection_save() async throws {
// MUT
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/DocUploadTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import PostgresKit
import XCTVapor


final class DocUploadTests: AppTestCase {
final class DocUploadTests: ParallelizedAppTestCase {

func test_attach() async throws {
// setup
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/DocumentationPageProcessorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import InlineSnapshotTesting
import SwiftSoup


final class DocumentationPageProcessorTests: AppTestCase {
final class DocumentationPageProcessorTests: ParallelizedAppTestCase {

func test_header_linkTitle() throws {
// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/2249
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/DocumentationTargetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import XCTest


final class DocumentationTargetTests: AppTestCase {
final class DocumentationTargetTests: ParallelizedAppTestCase {

func test_external() async throws {
// Test external doc url lookup
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/ErrorMiddlewareTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Dependencies
import Vapor


class ErrorMiddlewareTests: AppTestCase {
class ErrorMiddlewareTests: ParallelizedAppTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/ErrorPageModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import XCTVapor

class ErrorPageModelTests: AppTestCase {
class ErrorPageModelTests: ParallelizedAppTestCase {

func test_500() throws {
// setup
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/ErrorReportingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Dependencies
import XCTVapor


class ErrorReportingTests: AppTestCase {
class ErrorReportingTests: ParallelizedAppTestCase {

func test_Analyze_recordError() async throws {
let pkg = try await savePackage(on: app.db, "1")
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/GithubTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import SwiftSoup
import Vapor


class GithubTests: AppTestCase {
class GithubTests: ParallelizedAppTestCase {

func test_parseOwnerName() throws {
do {
Expand Down
4 changes: 2 additions & 2 deletions Tests/AppTests/GitlabBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Dependencies
import Vapor


class GitlabBuilderTests: AppTestCase {
class GitlabBuilderTests: ParallelizedAppTestCase {

func test_SwiftVersion_rendering() throws {
XCTAssertEqual("\(SwiftVersion.v4)", "6.0.0")
Expand Down Expand Up @@ -162,7 +162,7 @@ class GitlabBuilderTests: AppTestCase {
}


class LiveGitlabBuilderTests: AppTestCase {
class LiveGitlabBuilderTests: ParallelizedAppTestCase {

func test_triggerBuild_live() async throws {
try XCTSkipIf(
Expand Down
40 changes: 40 additions & 0 deletions Tests/AppTests/Helpers/ShellOutCommand+ext.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright Dave Verwer, Sven A. Schmidt, and other contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation

import ShellOut


extension ShellOutCommand {
static func launchDB(id: UUID, port: Int) -> ShellOutCommand {
.init(command: "docker", arguments: [
"run", "--name", "spi_test_\(id)",
"-e", "POSTGRES_DB=spi_test",
"-e", "POSTGRES_USER=spi_test",
"-e", "POSTGRES_PASSWORD=xxx",
"-e", "PGDATA=/pgdata",
"--tmpfs", "/pgdata:rw,noexec,nosuid,size=1024m",
"-p", "\(port):5432",
"-d",
"postgres:16-alpine"
])
}

static func removeDB(id: UUID) -> ShellOutCommand {
.init(command: "docker", arguments: [
"rm", "-f", "spi_test_\(id)"
])
}
}
2 changes: 1 addition & 1 deletion Tests/AppTests/HomeIndexModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Dependencies
import XCTVapor


class HomeIndexModelTests: AppTestCase {
class HomeIndexModelTests: ParallelizedAppTestCase {

func test_query() async throws {
// setup
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/IngestionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import S3Store
import Vapor


class IngestionTests: AppTestCase {
class IngestionTests: ParallelizedAppTestCase {

func test_ingest_basic() async throws {
// setup
Expand Down
2 changes: 1 addition & 1 deletion Tests/AppTests/Joined3Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import Vapor
import XCTest

class Joined3Tests: AppTestCase {
class Joined3Tests: ParallelizedAppTestCase {

func test_query_no_version() async throws {
// setup
Expand Down
Loading
Loading