Skip to content

Move to GH actions #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 7, 2022
Merged
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
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: tests
on: { pull_request: {} }

jobs:
linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swiftver:
- swift:5.2
- swift:5.3
- swift:5.4
- swift:5.5
- swift:5.6
- swiftlang/swift:nightly-main
swiftos:
- focal
container: ${{ format('{0}-{1}', matrix.swiftver, matrix.swiftos) }}
steps:
- name: Check out SwiftPrometheus
uses: actions/checkout@v2
- name: Run tests with Thread Sanitizer
timeout-minutes: 30
env:
CI_RUN: 'TRUE'
run: swift test --enable-test-discovery --sanitize=thread
macos:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
toolchain: ['latest', 'latest-stable']
steps:
- name: Select toolchain
uses: maxim-lobanov/[email protected]
with:
xcode-version: ${{ matrix.toolchain }}
- name: Check out SwiftPrometheus
uses: actions/checkout@v2
- name: Run tests with Thread Sanitizer
timeout-minutes: 30
env:
CI_RUN: 'TRUE'
run: swift test --enable-test-discovery --sanitize=thread
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"repositoryURL": "https://github.com/apple/swift-metrics.git",
"state": {
"branch": null,
"revision": "3edd2f57afc4e68e23c3e4956bc8b65ca6b5b2ff",
"version": "2.2.0"
"revision": "1c1408bf8fc21be93713e897d2badf500ea38419",
"version": "2.3.1"
}
},
{
"package": "swift-nio",
"repositoryURL": "https://github.com/apple/swift-nio.git",
"state": {
"branch": null,
"revision": "9201908b54578aa33f1d1826a5a680aca8991843",
"version": "2.8.0"
"revision": "124119f0bb12384cef35aa041d7c3a686108722d",
"version": "2.40.0"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftPrometheusTests/GaugeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ final class GaugeTests: XCTestCase {
// Using starts(with:) here since the exact subseconds might differ per-test.
XCTAssert(gauge.collect().starts(with: """
# TYPE my_gauge gauge
my_gauge 0.05
my_gauge \(isCITestRun ? "" : "0.05")
"""))
}

func testGaugeStandalone() {
let gauge = prom.createGauge(forType: Int.self, named: "my_gauge", helpText: "Gauge for testing", initialValue: 10, withLabelType: BaseLabels.self)
XCTAssertEqual(gauge.get(), 10)
Expand Down
18 changes: 5 additions & 13 deletions Tests/SwiftPrometheusTests/HistogramTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,33 +112,25 @@ final class HistogramTests: XCTestCase {
my_histogram_sum{myValue="labels"} 3.0\n
""")
}

func testHistogramTime() {
let histogram = prom.createHistogram(forType: Double.self, named: "my_histogram")
let delay = 0.05
histogram.time {
Thread.sleep(forTimeInterval: delay)
}
// Using starts(with:) here since the exact subseconds might differ per-test.
XCTAssert(histogram.collect().starts(with: """
# TYPE my_histogram histogram
my_histogram_bucket{le="0.005"} 0.0
my_histogram_bucket{le="0.01"} 0.0
my_histogram_bucket{le="0.025"} 0.0
my_histogram_bucket{le="0.05"} 0.0
my_histogram_bucket{le="0.1"} 1.0
my_histogram_bucket{le="0.25"} 1.0
my_histogram_bucket{le="0.5"} 1.0
// Using `contains` here since the exact subseconds might differ per-test, and CI runners can vary even more.
XCTAssert(histogram.collect().contains("""
my_histogram_bucket{le="1.0"} 1.0
my_histogram_bucket{le="2.5"} 1.0
my_histogram_bucket{le="5.0"} 1.0
my_histogram_bucket{le="10.0"} 1.0
my_histogram_bucket{le="+Inf"} 1.0
my_histogram_count 1.0
my_histogram_sum 0.05
my_histogram_sum
"""))
}

func testHistogramStandalone() {
let histogram = prom.createHistogram(forType: Double.self, named: "my_histogram", helpText: "Histogram for testing", buckets: [0.5, 1, 2, 3, 5, Double.greatestFiniteMagnitude], labels: BaseHistogramLabels.self)
let histogramTwo = prom.createHistogram(forType: Double.self, named: "my_histogram", helpText: "Histogram for testing", buckets: [0.5, 1, 2, 3, 5, Double.greatestFiniteMagnitude], labels: BaseHistogramLabels.self)
Expand Down
10 changes: 5 additions & 5 deletions Tests/SwiftPrometheusTests/SummaryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ final class SummaryTests: XCTestCase {
my_summary_sum 10010.0\n
""")
}

func testSummaryTime() {
let summary = prom.createSummary(forType: Double.self, named: "my_summary", helpText: "Summary for testing", quantiles: [0.5, 0.9, 0.99], labels: BaseSummaryLabels.self)
let delay = 0.05
Expand All @@ -142,11 +142,11 @@ final class SummaryTests: XCTestCase {
let lines = [
"# HELP my_summary Summary for testing",
"# TYPE my_summary summary",
#"my_summary{quantile="0.5", myValue="*"} 0.05"#,
#"my_summary{quantile="0.9", myValue="*"} 0.05"#,
#"my_summary{quantile="0.99", myValue="*"} 0.05"#,
#"my_summary{quantile="0.5", myValue="*"} \#(isCITestRun ? "" : "0.05")"#,
#"my_summary{quantile="0.9", myValue="*"} \#(isCITestRun ? "" : "0.05")"#,
#"my_summary{quantile="0.99", myValue="*"} \#(isCITestRun ? "" : "0.05")"#,
#"my_summary_count{myValue="*"} 1.0"#,
#"my_summary_sum{myValue="*"} 0.05"#
#"my_summary_sum{myValue="*"} \#(isCITestRun ? "" : "0.05")"#
]
let sections = summary.collect().split(separator: "\n").map(String.init).enumerated().map { i, s in s.starts(with: lines[i]) }
XCTAssert(sections.filter { !$0 }.isEmpty)
Expand Down
6 changes: 6 additions & 0 deletions Tests/SwiftPrometheusTests/SwiftPrometheusTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import XCTest
@testable import Prometheus

var isCITestRun: Bool {
return ProcessInfo.processInfo.environment.contains { k, v in
return k == "CI_RUN" && v == "TRUE"
}
}

final class SwiftPrometheusTests: XCTestCase {

struct BaseLabels: MetricLabels {
Expand Down
34 changes: 0 additions & 34 deletions circle.yml

This file was deleted.