swift icon indicating copy to clipboard operation
swift copied to clipboard

Danger is crashing on travis says its not finding danger-response.

Open scottandrew opened this issue 4 years ago • 6 comments

I am trying to integrate danger 3.0 into our repo using package manger.

My package looks like so:

let package = Package(
    name: "DangerTarget",
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "DangerDeps",
            type: .dynamic,
            targets: ["DangerTarget"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(url: "https://github.com/danger/swift.git", from: "3.0.0"),
        .package(url: "https://github.com/f-meloni/danger-swift-xcodesummary", from: "1.1.0")
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "DangerTarget",
            dependencies: ["Danger", "DangerXCodeSummary"],
			path: ".",
			sources: ["dummy.swift"]),
    ]
)

I am using the installing and verifying using the steps described:

npm install -g danger
swift build

Danger file is:

let danger = Danger()
let xcodeSummary = XCodeSummary(filePath: "result.json")

let title = danger.github.pullRequest.title

if (title.contains("WIP")) {
    danger.fail("This is a work in progress and can't be merged!")
}

if (!title.starts(with: "ORDER-")) {
    danger.fail("Pull request should start with bug number!")
}

if let body = danger.github.pullRequest.body {
    if (body.contains("https://keenwawa.atlassian.net/browse/???")) {
        danger.fail("Forgot to link to Jira ticket!")
    }

    if (!body.contains("[x]")) {
        danger.fail("Forgot to mark a type in the checklist!")
    }
} else {
    danger.fail("Missing pull request message")
}

xcodeSummary.report()

SwiftLint.lint(.all(directory: nil))

But when I run danger I am getting the following stack dump on travis.

Stack dump:
0.	Program arguments: /Applications/Xcode-11.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret /var/folders/17/5mc7816d3mndxjqgplq6057w0000gn/T/_tmp_dangerfile.swift -enable-objc-interop -sdk /Applications/Xcode-11.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -I /Users/travis/build/Keenwawa/Kiosk/.build/debug -module-name _tmp_dangerfile -lDanger -- /var/folders/17/5mc7816d3mndxjqgplq6057w0000gn/T/danger-dsl.json /var/folders/17/5mc7816d3mndxjqgplq6057w0000gn/T/danger-response.json 
0  swift                    0x0000000106c5aa63 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x0000000106c5a236 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff59563b5d _sigtramp + 29
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 2796143808
4  swift                    0x00000001028cdcfd llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 365
5  swift                    0x00000001028d4cb2 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, char const* const*) + 1090
6  swift                    0x00000001028a7d5f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 45727
7  swift                    0x00000001028992b4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
8  swift                    0x00000001028267b3 main + 1219
9  libdyld.dylib            0x00007fff5937e3d5 start + 1
10 libdyld.dylib            0x000000000000000f start + 2798132283
�[31mERROR: Dangerfile eval failed at Dangerfile.swift
�[0;0m�[31mERROR: Could not get the results JSON file at /var/folders/17/5mc7816d3mndxjqgplq6057w0000gn/T/danger-response.json
�[0;0m

scottandrew avatar Jan 16 '20 19:01 scottandrew

What happens if you run swift run danger-swift local?

f-meloni avatar Jan 16 '20 23:01 f-meloni

This works locally. Are you asking about doing that on Travis?

scottandrew avatar Jan 17 '20 04:01 scottandrew

Ok, can I see your travis config please?

f-meloni avatar Jan 17 '20 20:01 f-meloni

I can't give you the whole config but the relevant parts are:

os: osx
language: swift
osx_image: xcode11.3
cache: 
  ~/.danger-swift
  .build

branches:
  only:
    - /^release.*$/
    - master
    - /^ORDER-.*$/
    - /^.*\/?ORDER-.*$/
    - /^.*\/?SERVICES-.*$/


# Build stages: https://docs.travis-ci.com/user/build-stages/.
stages:
  - compile
  - debug
  - release

jobs:
  include:
    # compile: Check that the code builds and tests pass.
    - stage: compile
      before_install: 
         # make sure our shell scripts are executable.
        - chmod +x ./scripts/before_install.sh
        - chmod +x ./scripts/prepare_keychain.sh
        - chmod +x ./scripts/after_script.sh
        # make suree cocoa pods is up to date.
        - sudo gem install cocoapods
        - sudo gem install xcpretty-json-formatter
        # last minute preperations before we install.
        - ./scripts/before_install.sh
        # update pods.
        - travis_wait pod install --repo-update
      
      before_script:
        # prepare keychain for signing.
        - ./scripts/prepare_keychain.sh
    
      script: 
        # clean, build and test
        - xcodebuild -workspace Kiosk-Fresh.xcworkspace -scheme Kiosk -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPad (7th generation),OS=13.2.2' clean test | XCPRETTY_JSON_FILE_OUTPUT=result.json xcpretty -f `xcpretty-json-formatter`
        - swift run danger-swift ci --failOnErrors

The before install script has:

#Required to fix: RuntimeError: [!] Please enable Spotlight indexing for /Applications.
sudo mdutil -i on / 

# Install ImageMagik so we can badge the icon.
brew install imagemagick graphicsmagick
brew install xctool
npm install -g danger
swift build

full stack dump is:

[38/39] Merging module Runner
1884[39/39] Linking danger-swift
1885Stack dump:
18860.	Program arguments: /Applications/Xcode-11.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret /var/folders/17/5mc7816d3mndxjqgplq6057w0000gn/T/_tmp_dangerfile.swift -enable-objc-interop -sdk /Applications/Xcode-11.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -I /Users/travis/build/Keenwawa/Kiosk/.build/debug -module-name _tmp_dangerfile -lDanger -- /var/folders/17/5mc7816d3mndxjqgplq6057w0000gn/T/danger-dsl.json /var/folders/17/5mc7816d3mndxjqgplq6057w0000gn/T/danger-response.json 
1887
18880  swift                    0x0000000106c5aa63 
1889PrintStackTraceSignalHandler(void*) + 51
18901  swift                    0x0000000106c5a236 SignalHandler(int) + 358
18912  libsystem_platform.dylib 0x00007fff59563b5d _sigtramp + 29
18923  libsystem_platform.dylib 000000000000000000 _sigtramp + 2796143808
18934  swift                    0x00000001028cdcfd llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 365
18945  swift                    0x00000001028d4cb2 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, char const* const*) + 1090
1895
18966  swift                    0x00000001028a7d5f performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 45727
18977  swift                    0x00000001028992b4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
1898
18998  swift                    0x00000001028267b3 main + 1219
19009  libdyld.dylib            0x00007fff5937e3d5 start + 1
190110 libdyld.dylib            0x000000000000000f start + 2798132283
1902
1903ERROR: Dangerfile eval failed at Dangerfile.swift
1904ERROR: Could not get the results JSON file at /var/folders/17/5mc7816d3mndxjqgplq6057w0000gn/T/danger-response.json

scottandrew avatar Jan 17 '20 20:01 scottandrew

I didn't find an answer to why is not working, I have a really similar configuration on this repo https://github.com/f-meloni/danger-swift-coverage and is working, maybe that could help you to find the reason why is crashing

f-meloni avatar Jan 20 '20 22:01 f-meloni

I have no clue what is going on.. I have to give up on this for a bit..

scottandrew avatar Jan 21 '20 18:01 scottandrew