Coder Social home page Coder Social logo

action-screenshot-diff's Introduction

action-visual-snapshot test

This is a GitHub action that compares 2-3 sets of images and produces a diff using pixelmatch. The idea is to have your tests generate screenshots, save those screenshots as an artifact in GitHub, compare them to a "base" (e.g. main branch) set of images and produce a diff image of the changed pixels, and then upload those diffs as an artifact as well.

Usage

There are two steps required in your GitHub workflow. First, upload your snapshots as GitHub Action artifact. path needs to reference the path where your snapshots are saved and name is the name of the artifact for GitHub.

  - name: Save snapshots
    if: always()
    uses: actions/upload-artifact@v2
    with:
      save-only: true
      path: .artifacts/visual-snapshots

Then you'll need to run the action to compare the snapshots (gcs-bucket and gcp-service-account-key are optional and will upload your images to the bucket if specified):

    visual-diff:
      if: ${{ github.ref != 'refs/heads/master' }}
      needs: acceptance
      runs-on: ubuntu-16.04

      steps:
        - name: Diff snapshots
          id: visual-snapshots-diff
          uses: getsentry/action-visual-snapshot@v1
          with:
            github-token: ${{ secrets.GITHUB_TOKEN }}
            gcs-bucket: 'sentry-visual-snapshots'
            gcp-service-account-key: ${{ secrets.SNAPSHOT_GOOGLE_SERVICE_ACCOUNT_KEY }}

Multiple diffs

You can also have multiple sets of diff actions with some configuration inputs

  - name: Diff snapshots
    id: visual-snapshots-diff
    uses: getsentry/action-visual-snapshot@v1
    with:
      snapshot-path: .artifacts/visual-snapshots-jest
      action-name: Jest Snapshots
      artifact-name: visual-snapshots-jest
      github-token: ${{ secrets.GITHUB_TOKEN }}

Contributing

WIP

Updating Image Gallery Template

The main template is src/template/index.ejs -- this gets "built" into a module (that is the actual template) that the action can use and inject data into.

yarn dev:gallery && open example_gallery/index.html

Files changes to src/template/index.ejs will rebuild the example_gallery/index.html file (although you currently need to save the file twice).

Publishing

Actions are run from GitHub repos so we will checkin the packed dist folder, this is done by GitHub Actions for all branches.

To do this manually, run ncc and push the results:

$ yarn dist
$ git add dist
$ git commit -a -m "prod dependencies"

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.