Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
plus-square

GitHub Action

Smart Diff

v0.1.1

Smart Diff

plus-square

Smart Diff

Perform a diff between two files given a tolerance and send notifications

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Smart Diff

uses: LouisBrunner/[email protected]

Learn more about this action in LouisBrunner/diff-action

Choose a version

GitHub Actions: diff-action build-test

This GitHub Action allows you to compare two files based on a tolerance, output the result to a file and send various notifications (comment on a linked GitHub issue/pull request, create a Check Run, ...), etc.

Usage

The following shows how to compare two files, making sure only additions happened, and output the difference to a file.

name: "build-test"
on: [push]

jobs:
  test_something:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: LouisBrunner/[email protected]
      with:
        old: file1.txt
        new: file2.txt
        mode: addition
        tolerance: better
        output: out.txt

See the examples workflow for more details and examples (and see the associated runs to see how it will look like).

Inputs

old

Required The first file to compare

new

Required The second file to compare

mode

Required The method used to measure the tolerance, can be either addition (addition are better) or deletion (deletion are better)

tolerance

Required The tolerance to check the diff for, depends on mode, can be either (examples given with mode = deletion) better (only deletion), mixed-better (more deletion than addition), same (stay the exact same), mixed (same amount of lines but not the same), mixed-worse (more addition than deletion) or worse (only addition)

output

Optional The path where to output the diff (as well as on the console)

token

Optional Your GITHUB_TOKEN, required when using notify_check and/or notify_issue

title

Optional add a title to the notifications to distinguish between multiple workflows/jobs

notify_check

Optional Will create a GitHub Check Run if 'true' is specified, requires token to be given as well

notify_issue

Optional Will create a comment in the linked issue if 'true' is specified, requires token to be given as well

Outputs

passed

Contains a boolean ('true' or 'false') representing if the check passed or not

output

Contains the output of the diff

Issues

  • Add a mode for the tolerance so addition can be better than deletion (which isn't possible now)