Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/adzz/yarn_command_action

A github action which will run any yarn or npm command in a node alpine container
https://github.com/adzz/yarn_command_action

cd ci deployment docker github-action github-actions javascript js npm npm-script react yarn

Last synced: about 3 hours ago
JSON representation

A github action which will run any yarn or npm command in a node alpine container

Awesome Lists containing this project

README

        

# Javascript Command Github Action

This is a simple action to allow you to run any command defined in your package.json e.g. `yarn test` or `npm test`. This command will install packages if that has not been done first, then run the supplied command.

Currently uses node:16.13.1-alpine3.15 docker container.

# Examples

## Test - Create React App

If you are using the default create react app, ensure that you pass in the flag `--watchAll=false` so that jest doesn't enter interactive mode, otherwise the action will never finish.

```yaml
on: [pull_request]

jobs:
tests:
name: run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Adzz/[email protected]
with:
command: test --watchAll=false
```

This will default to using `yarn` and the `test` command specified in your `package.json`. Alternatively you can define a specific script there:

```json
"scripts": {
...
"test:ci": "react-scripts test --watchAll=false",
},
```

Then do this:

```yaml
on: [pull_request]

jobs:
tests:
name: run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Adzz/[email protected]
with:
command: test:ci
```

### Using NPM instead of yarn

```yaml
on: [pull_request]

jobs:
tests:
name: run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Adzz/[email protected]
with:
package-manager: npm
command: test:ci
```

### Lint then test

In the `package.json`

```json
"scripts": {
...
"test:ci": "react-scripts test --watchAll=false",
"eslint": "eslint . --ext .js --ext .jsx --ext .gql --ext .graphql",
},
```

```yaml
on: [pull_request]

jobs:
eslint:
name: run linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Adzz/[email protected]
with:
command: eslint
tests:
name: run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Adzz/[email protected]
with:
command: test:ci
```