Skip to content

Commit

Permalink
fix: print hash and lock filename using debug log (cypress-io#226)
Browse files Browse the repository at this point in the history
and add more assertions to the env example
  • Loading branch information
bahmutov authored Nov 11, 2020
1 parent 637d8e8 commit 6f4f2c6
Show file tree
Hide file tree
Showing 8 changed files with 379 additions and 354 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/example-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ jobs:
working-directory: examples/env
# additional env variables to pass to Cypress specs
# variables are automatically casted
# Cypress.env('host') // 'api.dev.local'
# Cypress.env('host') // 'http://api.dev.local'
# Cypress.env('apiPort') // 4222
env: host=api.dev.local,apiPort=4222
env: host=http://api.dev.local,apiPort=4222
spec: cypress/integration/spec.js

with-action-env:
Expand All @@ -55,7 +55,7 @@ jobs:
# via additional "env" blocks
env:
CYPRESS_apiPort: 4222
CYPRESS_host: api.dev.local
CYPRESS_host: http://api.dev.local
with:
working-directory: examples/env
spec: cypress/integration/spec.js
Expand All @@ -75,6 +75,6 @@ jobs:
env:
CYPRESS_apiPort: 4222
with:
env: host=api.dev.local
env: host=http://api.dev.local
working-directory: examples/env
spec: cypress/integration/spec.js
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7215,7 +7215,9 @@ const useYarn = () => fs.existsSync(yarnFilename)

const lockHash = () => {
const lockFilename = useYarn() ? yarnFilename : packageLockFilename
return hasha.fromFileSync(lockFilename)
const fileHash = hasha.fromFileSync(lockFilename)
core.debug(`Hash from file ${lockFilename} is ${fileHash}`)
return fileHash
}

// enforce the same NPM cache folder across different operating systems
Expand Down
21 changes: 16 additions & 5 deletions examples/env/cypress/integration/spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
it('has all expected env variables', () => {
// environmentName is set as workflow environment variable
// as a precaution we can confirm the variable was set
expect(Cypress.env('environmentName'), 'environment').to.be.a(
'string'
)
// and we can confirm its value
expect(
Cypress.env('environmentName'),
'has environment name'
'environment name is staging'
).to.equal('staging')

// host and port are set via action's "with: env:" parameter
expect(Cypress.env()).to.deep.include({
host: 'api.dev.local',
apiPort: 4222
})
expect(Cypress.env(), 'full env includes API info').to.deep.include(
{
host: 'http://api.dev.local',
apiPort: 4222
}
)
// we can confirm that host is an url
expect(Cypress.env('host'), 'host is an URL').to.match(
/^https?:\/\//
)
})
4 changes: 2 additions & 2 deletions examples/env/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = (on, config) => {
console.log('in plugis file')
console.log('in plugins file')
console.log(
'process.env.CYPRESS_environmentName',
process.env.CYPRESS_environmentName
)
console.log('config.env', config.env)
console.log('entire config.env', config.env)
}
Loading

0 comments on commit 6f4f2c6

Please sign in to comment.