Giter Site home page Giter Site logo

ionbazan / composer-diff-action Goto Github PK

View Code? Open in Web Editor NEW
16.0 1.0 3.0 47 KB

Compare composer.lock files and generate human-readable list of package changes

License: MIT License

Dockerfile 52.02% Shell 47.98%
github markdown php diff composer packagist packages pullrequest composer-plugin composer-diff

composer-diff-action's Issues

It stopped to work

Got error message today:

In PackageDiff.php line 135:

  Could not open file ad66625dce6fd04da4b628f870a7230cce53fd10:apps/silverbac  
  k-drupal/composer.lock or find it in git as ad66625dce6fd04da4b628f870a7230  
  cce53fd10:apps/silverback-drupal/composer.lock 

I tried to debug it by adding a new job step:

git show ad66625dce6fd04da4b628f870a7230cce53fd10:apps/silverback-drupal/composer.lock

This one worked without any issues.

Debugging here: AmazeeLabs/silverback-mono#1021

composer_diff_exit_code value is always 0

I just started using this action but it never posts a comment, even when there is output in the diff (because the exit code is 0). I think the issue is that the README is newer than the most recent release so the code that runs in the action doesn't match the posted docs. The needed PR is #5

[SOLVED] Setting target parameter does not seem to work.

We have a project where the composer.lock file is situated in a subfolder (packages/backend/).

I tried to set the target parameter to configure this, but I can't seem to find the correct one.

This is the last one I tried:

name: Composer Diff
on:
  pull_request:
    paths:
      - 'packages/backend/composer.lock'
jobs:
  composer-diff:
    name: Composer Diff
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0 # Required to make it possible to compare with PR base branch

      - name: Generate composer diff
        id: composer_diff # To reference the output in comment
        uses: IonBazan/composer-diff-action@v1
        with:
          target: ${{ github.event.pull_request.base.sha }}:packages/backend/composer.lock

      - uses: marocchino/sticky-pull-request-comment@v2
        # An empty diff result will break this action.
        if: ${{ steps.composer_diff.outputs.composer_diff_exit_code != 0 }}
        with:
          target: ${{ github.event.pull_request.base.sha }}:packages/backend/composer.lock
          header: composer-diff # Creates a collapsed comment with the report
          message: |
            <details>
            <summary>Composer package changes</summary>

            ${{ steps.composer_diff.outputs.composer_diff }}

            </details>

In the "Generate composer diff" step we receive the error Could not open file 2a6af2d592e1f11b0d4e535bb096133d62096101 or find it in git as 2a6af2d592e1f11b0d4e535bb096133d62096101:composer.lock: fatal: path 'composer.lock' does not exist in '2a6af2d592e1f11b0d4e535bb096133d62096101

In the "Run marocchino/sticky-pull-request-comment@v2" step we receive the warning Unexpected input(s) 'target', valid inputs are ['header', 'append', 'recreate', 'delete', 'only_create', 'only_update', 'hide_details', 'hide', 'hide_and_recreate', 'hide_classify', 'message', 'path', 'ignore_empty', 'skip_unchanged', 'follow_symbolic_links', 'number', 'owner', 'repo', 'GITHUB_TOKEN'].

These two errors tell me that the target keys in the config are at the wrong place. Could someone point us in the right direction here?

[help] trying to make it work on a scheduled composer update

hi there!

You action works perfectly on my PR workflow, no problem there.
I'd like to commit a composer update on a schedule. here is my workflow:

'on':
  schedule:
    -
      cron: '24 6 * * 1,2,3,4,5'
  workflow_dispatch: null
jobs:
  composer_update_job:
    runs-on: ubuntu-latest
    name: 'composer update'
    steps:
    
      - name: Get current date
        id: date
        run: echo "::set-output name=date::$(date +'%Y-%m-%d')" 
      -
        name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      -
        name: 'Setup PHP'
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.0'
      -
        name: 'Run composer update'
        run: 'composer update --no-dev --no-progress'
        id: run_composer
        
      - name: Generate composer diff
        id: composer_diff # To reference the output in comment
        uses: IonBazan/composer-diff-action@v1
        with: 
          no-dev: true
          format: mdlist
      -
        name: 'Create Pull Request'
        uses: peter-evans/create-pull-request@v4
        id: cpr
        with:
          token: '${{ secrets.MERGE_TOKEN }}'
          commit-message: ${{ steps.composer_diff.outputs.composer_diff }}
          committer: 'Woogo Bot <[email protected]>'
          author: 'Woogo Bot <[email protected]>'
          branch: woogobot/composer-update
          delete-branch: true
          title: 'feat(plugins) composer update'
          labels: 'composer update'

The output of ${{ steps.composer_diff.outputs.composer_diff }} is empty there. However in the PR check, it will be correct.

What am I doing wrong here ?

Thanks!

Empty output is not truly empty

When there is no changes to the lock file, an empty composer_diff output is produced, but it's not truly empty.

See log of one oof my workflows:

##[debug]Evaluating: format('{0}
##[debug]', steps.composer_diff.outputs.composer_diff)
##[debug]Evaluating format:
##[debug]..Evaluating String:
##[debug]..=> '{0}
##[debug]'
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating steps:
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'composer_diff'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'outputs'
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'composer_diff'
##[debug]..=> ''
##[debug]=> '
##[debug]'
##[debug]Result: '
##[debug]'

then marocchino/sticky-pull-request-comment@v2 fails with Error: Either message or path input is required, but I cannot check if the output is an empty string like '' and skip the step, because it's not an empty string

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.