Skip to content
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
33 changes: 32 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,38 @@ We require that your commit messages match our template. The easiest way to do t

### Run CI checks locally

You can run the Github Actions workflows locally using [act](https://github.com/nektos/act). For detailed steps on how to do this please see [https://github.com/swiftlang/github-workflows?tab=readme-ov-file#running-workflows-locally](https://github.com/swiftlang/github-workflows?tab=readme-ov-file#running-workflows-locally).
You can run the Github Actions workflows locally using
[act](https://github.com/nektos/act). To run all the jobs that run on a pull
request, use the following command:

```
% act pull_request
```

To run just a single job, use `workflow_call -j <job>`, and specify the inputs
the job expects. For example, to run just shellcheck:

```
% act workflow_call -j soundness --input shell_check_enabled=true
```

To bind-mount the working directory to the container, rather than a copy, use
`--bind`. For example, to run just the formatting, and have the results
reflected in your working directory:

```
% act --bind workflow_call -j soundness --input format_check_enabled=true
```

If you'd like `act` to always run with certain flags, these can be be placed in
an `.actrc` file either in the current working directory or your home
directory, for example:

```
--container-architecture=linux/amd64
--remote-name upstream
--action-offline-mode
```

## How to contribute your work

Expand Down
5 changes: 1 addition & 4 deletions Tests/InMemoryTracingTests/InMemoryTracerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Testing)
@_spi(Testing) import InMemoryTracing
@_spi(Locking) import Instrumentation
import Testing
import Tracing
@_spi(Testing) import InMemoryTracing

@Suite("InMemoryTracer")
struct InMemoryTracerTests {
Expand Down Expand Up @@ -437,5 +436,3 @@ private final class MockClock {
Instant(nanosecondsSinceEpoch: self._now)
}
}

#endif
18 changes: 10 additions & 8 deletions Tests/InstrumentationTests/InstrumentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
//
//===----------------------------------------------------------------------===//

import Foundation
import Instrumentation
import ServiceContextModule
import XCTest
import Testing

final class InstrumentTests: XCTestCase {
func testMultiplexInvokesAllInstruments() {
@Suite("MultiplexInstrument")
struct InstrumentTests {
@Test("MultiplexInstrument invokes all instruments")
func multiplexInvokesAllInstruments() {
let instrument = MultiplexInstrument([
FirstFakeTracer(),
SecondFakeTracer(),
Expand All @@ -26,15 +29,14 @@ final class InstrumentTests: XCTestCase {
var context = ServiceContext.topLevel
instrument.extract([String: String](), into: &context, using: DictionaryExtractor())

XCTAssertEqual(context[FirstFakeTracer.TraceIDKey.self], FirstFakeTracer.defaultTraceID)
XCTAssertEqual(context[SecondFakeTracer.TraceIDKey.self], SecondFakeTracer.defaultTraceID)
#expect(context[FirstFakeTracer.TraceIDKey.self] == FirstFakeTracer.defaultTraceID)
#expect(context[SecondFakeTracer.TraceIDKey.self] == SecondFakeTracer.defaultTraceID)

var subsequentRequestHeaders = ["Accept": "application/json"]
instrument.inject(context, into: &subsequentRequestHeaders, using: DictionaryInjector())

XCTAssertEqual(
subsequentRequestHeaders,
[
#expect(
subsequentRequestHeaders == [
"Accept": "application/json",
FirstFakeTracer.headerName: FirstFakeTracer.defaultTraceID,
SecondFakeTracer.headerName: SecondFakeTracer.defaultTraceID,
Expand Down
11 changes: 8 additions & 3 deletions Tests/TracingTests/ActorTracingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@
//===----------------------------------------------------------------------===//

import ServiceContextModule
import Testing
import Tracing
import XCTest

@testable import Instrumentation

/// This is a compile-time test
final class ActorTracingTests: XCTestCase {
func test() {}
@Suite("Actor Tracing Compatibility")
struct ActorTracingTests {
@Test("Compiles with actor isolation")
func compilesWithActorIsolation() {
// This test exists purely to verify that the code compiles
// with Swift's strict concurrency checking
}
}

func work() async {}
Expand Down
28 changes: 16 additions & 12 deletions Tests/TracingTests/DynamicTracepointTracerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
//
//===----------------------------------------------------------------------===//

import Foundation
import ServiceContextModule
import Testing
import Tracing
import XCTest

@testable import Instrumentation

final class DynamicTracepointTracerTests: XCTestCase {
func test_adhoc_enableBySourceLoc() {
@Suite("Dynamic Tracepoint Tracer Tests")
struct DynamicTracepointTracerTests {
@Test("Ad-hoc tracepoint enable by source location")
func adhoc_enableBySourceLoc() {
let tracer = DynamicTracepointTestTracer()

let fileID = #fileID
Expand Down Expand Up @@ -49,16 +52,17 @@ final class DynamicTracepointTracerTests: XCTestCase {
}
}

XCTAssertEqual(tracer.spans.count, 4)
#expect(tracer.spans.count == 4)

for span in tracer.spans {
XCTAssertEqual(span.context.traceID, "trace-id-fake-\(fileID)-\(fakeLine)")
#expect(span.context.traceID == "trace-id-fake-\(fileID)-\(fakeLine)")
}
XCTAssertEqual(tracer.spans[0].context.spanID, "span-id-fake-\(fileID)-\(fakeLine)")
XCTAssertEqual(tracer.spans[1].context.spanID, "span-id-fake-\(fileID)-\(fakeNextLine)")
#expect(tracer.spans[0].context.spanID == "span-id-fake-\(fileID)-\(fakeLine)")
#expect(tracer.spans[1].context.spanID == "span-id-fake-\(fileID)-\(fakeNextLine)")
}

func test_adhoc_enableByFunction() {
@Test("Ad-hoc tracepoint enable by function")
func adhoc_enableByFunction() {
let tracer = DynamicTracepointTestTracer()

let fileID = #fileID
Expand All @@ -70,12 +74,12 @@ final class DynamicTracepointTracerTests: XCTestCase {
self.logic(fakeLine: 55, tracer: tracer)
self.traceMeLogic(fakeLine: fakeLine, tracer: tracer)

XCTAssertEqual(tracer.spans.count, 2)
#expect(tracer.spans.count == 2)
for span in tracer.spans {
XCTAssertEqual(span.context.traceID, "trace-id-fake-\(fileID)-\(fakeLine)")
#expect(span.context.traceID == "trace-id-fake-\(fileID)-\(fakeLine)")
}
XCTAssertEqual(tracer.spans[0].context.spanID, "span-id-fake-\(fileID)-\(fakeLine)")
XCTAssertEqual(tracer.spans[1].context.spanID, "span-id-fake-\(fileID)-\(fakeNextLine)")
#expect(tracer.spans[0].context.spanID == "span-id-fake-\(fileID)-\(fakeLine)")
#expect(tracer.spans[1].context.spanID == "span-id-fake-\(fileID)-\(fakeNextLine)")
}

func logic(fakeLine: UInt, tracer: any Tracer) {
Expand Down
Loading
Loading