sourcegraph / create

CLI to bootstrap Sourcegraph npm packages
Apache License 2.0
9 stars 3 forks source link

Fetching Codecov repository tokens fails if repo exists as private GH repo but you say it should be public #5

Open sqs opened 6 years ago

sqs commented 6 years ago

npm init @sourcegraph in the existing private repo https://github.com/sourcegraph/extensions-client-common consistently failed. I fixed it by making the repo public (so I am not blocked on this and it is not urgent).

$ TRAVIS_TOKEN=REDACTED BUILDKITE_TOKEN=REDACTED CODECOV_TOKEN=REDACTED GITHUB_TOKEN=REDACTED npm init @sourcegraph
npx: installed 154 in 3.028s
Using GITHUB_TOKEN from env var
Using CODECOV_TOKEN from env var
Using BUILDKITE_TOKEN from env var
*️⃣ Welcome to the Sourcegraph npm package initializer
? What should the name of the package be? Examples: @sourcegraph/codeintellify, @sourcegraph/react-loading-spinner, cxp @sourcegraph/ext
ensions-client-common
? Description 
? 🔐 Should this package be public or private? public
📘 Existing git remote detected, skipping GitHub repository creation
🔑 Giving all FTTs admin access
? License? MIT
📄 Adding LICENSE
? Does this package have tests? Yes
📄 tsconfig.json already exists, skipping creation
📄 tslint.json already exists, skipping creation
📄 Adding prettier.config.js
📄 Adding .prettierignore
📄 Adding .gitignore
📄 package.json already exists, skipping creation
📂 Creating src directory
📦 Installing dependencies

> husky@0.14.3 uninstall /home/sqs/src/github.com/sourcegraph/extensions-client-common/node_modules/husky
> node ./bin/uninstall.js

husky
uninstalling Git hooks
done

> husky@0.14.3 install /home/sqs/src/github.com/sourcegraph/extensions-client-common/node_modules/husky
> node ./bin/install.js

husky
setting up Git hooks
done

npm WARN @gql2ts/from-query@1.8.2 requires a peer of graphql@>= 0.10 <1.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @gql2ts/util@1.8.1 requires a peer of graphql@>= 0.10 <1.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.1.3 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN tslint-language-service@0.9.9 requires a peer of typescript@>= 2.3.1 < 3 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ @commitlint/config-conventional@7.0.1
+ @sourcegraph/tsconfig@3.0.0
+ @commitlint/cli@7.0.0
+ husky@0.14.3
+ prettier@1.14.2
+ tslint@5.11.0
+ mocha@5.2.0
+ semantic-release@15.9.8
+ nyc@12.0.2
+ typescript@3.0.1
+ @sourcegraph/tslint-config@12.0.0
+ @sourcegraph/prettierrc@2.2.0
updated 12 packages and audited 12303 packages in 11.362s
found 0 vulnerabilities

🔑 Fetching CodeCov repository tokens
{ StatusCodeError: 404 - {"error":{"reason":"GitHub API: Not Found","context":null},"meta":{"status":404}}
    at new StatusCodeError (/home/sqs/.npm/_npx/20320/lib/node_modules/@sourcegraph/create/node_modules/request-promise-core/lib/errors.js:32:15)
    at Request.plumbing.callback (/home/sqs/.npm/_npx/20320/lib/node_modules/@sourcegraph/create/node_modules/request-promise-core/lib/plumbing.js:104:33)
    at Request.RP$callback [as _callback] (/home/sqs/.npm/_npx/20320/lib/node_modules/@sourcegraph/create/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at Request.self.callback (/home/sqs/.npm/_npx/20320/lib/node_modules/@sourcegraph/create/node_modules/request/request.js:185:22)
    at Request.emit (events.js:182:13)
    at Request.<anonymous> (/home/sqs/.npm/_npx/20320/lib/node_modules/@sourcegraph/create/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:182:13)
    at IncomingMessage.<anonymous> (/home/sqs/.npm/_npx/20320/lib/node_modules/@sourcegraph/create/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:273:13)
    at IncomingMessage.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1081:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  name: 'StatusCodeError',
  statusCode: 404,
  message:
   '404 - {"error":{"reason":"GitHub API: Not Found","context":null},"meta":{"status":404}}',
  error:
   { error: { reason: 'GitHub API: Not Found', context: null },
     meta: { status: 404 } },
  options:
   { resolveWithFullResponse: true,
     baseUrl: 'https://codecov.io/api/',
     json: true,
     headers: { Authorization: 'token REDACTED' },
     uri: 'gh/sourcegraph/extensions-client-common',
     method: 'GET',
     callback: [Function: RP$callback],
     transform: undefined,
     simple: true,
     transform2xxOnly: false },
felixfbecker commented 6 years ago

Yes, the CLI does not support changing the state of e.g. the repo from private to public. It is only build to create things, idempotently. Any change must either be done manually, or by deleting the object and running again (e.g. deleting the GitHub repo, deleting buildkite.yml). It would be nice if it did support changing, but that would make the code a lot more complex (basically implementing a desired state configuration algorithm and transitions for every object into every possible state).

It somewhat confuses me though that Codecov would fail just because the repo is private, given that you have a codecov API token...