Giter Club home page Giter Club logo

syncpack-github-action's Introduction

syncpack-github-action

A GitHub Action to Synchronise monorepo dependency versions with syncpack.

⚠️ Project Status

syncpack is stable but this GitHub Action is very new (May 15th 2022).

🌩 Installation

  1. Create a .syncpackrc file in the root of your project.

    {
      "dev": true,
      "filter": ".",
      "indent": "  ",
      "overrides": true,
      "peer": true,
      "prod": true,
      "resolutions": true,
      "workspace": true,
      "semverGroups": [],
      "semverRange": "",
      "sortAz": [
        "contributors",
        "dependencies",
        "devDependencies",
        "keywords",
        "peerDependencies",
        "resolutions",
        "scripts"
      ],
      "sortFirst": ["name", "description", "version", "author"],
      "source": [],
      "versionGroups": []
    }
  2. Create a /.github/workflows/syncpack.yml workflow to run syncpack on Pull Requests.

    on:
      # Run whenever a pull request is updated
      pull_request:
        branches:
          - main
    jobs:
      syncpack:
        runs-on: ubuntu-latest
        name: syncpack
        steps:
          # Check out the branch so we can read/write its files
          - uses: actions/checkout@v3
          # Use Node.js as syncpack is written in that
          - uses: actions/setup-node@v3
            with:
              node-version: 16
          - uses: JamieMason/[email protected]
            env:
              # If any options are set to 'fix' then
              # env.GITHUB_TOKEN is needed to push to PRs
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  3. Unless you don't plan to use fix to commit automatic fixes to your Pull Requests, go to /settings/actions in your repository and enable Read and write permissions under Workflow permissions.

🛠 Settings

All settings are optional, and their default values are listed below.

with:
  # Email to be used when the GitHub Action Commits and Comments
  bot-email: '[email protected]'
  # GitHub Username to be used when the GitHub Action Commits and
  # Comments
  bot-username: 'github-actions[bot]'
  # Commit message to be used when auto-fixing PRs
  commit-message: 'chore(syncpack): format and sync package.json files'
  # How to handle unconventional formatting/ordering of package.json
  # files
  #
  # * 'fix' - Auto-fix and commit to the PR
  # * 'ignore' - Do nothing
  format-mismatches: 'fix'
  # Whether to update package-lock.json, pnpm-lock.yaml, or yarn.lock
  # when semver range or version mismatches have been auto-fixed
  #
  # * 'fix' - Auto-fix and commit to the PR
  # * 'ignore' - Do nothing
  lockfile-mismatches: 'fix'
  # The specific version of your chosen `package-manager`
  package-manager-version: 'latest'
  # What to use to update your lockfile
  #
  # * 'npm'
  # * 'pnpm'
  # * 'yarn'
  package-manager: 'npm'
  # Ensure dependency versions follow a consistent format
  #
  # * 'lint' - Block merging the PR until manually fixed
  # * 'fix' - Auto-fix and commit to the PR
  # * 'ignore' - Do nothing
  semver-range-mismatches: 'fix'
  # Migrate to a newer version of syncpack than was available at the
  # time of writing this GitHub action
  syncpack-version: '7.2.1'
  # How to handle dependencies which are required by multiple packages,
  # where the version is not the same across every package
  #
  # * 'lint' - Block merging the PR until manually fixed
  # * 'fix' - Auto-fix and commit to the PR
  # * 'ignore' - Do nothing
  version-mismatches: 'fix'

syncpack-github-action's People

Contributors

horusgoul avatar jamiemason avatar jonathansadowski avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

syncpack-github-action's Issues

Skip empty comments

Would it be possible to skip commenting the PR if there were no fixes (or lint errors) from the syncpack?
CleanShot 2023-03-10 at 15 08 18

Cannot create comment on dependabot PR's

Whenever i merge a PR to my main branch, syncpack action will fail in the step where he tries to add a comment:

Screenshot 2022-11-16 at 07 59 09

This makes sense to me, because in the moment he tries to add the comment, there is no pull request anymore, as it was just merged to main. Easy fix -> i disabled running syncpack on pushes to main.

But now, i get the same behavior in dependabot pull requests, where it should work i guess?

Screenshot 2022-11-16 at 08 02 17

But now i think it is a bug that he cannot add his comment to the pull-request.

Syncpack commit doesn't trigger CI checks

Whenever the syncpack action is applying changes and commits them to the open pull request, it doesn't trigger a new CI run..
All my CI jobs don't have an "if", so they should be triggered i guess? Could this be a bug of syncpack-github-action?

Screenshot 2022-11-16 at 11 13 29

How to run in lint only (no fixing) mode

Hi!

I have the following action

name: Test PNPM dependencies are in sync across packages

on:
  push:
    paths:
      - src/pnpm-lock.yaml
      - src/pnpm-workspace.yaml
      - .syncpackrc.json
      - .github/workflows/test-pnpm-synced-dependencies.yml

jobs:
  check-pnpm-lock-versions:
    runs-on: ubuntu-22.04
    name: Test PNPM dependencies are in sync across packages
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
      - uses: JamieMason/[email protected]
        with:
          package-manager: "pnpm"
          format-mismatches: "ignore"
          lockfile-mismatches: "ignore"
          semver-range-mismatches: "ignore"
          version-mismatches: "lint"

Basically it should be lint only, no fixing mode. But when I try to run it it gives the following error

image

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.