Git Product home page Git Product logo

yarn-lock-changes's Introduction

Yarn Lock Changes

Creates a comment inside Pull Request with the human-readable summary of the changes to the yarn.lock file. Works in public and private repositories, offers a degree of customization.

Usage

⚡️ Workflow Example

Example below shows the minimal workflow setup, required action input (token) and all the optional inputs (set to theirs default values). If you are happy with the output generated by the action, it's safe to remove all optional inputs.

name: Yarn Lock Changes
on: [pull_request]

jobs:
  yarn_lock_changes:
    runs-on: ubuntu-latest
    # Permission overwrite is required for Dependabot PRs, see "Common issues" section below.
    permissions:
      pull-requests: write
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Yarn Lock Changes
        # Please use `main` as version before the stable release will be published as `v1`.
        uses: Simek/yarn-lock-changes@main
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          # Optional inputs, can be deleted safely if you are happy with default values.
          collapsibleThreshold: 25
          failOnDowngrade: false
          path: yarn.lock
          updateComment: true
          groupByType: false

Note

For Node <18 support, you can change the action version tag in your workflow to v0.11, instead of using main:

- name: Yarn Lock Changes
  uses: Simek/[email protected]

🔌 Inputs

Input Required Default Description
token Yes Repository GITHUB_TOKEN which allows action to make calls to the GitHub API (Octokit).
collapsibleThreshold No 25 Number of lock changes, which will result in collapsed comment content, and an addition of changes summary table.
failOnDowngrade No false WFail the action when a dependency downgrade is detected. Comment will still be posted.
path No yarn.lock Path to the yarn.lock file in the repository. Default value points to the file at project root.
updateComment No true Update the comment on each new commit. If value is set to false, bot will post a new comment on each change.
groupByType No false Group the dependencies in the comment table by the change type.

📸 Preview

Basic comment appearance

basic

Comment appearance when collapsibleThreshold has been reached

summary

📋 Common issues

The action fails on the Dependabot pull requests

Due to the security reasons from March 1st, 2021 workflow runs that are triggered by Dependabot have permissions reduced by default:

To ensure that sufficient permissions for this action are always granted, you will need to add permissions entry to the job which runs yarn-lock-changes:

jobs:
  ...:
    runs-on: ...
    #####
    permissions:
      pull-requests: write
    #####
    steps:
      ...

The action fails in a private repository

After one of the GitHub Actions security breaches GitHub decided to trim down the default permission set for actions running in private repositories.

If you are trying to run action with default setup in the private repository, you will see the following error during checkout step:

remote: Repository not found.
Error: fatal: repository 'https://github.com/<your_user>/<your_repo>/' not found
Error: The process '/usr/bin/git' failed with exit code 128

This means that you will need to add the following permissions entry to the job which runs checkout:

jobs:
  ...:
    runs-on: ...
    #####
    permissions:
      contents: read
    #####
    steps:
      ...

If you would like to learn a little bit more about this problem, you can visit this issue in the GitHub Checkout Action repository:

🔍️ Debugging

To run action in the debug mode you need to add the ACTIONS_STEP_DEBUG repository secret and set it to true, as stated in the GitHub documentation.

Then additional information which might be useful for the users when debugging the issues will be available in the action output, prefixed by ##[debug].

yarn-lock-changes's People

Contributors

dependabot[bot] avatar nathanforce avatar simek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

yarn-lock-changes's Issues

Cannot read `yarn.lock` larger than 1MB

Hi,

Thanks for creating this action - it would be useful for my CI/CD. However, our yarn.lock is 1.1MB and the action fails with the following message:

Run Simek/yarn-lock-changes@main
  with:
    collapsibleThreshold: 25
    path: yarn.lock
    token: ***
    updateComment: true

Error: This API returns blobs up to 1 MB in size. The requested blob is too large to fetch via the API, but you can use the Git Data API to request blobs up to 100 MB in size.: {"resource":"Blob","field":"data","code":"too_large"}

`yarn-lock-changes` gets confused when a PR is on an older commit than default branch

When the default branch has a yarn.lock with more recent packages than the branch that a PR is based on, yarn-lock-changes thinks that the PR is downgrading said packages even though it doesn't actually change yarn.lock. Example:

  • @babel/core is at 7.14.8 on default branch
  • PR is based on a commit that is just before the bump of @babel/core
  • yarn-lock-changes thinks that the PR is downgrading @babel/core

See microsoft/react-native-test-app#426.

Detect dependency depth and allow to configure max depth

Currently all dependency changes are listed in summary comment.

It will be nice to detect the depth of dependency and allow users to configure maxDepth via action inputs. This field should be optional and by default set to 0, which means that comment should include all the changes.

Can't find yarn.lock

Hi there!

I followed the instructions and running into the following error message:

image

I've made sure yarn.lock is available, at the root of the repository. It doesn't matter if the file is changes or not in the PR. Here is an example of the file changes in the PR:

image

Any guidance how to debug or resolve?

Feature request: support multiple yarn.lock files

Hello and thanks for developing and maintaining this action!

I have a bit of an unusual setup, in which my repo contains several projects. Sort of like a monorepo, but without all the extra tooling. Basically, my repo is in transition from a legacy app to a modern one:

/package.json and /yarn.lock for shared devDependencies.
/legacy-app/package.json and /legacy-app/yarn.lock for the legacy app.
/modern-app/package.json and /modern-app/yarn.lock for the modern app.

Is there a chance to add support for either detecting multiple yarn.lock files - or - specifying them explicitly, just like the current path allows, but for more than one?

Error: Resource not accessible by integration

Hi!

I'm getting the error Error: Resource not accessible by integration when the action runs on a PR created by a GitHub integration (dependabot). This makes the CI fail, I think it'd be better to just skip the workflow if it really can't run for integrations, if it can then this is a bug report :)

> Run Simek/yarn-lock-changes@main
  with:
    token: ***
    collapsibleThreshold: 25
    failOnDowngrade: false
    path: yarn.lock
    updateComment: true
Error: Resource not accessible by integration

This is the PR: mrousavy/react-native-vision-camera#158

Differentiate between dependency update and downgrade

Currently, no matter if the dependency was updated or downgraded, the reported status in the summary will be set to:

  • ⬆️ UPDATED

It will be nice to differentiate between those two states:

  • ⬆️ UPDATED
  • ⬇️ DOWNGRADED

Feature Request: more detailed/correct information when package become duplicated

Intro:
yarn.lock file may contain several versions of the same dependency.
When adding/upgrading packages using yarn, you sometimes end up not with an upgrade, but with an additional of another version of the package.

In the current state of this action, when another version is added, it still marks it as updated.
I think it will be more correct to mark it as "added" with the new version, and not as update, or created additional kind of indication for that.

I will try to open a PR to emphasis that.

Worth noting: yarn-deduplicate is an important tool that dramatically helps avoiding unneeded duplications (Some duplications are needed) https://github.com/atlassian/yarn-deduplicates

Group table by status type

Currently the table listing all the dependencies lists the dependencencies in alphabetical order based on the package name. This is fine for small diffs, but for large diffs it becomes harder to see which packages got removed/downgraded etc., at a glance.

It could be an option in the workflow step to first group the packages by status then alphabetically sort them within those groups in the table, i.e shown in the table as:

  • Added (a-z)
  • Updated (a-z)
  • Downgraded (a-z)
  • Removed (a-z)

Permissions not sufficient within private repositories

Problem

Using the example in the README.md within private repositories causes the checkout job to crash with the following error:

remote: Repository not found.
Error: fatal: repository 'https://github.com/<your_user>/<your_repo>/' not found

This problem is already tracked here.

Solution

In order to use this action within private repositories, i also needed to add write permissions for id-token and read permissions for contents to the job, as described here, so it looks like something like this:

...

yarn_lock_changes:
    runs-on: ubuntu-latest
    permissions:
        pull-requests: write
        id-token: write
        contents: read

...

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.