Skip to content
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

server: read record key from environment variable, close #820 #821

Merged
merged 1 commit into from
Oct 26, 2017
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
2 changes: 2 additions & 0 deletions cli/lib/exec/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ const spawn = require('./spawn')
const verify = require('../tasks/verify')

const processRunOptions = (options = {}) => {
debug('processing run options')
const args = ['--run-project', options.project]

//// if key is set use that - else attempt to find it by env var
if (options.key == null) {
debug('--key is not set, looking up environment variable CYPRESS_RECORD_KEY')
options.key = process.env.CYPRESS_RECORD_KEY || process.env.CYPRESS_CI_KEY
}

Expand Down
4 changes: 4 additions & 0 deletions packages/server/lib/cypress.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ module.exports = {

start: (argv = []) ->
require("./logger").info("starting desktop app", args: argv)
log("starting cypress server")

## make sure we have the appData folder
require("./util/app_data").ensure()
Expand Down Expand Up @@ -148,6 +149,9 @@ module.exports = {
## enable old CLI tools to record
when options.record or options.ci
options.mode = "record"
if not options.key
log("trying to read option key from environment")
options.key = process.env.CYPRESS_RECORD_KEY || process.env.CYPRESS_CI_KEY

when options.runProject
## go into headless mode when told to run
Expand Down
16 changes: 15 additions & 1 deletion packages/server/test/integration/cypress_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ describe "lib/cypress", ->
context "--record or --ci", ->
afterEach ->
delete process.env.CYPRESS_PROJECT_ID
delete process.env.CYPRESS_RECORD_KEY

beforeEach ->
@setup = =>
Expand Down Expand Up @@ -821,7 +822,7 @@ describe "lib/cypress", ->
@setup()

## set the projectId to be todos even though
## we are running the prisine project
## we are running the pristine project
process.env.CYPRESS_PROJECT_ID = @projectId

@createRun.resolves()
Expand All @@ -832,6 +833,19 @@ describe "lib/cypress", ->
expect(errors.warning).not.to.be.called
@expectExitWith(3)

it "uses process.env.CYPRESS_RECORD_KEY", ->
@setup()

process.env.CYPRESS_RECORD_KEY = "token-123"

@createRun.resolves()
@sandbox.stub(api, "createInstance").resolves()

cypress.start(["--run-project=#{@todosPath}", "--record"])
.then =>
expect(errors.warning).not.to.be.called
@expectExitWith(3)

it "still records even with old --ci option", ->
@setup()

Expand Down