swift icon indicating copy to clipboard operation
swift copied to clipboard

Running yarn danger local yields error

Open doronkatz opened this issue 5 years ago • 11 comments

Report

What did you do?

ℹ Please replace this with what you did. yarn danger local

What did you expect to happen?

Run on docker image (via bitbucket pipelines) and complete successfully.

What happened instead?

root@893d1e34f18f:/app# yarn danger local
yarn run v1.19.1
$ /app/node_modules/.bin/danger local
events.js:187
      throw er; // Unhandled 'error' event
      ^

Error: spawn git ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:262:19)
    at onErrorNT (internal/child_process.js:464:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:12)
    at onErrorNT (internal/child_process.js:464:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn git',
  path: 'git',
  spawnargs: [ 'diff', 'master...HEAD' ]
}
error Command failed with exit code 1.

Your Environment

Bitbucket pipelines. Running latest version of Danger.

import DangerSwiftCoverage
Coverage.spmCoverage(minimumCoverage: 50)

The bitbucket-pipeline contains:

# This is a sample build configuration for Other.
# Check our guides at https://confluence.atlassian.com/x/5Q4SMw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
options:
  docker: true

definitions:
  services:
    docker:
      memory: 2048
    swift:
      image: swift:latest
      memory: 128

steps:
  - step: &step-test
      name: Swift Unit Testing
      image: swift
      script:
        - swift build
        - api_token="$API_KEY" swift test
  - step: &step-lint
      name: Swift Lint
      image: dantoml/swiftlint:latest
      script:
        - swiftlint autocorrect
        - swiftlint lint
  - step: &step-coverage
      name: Danger Coverage
      image: node:slim
      caches:
        - node
      script:
        - yarn add danger
        - yarn danger ci
          

pipelines:
  default:
    - parallel:
        - step: *step-test
        - step: *step-lint
        - step: *step-coverage

doronkatz avatar Nov 27 '19 16:11 doronkatz

Running with CI i get no error but it just skips. If i do local, i get the error shown above.

doronkatz avatar Nov 27 '19 16:11 doronkatz

Error: spawn git ENOENT

Looks like your CI might not have git?

orta avatar Nov 27 '19 21:11 orta

Well maybe you can help me with this. So my workflow has me via the bitbucket pipelines calling an image (node) to trigger add danger and then danger ci. Are you saying that the node image doesn't have git?

Ill update the description to show my entire workflow in pipelines, if that helps in context understand the workflow.. But essentially i want my bitbucket pipeline as a step to call danger, for my swift application.

doronkatz avatar Nov 27 '19 22:11 doronkatz

I think you might want to re-run through the help sections of the website for Danger Swift, this is currently set up to use Danger JS in the CI

orta avatar Nov 28 '19 12:11 orta

Small addition, if you want to use DangerSwiftCoverage you need to use swift test --enable-code-coverage=true

f-meloni avatar Nov 28 '19 12:11 f-meloni

Tahnks @f-meloni , So in the above pipeline yaml, I add swift test --enable-code-coverage=true to the first step, right? Is the last step still correct?

doronkatz avatar Nov 28 '19 18:11 doronkatz

No those are the command to use Danger-JS help sections of the website for Danger Swift for the correct set up as @orta suggested

f-meloni avatar Nov 30 '19 12:11 f-meloni

The help section doent really help me @f-meloni. If i want to have docker do swift test but also use danger, what image would i use for that, or what command?

doronkatz avatar Nov 30 '19 18:11 doronkatz

If you are using the SPM configuration you probably need

      script:
        - npm install -g danger
        - swift run danger-swift ci

f-meloni avatar Dec 04 '19 20:12 f-meloni

Thanks..

Yeah im trying to find a docker image that has npm and swift.... 🤦🏻‍♂️

On Wed, Dec 4, 2019, at 12:41 PM, Franco Meloni wrote:

If you are using the SPM configuration you probably need

  script:
    - npm install -g danger
    - swift run danger-swift ci

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/danger/swift/issues/297?email_source=notifications&email_token=AACUJJ65P3POYIO4MEOIE53QXAIV7A5CNFSM4JSUDDS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEF6NOSY#issuecomment-561829707, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACUJJ43OWNLQMNJWDJYWY3QXAIV7ANCNFSM4JSUDDSQ.

This email and any attachments are confidential and may be subject to copyright, legal or some other professional privilege. They are intended solely for the attention and use of the named addressee(s). They may only be copied, distributed or disclosed with the consent of the copyright owner. If you have received this email by mistake or by breach of the confidentiality clause, please notify the sender immediately by return email and delete or destroy all copies of the email. Any confidentiality, privilege or copyright is not waived or lost because this email has been sent to you by mistake.

doronkatz avatar Dec 04 '19 21:12 doronkatz

https://github.com/danger/swift/blob/master/Dockerfile This one has both, but don't know if fits your needs

f-meloni avatar Dec 04 '19 21:12 f-meloni