Skip to content

Commit

Permalink
Misc cleanups (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynne committed Jul 10, 2023
1 parent 2a8d3e4 commit 9e42dea
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
File renamed without changes.
20 changes: 14 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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'
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 6 additions & 2 deletions Tests/RedisTests/MultipleRedisTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion Tests/RedisTests/RedisTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
)
}
}
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 9e42dea

Please sign in to comment.