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

feat: add custom install command support #260

Merged
merged 3 commits into from
Dec 8, 2020
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
15 changes: 15 additions & 0 deletions .github/workflows/example-install-command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: example-install-command
on: [push]
jobs:
install-command:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Custom Yarn command
uses: ./
with:
working-directory: examples/install-command
# https://classic.yarnpkg.com/en/docs/cli/install
install-command: yarn --frozen-lockfile --silent
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- [Start server](#start-server) before running the tests
- [Start multiple servers](#start-multiple-servers) before running the tests
- [Wait for server](#wait-on) to respond before running the tests
- use [custom install command](#custom-install-command)
- use [command prefix](#command-prefix)
- use [own custom test command](#custom-test-command)
- pass [custom build id](#custom-build-id) when recording to Dashboard
Expand Down Expand Up @@ -633,6 +634,18 @@ See [example-wait-on.yml](.github/workflows/example-wait-on.yml) workflow file.

If this action times out waiting for the server to respond, please see [Debugging](#debugging) section in this README file.

### Custom install command

If you want to overwrite the install command

```yml
- uses: cypress-io/github-action@v2
with:
install-command: yarn --frozen-lockfile --silent
```

See [example-install-command.yml](.github/workflows/example-install-command.yml) workflow file.

### Command prefix

You can prefix the default test command using the `command-prefix` option. This is useful for example when running [Percy](https://docs.percy.io/docs/cypress), which requires the test command to be wrapped with `percy exec --`.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ inputs:
install:
description: 'Whether or not to run install'
required: false
install-command:
description: 'Custom install command to use'
required: false
runTests:
description: 'Whether or not to run tests'
required: false
Expand Down
8 changes: 7 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8705,9 +8705,16 @@ const install = () => {
// prevent lots of progress messages during install
core.exportVariable('CI', '1')
core.exportVariable('CYPRESS_CACHE_FOLDER', CYPRESS_CACHE_FOLDER)
// set NPM cache path in case the user has custom install command
core.exportVariable('npm_config_cache', NPM_CACHE_FOLDER)

// Note: need to quote found tool to avoid Windows choking on
// npm paths with spaces like "C:\Program Files\nodejs\npm.cmd ci"
const installCommand = core.getInput('install-command')
if (installCommand) {
core.debug(`using custom install command "${installCommand}"`)
return execCommand(installCommand, true, 'install command')
}

if (useYarn()) {
core.debug('installing NPM dependencies using Yarn')
Expand All @@ -8721,7 +8728,6 @@ const install = () => {
})
} else {
core.debug('installing NPM dependencies')
core.exportVariable('npm_config_cache', NPM_CACHE_FOLDER)

return io.which('npm', true).then((npmPath) => {
core.debug(`npm at "${npmPath}"`)
Expand Down
3 changes: 3 additions & 0 deletions examples/install-command/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# example: install-command

This example runs the custom install command.
6 changes: 6 additions & 0 deletions examples/install-command/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"fixturesFolder": false,
"supportFile": false,
"pluginsFile": false,
"baseUrl": "https://example.cypress.io/"
}
7 changes: 7 additions & 0 deletions examples/install-command/cypress/integration/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference types="cypress" />
describe('example: install-only', () => {
it('loads the deployed site', () => {
cy.visit('/')
cy.contains('h1', 'Kitchen Sink')
})
})
18 changes: 18 additions & 0 deletions examples/install-command/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "example-install-command",
"version": "1.0.0",
"description": "Install dependencies using custom command",
"scripts": {
"test": "cypress run"
},
"author": "Gleb Bahmutov <[email protected]>",
"license": "MIT",
"private": true,
"devDependencies": {
"cypress": "6.1.0"
},
"dependencies": {
"arg": "5.0.0",
"debug": "4.2.0"
}
}
Loading