From 9e42dea36d2931db125f83ab295094bf404e5625 Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Mon, 10 Jul 2023 04:12:15 -0500 Subject: [PATCH] Misc cleanups (#209) --- CONTRIBUTING.md => .github/CONTRIBUTING.md | 0 .github/workflows/test.yml | 20 ++++++++++++++------ Package.swift | 2 +- Tests/RedisTests/MultipleRedisTests.swift | 8 ++++++-- Tests/RedisTests/RedisTests.swift | 4 +++- 5 files changed, 24 insertions(+), 10 deletions(-) rename CONTRIBUTING.md => .github/CONTRIBUTING.md (100%) diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e00f1f..9f1fbde 100755 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,10 @@ name: test -on: - pull_request: { types: [opened, reopened, synchronize, ready_for_review] } - push: { branches: [ main ] } concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +on: + pull_request: { types: [opened, reopened, synchronize, ready_for_review] } + push: { branches: [ main ] } env: LOG_LEVEL: info SWIFT_DETERMINISTIC_HASHING: 1 @@ -39,22 +39,30 @@ jobs: redis: - redis:6 - redis:7 + runs-on: ubuntu-latest container: ${{ matrix.container }} services: redis: image: ${{ matrix.redis }} redis-2: image: ${{ matrix.redis }} - runs-on: ubuntu-latest steps: - name: Save Redis version to env run: | echo REDIS_VERSION='${{ matrix.redis }}' >> $GITHUB_ENV + - name: Display versions + shell: bash + run: | + if [[ '${{ contains(matrix.container, 'nightly') }}' == 'true' ]]; then + SWIFT_PLATFORM="$(source /etc/os-release && echo "${ID}${VERSION_ID}")" SWIFT_VERSION="$(cat /.swift_tag)" + printf 'SWIFT_PLATFORM=%s\nSWIFT_VERSION=%s\n' "${SWIFT_PLATFORM}" "${SWIFT_VERSION}" >>"${GITHUB_ENV}" + fi + printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}" && swift --version - name: Check out package uses: actions/checkout@v3 - - name: Run unit tests with Thread Sanitizer + - name: Run unit tests with Thread Sanitizer and coverage run: swift test --sanitize=thread --enable-code-coverage - - name: Upload code coverage + - name: Submit coverage report to Codecov.io uses: vapor/swift-codecov-action@v0.2 with: cc_env_vars: 'SWIFT_VERSION,SWIFT_PLATFORM,RUNNER_OS,RUNNER_ARCH,REDIS_VERSION' diff --git a/Package.swift b/Package.swift index 5b60819..6baeb22 100644 --- a/Package.swift +++ b/Package.swift @@ -14,7 +14,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/swift-server/RediStack.git", from: "1.4.1"), - .package(url: "https://github.com/vapor/vapor.git", from: "4.50.0"), + .package(url: "https://github.com/vapor/vapor.git", from: "4.77.1"), ], targets: [ .target( diff --git a/Tests/RedisTests/MultipleRedisTests.swift b/Tests/RedisTests/MultipleRedisTests.swift index edbb76b..0edfc32 100644 --- a/Tests/RedisTests/MultipleRedisTests.swift +++ b/Tests/RedisTests/MultipleRedisTests.swift @@ -20,10 +20,14 @@ class MultipleRedisTests: XCTestCase { redisConfig = try RedisConfiguration( hostname: Environment.get("REDIS_HOSTNAME") ?? "localhost", - port: Environment.get("REDIS_PORT")?.int ?? 6379) + port: Environment.get("REDIS_PORT")?.int ?? 6379, + pool: .init(connectionRetryTimeout: .milliseconds(100)) + ) redisConfig2 = try RedisConfiguration( hostname: Environment.get("REDIS_HOSTNAME_2") ?? "localhost", - port: Environment.get("REDIS_PORT_2")?.int ?? 6380) + port: Environment.get("REDIS_PORT_2")?.int ?? 6380, + pool: .init(connectionRetryTimeout: .milliseconds(100)) + ) } func testApplicationRedis() throws { diff --git a/Tests/RedisTests/RedisTests.swift b/Tests/RedisTests/RedisTests.swift index a63b190..8b3ff9d 100644 --- a/Tests/RedisTests/RedisTests.swift +++ b/Tests/RedisTests/RedisTests.swift @@ -20,7 +20,8 @@ final class RedisTests: XCTestCase { try super.setUpWithError() redisConfig = try RedisConfiguration( hostname: Environment.get("REDIS_HOSTNAME") ?? "localhost", - port: Environment.get("REDIS_PORT")?.int ?? 6379 + port: Environment.get("REDIS_PORT")?.int ?? 6379, + pool: .init(connectionRetryTimeout: .milliseconds(100)) ) } } @@ -199,6 +200,7 @@ extension RedisTests { app.caches.use(.redis) try app.boot() + XCTAssertNoThrow(try app.redis.send(command: "DEL", with: [.init(from: "foo")]).wait()) try XCTAssertNil(app.cache.get("foo", as: String.self).wait()) try app.cache.set("foo", to: "bar").wait() try XCTAssertEqual(app.cache.get("foo", as: String.self).wait(), "bar")