Giter Site home page Giter Site logo

nodejs-production-test-action's Introduction

node-production-test-action

Catches publishing problems

Motivation

Sometimes things can go awry if you, say, accidentally a production dependency as a dev dependency. Or omit a file from the files prop. Or get too excited about adding stuff to .npmignore. Or maybe the entry points are wrong. Or you are trying to provide dual ESM/CJS modules (in which case, you definitely need this).

This action will run a script (provided by you) within your package--as your package would appear to a consumer.

In other words, we want to check if npm install <your-pkg> actually installs a package that can be used.

Inputs

script

npm script name (as in the scripts prop of package.json) to run. Required.

workspace

Space-delimited list of one or more npm workspace names, paths, or a path to a workspace dir. Corresponds to the --workspace argument of npm pack. If present, will cause npm run-script to run for each resulting installation.

workspaces

Pack all workspaces. Corresponds to the --workspaces flag of npm pack. If true, will cause npm run-script to run for each resulting installation. Boolean.

includeWorkspaceRoot

If workspaces is true, also pack the workspace root. Corresponds to the --include-workspace-root flag of npm pack. Boolean.

extraNpmInstallArgs

Space-delimited list of extra arguments (including any leading dashes; e.g., --ignore-scripts) to use with npm install /path/to/tarball.tgz.

verbose

If true, print whatever npm is doing under the hood. Boolean.

json

If true, output the result of the action as a single JSON blob. The shape of this is defined by the SmokerJsonOutput type declared by midnight-smoker. Boolean.

Outputs

n/a

Example Usage

jobs:
  smoke:
    name: Smoke Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install dependencies
        run: npm install
      - uses: boneskull/nodejs-production-test-action@v1
        with:
          script: test:smoke # name of script in workspace
          # workspace: foo bar # // list of npm workspaces, if any
          # workspaces: false # // if `true`, run script for all workspaces
          # quiet: false # // do not suppress npm output
          # includeWorkspaceRoot: false # // also include workspace root if `workspaces` is true
          # extraNpmInstallArgs: '--ignore-scripts' # // extra flags for `npm install` of tarball (space-delimited), if needed

Local Testing

To mimic what GH actions would do, run node dist/index.js and set the following environment variables (all are required):

  • INPUT_SCRIPT=<your-script>
  • INPUT_QUIET=true or INPUT_QUIET=false
  • INPUT_WORKSPACES=true or INPUT_WORKSPACES=false
  • INPUT_INCLUDEWORKSPACEROOT=true or INPUT_INCLUDEWORKSPACEROOT=false
  • INPUT_JSON=true or INPUT_JSON=false

Using the same convention, other inputs can be set this way via environment variables.

Notes

  • npm run-script operations are run in serial due to the typical low CPU core count of CI machines and the inability to abort child processes via GH's actions toolkit. This may be re-enabled at a later time if an API with AbortSignal support can be leveraged.
  • The installation of tarballs happens within a single temp dir. At a later time, each npm install should happen in its own directory. This will necessarily cause a slowdown, because the npm install command is run against all tarballs at once.
  • The temp dir is removed at the end of the run.
  • Lifecycle script output from npm pack is always suppressed because it writes to STDOUT and thus inhibits parsing of its JSON output.

Roadmap

  • Run npm install and npm run-script in parallel (see notes).

Stuff I Won't Do But Will Entertain PRs For

  • Alternate package manager support
  • Execution of arbitrary scripts (instead of package.json scripts)

Non-Goals

  • Support for different CI services
  • Explicit support for unique or weird use-cases
  • Rewrite it in TypeScript

License

Copyright © 2022 Christopher "boneskull" Hiller. Licensed Apache-2.0

nodejs-production-test-action's People

Contributors

boneskull avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

sede-open

nodejs-production-test-action's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Package lookup failures

Warning

Renovate failed to look up the following dependencies: Could not determine new digest for update (github-tags package bahmutov/npm-install).

Files affected: .github/workflows/nodejs.yml


Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/nodejs.yml
  • actions/checkout v3@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
  • actions/setup-node v3@e33196f7422957bea03ed53f6fbb155025ffc7b8
  • bahmutov/npm-install v1@cb39a46f27f14697fec763d60fb23ad347e2befa
npm
package.json
  • @actions/core 1.10.0
  • @actions/exec 1.1.1
  • @actions/io 1.1.3
  • log-symbols 4.1.0
  • midnight-smoker 2.0.1
  • pluralize 8.0.0
  • @tsconfig/node16 16.1.1
  • @types/node 18.19.8
  • @types/pluralize 0.0.33
  • @vercel/ncc 0.38.1
  • cross-env 7.0.3
  • husky 8.0.3
  • lint-staged 13.3.0
  • prettier 3.2.4
  • typescript 5.3.3
  • node ^14.17.0 || ^16.13.0 || >=18.0.0
  • npm >=7

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.