Skip to content

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

License

Notifications You must be signed in to change notification settings

Adzz/yarn_command_action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

on: [pull_request]

jobs:
  tests:
    name: run tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: Adzz/jest_test_action@v1.0.0
        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:

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

Then do this:

on: [pull_request]

jobs:
  tests:
    name: run tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: Adzz/jest_test_action@v1.0.0
        with:
          command: test:ci

Using NPM instead of yarn

on: [pull_request]

jobs:
  tests:
    name: run tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: Adzz/jest_test_action@v1.0.0
        with:
          package-manager: npm
          command: test:ci

Lint then test

In the package.json

 "scripts": {
    ...
    "test:ci": "react-scripts test --watchAll=false",
    "eslint": "eslint . --ext .js --ext .jsx --ext .gql --ext .graphql",
  },
on: [pull_request]

jobs:
  eslint:
    name: run linter
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: Adzz/jest_test_action@v1.0.0
        with:
          command: eslint
  tests:
    name: run tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: Adzz/jest_test_action@v1.0.0
        with:
          command: test:ci