GithubHelp home page GithubHelp logo

usefulness / diffuse-action Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 0.0 266 KB

Github Action wrapper for the Jake Wharton's Diffuse library

License: MIT License

Python 100.00%
diff apk aab aar jar github-action pull-requests continuous-integration diffuse wharton

diffuse-action's Introduction

Diffuse - Github Action

.github/workflows/after_merge.yml

Simple Github Action wrapper for Jake Wharton's Diffuse tool.

Usage

The action only exposes output containing the diff, so to effectively consume its output it is highly recommended to use other Github Actions to customize your experience.

Configuration:

By default, this action uses Diffuse fork - https://github.com/usefulness/diffuse (due to: JakeWharton/diffuse#111)

  - id: diffuse
    uses: usefulness/diffuse-action@v1
    with:
      old-file-path: old/file/path/old_file.apk
      new-file-path: new/file/path/new_file.apk

You can override the config to use the original Diffuse binary

  - id: diffuse
    uses: usefulness/diffuse-action@v1
    with:
      old-file-path: old/file/path/old_file.apk
      new-file-path: new/file/path/new_file.apk
      diffuse-repo: JakeWharton/diffuse
      lib-version: 0.1.0
Parameters

old-file-path - Path to reference file the diff should be generated for
new-file-path - Path to current file the diff should be generated for
lib-version (Optional) - Overrides dependency version, by default uses the latest published version
diffuse-repo (Optional) - Overrides usefulness/diffuse as the default repository containing published release artifacts.

Outputs

See full list of outputs.
For example: referencing steps.diffuse.outputs.diff-gh-comment at a later stage will print Diffuse tool output as a nicely formatted github comment

Sample: Create Pull Request comment

TODO: explain why to use free actions/cache for now and list its limitation.
Good introduction to the problem: JakeWharton/dependency-tree-diff#8 (comment)

  1. Integrate with a regular Pull Request workflow:
name: Pull Request workflow

on:
  pull_request:

jobs:
  generate-diff:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v2
    
    - uses: actions/setup-java@v3
      with:
        distribution: 'temurin'
        java-version: 21
      
    - uses: gradle/actions/setup-gradle@v3
      with:
        arguments: assemble

    # Generating the diff starts here ๐Ÿ‘‡ 

    - uses: actions/cache@v2
      name: Download base
      with:
        path: diffuse-source-file
        key: diffuse-${{ github.event.pull_request.base.sha }}

    - id: diffuse
      uses: usefulness/diffuse-action@v1
      with:
        old-file-path: diffuse-source-file
        new-file-path: app/build/outputs/release/app.apk


    # Consuming action output starts here ๐Ÿ‘‡

    - uses: peter-evans/find-comment@v1
      id: find_comment
      with:
        issue-number: ${{ github.event.pull_request.number }}
        body-includes: Diffuse output

    - uses: peter-evans/create-or-update-comment@v1
      if: ${{ steps.diffuse.outputs.diff-raw != null || steps.find_comment.outputs.comment-id != null }}
      with:
        body: |
          Diffuse output (customize your message here): 

          ${{ steps.diffuse.outputs.diff-gh-comment }}
        edit-mode: replace
        comment-id: ${{ steps.find_comment.outputs.comment-id }}
        issue-number: ${{ github.event.pull_request.number }}
        token: ${{ secrets.GITHUB_TOKEN }}

    - uses: actions/upload-artifact@v2
      with:
        name: diffuse-output
        path: ${{ steps.diffuse.outputs.diff-file }}
  1. Integrate with you post-merge flow:
on:
  push:
    branches:
      - master
      - main
      - trunk
      - develop
      - maine
      - mane
  schedule:
    - cron: '0 3 * * 1,4'

jobs:
  diffuse_cache:
    runs-on: ubuntu-latest
    name: Cache artifact for diffuse
    steps:
      - uses: actions/checkout@v2
      
      - uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: 21
          
      - uses: gradle/actions/setup-gradle@v3
        with:
          arguments: assemble

      # Integration starts here ๐Ÿ‘‡ 
      
      - uses: actions/cache@v2
        name: Upload base
        with:
          path: diffuse-source-file
          key: diffuse-${{ github.sha }}

      # Copy your build artifact under `diffuse-source-file` name which will be saved in cache
      - run: cp /app/build/outputs/debug/sample-apk.apk diffuse-source-file 
        shell: bash

More examples

Sample application as a pull request comment
Corresponding workflow file

pull_request

๐Ÿ™ Praise ๐Ÿ™ be ๐Ÿ™ to ๐Ÿ™ Wharton ๐Ÿ™

diffuse-action's People

Contributors

mateuszkwiecinski avatar mergify[bot] avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

diffuse-action's Issues

TypeError exception

I tried to use this action for comparison two CSVs, unfortunately it fails. I tried both with the default diffuse-repo and with JakeWharton's one.
Please suggest.
TIA,
Vitaly

- id: diffuse
        uses: usefulness/diffuse-action@v1
        with:
          old-file-path: file1.csv
          new-file-path: file2.csv
          diffuse-repo: JakeWharton/diffuse
          lib-version: 0.1.0
Traceback (most recent call last):
  File "/home/runner/work/_actions/usefulness/diffuse-action/v1/entrypoint.py", line 139, in <module>
    print(" ".join(java_call))
TypeError: sequence item 4: expected str instance, NoneType found

Error during python3 install request on ubuntu-24.04 runners

I using the latest 0.10.1 version on the new ubuntu-24.04 runner.

python3 -m pip install requests
  # shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  # env:
  #  JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.11-9/x64
  # JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.11-9/x64

I receive the following error when the command above is executed:

error: externally-managed-environment

ร— This environment is externally managed
โ•ฐโ”€> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
    
    See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: .github/renovate.json
Error type: Invalid JSON (parsing failed)
Message: Syntax error: expecting end of expression or separator near ] "exte

Dependency Dashboard

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

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/after_merge.yml
  • actions/checkout v4
  • actions/setup-java v4
  • actions/upload-artifact v4
.github/workflows/main.yml
  • actions/checkout v4
  • actions/setup-java v4
  • actions/download-artifact v4
  • actions/download-artifact v4
  • peter-evans/find-comment v3
  • peter-evans/create-or-update-comment v4
  • actions/upload-artifact v4
  • actions/checkout v4
  • actions/setup-java v4
  • actions/download-artifact v4
  • actions/download-artifact v4
  • peter-evans/find-comment v3
  • peter-evans/create-or-update-comment v4
  • actions/upload-artifact v4
  • actions/upload-artifact v4
  • actions/upload-artifact v4
  • actions/upload-artifact v4
  • actions/checkout v4
  • actions/setup-java v4
  • actions/download-artifact v4
  • actions/download-artifact v4
  • actions/upload-artifact v4
  • actions/upload-artifact v4

  • 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.