great-expectations / great_expectations_action

A GitHub Action that makes it easy to use Great Expectations to validate your data pipelines in your CI workflows.
MIT License
78 stars 12 forks source link

Action should be able to comment on a PR if a validation passes #71

Closed Aylr closed 4 years ago

Aylr commented 4 years ago

STR

  1. configure action as follows note the desire to have comments appear on passes and failures:
#Automatically Runs Great Expectation Checkpoints on every push to a PR, and provides links to hosted Data Docs if there an error.
name: PR Push
on: pull_request

jobs:
  great_expectations_validation:
    runs-on: ubuntu-latest
    steps:

      # Clone the contents of the repository
    - name: Copy Repository Contents
      uses: actions/checkout@main

      # Run Great Expectations and deploy Data Docs to Netlify
    - name: Run Great Expectation Checkpoints
      uses: superconductive/great_expectations_action@main
      continue-on-error: true
      with:
        CHECKPOINTS: "locations.rds.chk"
        NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
      env:
        DB_HOST: ${{ secrets.DB_HOST }}
        DB_PASS: ${{ secrets.DB_PASS }}
        DB_USER: ${{ secrets.DB_USER }} 

    # If a checkpoint failed, comment on the PR with a link to the Data Docs hosted on Netlify.
    - name: Comment on PR upon Checkpoint failure
      #      if: steps.ge.outputs.checkpoint_failure_flag == '1'
      uses: actions/github-script@v2
      with:
        github-token: ${{secrets.GITHUB_TOKEN}}
        script: |
            github.issues.createComment({
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            body: `Failed Great Expectations Checkpoint(s) \`${FAILED_CHECKPOINTS}\` detected for: ${process.env.GITHUB_SHA}.  Corresponding Data Docs have been generated and can be viewed [here](${process.env.URL}).`
            })
      env:
        URL: ${{ steps.ge.outputs.docs_url }}
        FAILED_CHECKPOINTS: ${{ steps.ge.outputs.failing_checkpoints }}
  1. Run action
  2. Note output
    
    2020-09-03T23:40:45.0622474Z ##[group]Run actions/github-script@v2
    2020-09-03T23:40:45.0622674Z with:
    2020-09-03T23:40:45.0623494Z   github-token: ***
    2020-09-03T23:40:45.0623761Z   script: github.issues.createComment({
    issue_number: context.issue.number,
    owner: context.repo.owner,
    repo: context.repo.repo,
    body: `Failed Great Expectations Checkpoint(s) \`${FAILED_CHECKPOINTS}\` detected for: ${process.env.GITHUB_SHA}.  Corresponding Data Docs have been generated and can be viewed [here](${process.env.URL}).`
    })

2020-09-03T23:40:45.0623989Z debug: false 2020-09-03T23:40:45.0624143Z user-agent: actions/github-script 2020-09-03T23:40:45.0624378Z result-encoding: json 2020-09-03T23:40:45.0624683Z env: 2020-09-03T23:40:45.0624842Z URL: 2020-09-03T23:40:45.0624989Z FAILED_CHECKPOINTS: 2020-09-03T23:40:45.0625134Z ##[endgroup] 2020-09-03T23:40:45.1269210Z ReferenceError: FAILED_CHECKPOINTS is not defined 2020-09-03T23:40:45.1270390Z at eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:7985:56), :7:52) 2020-09-03T23:40:45.1271107Z at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:7986:12) 2020-09-03T23:40:45.1271833Z at main (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:8011:26) 2020-09-03T23:40:45.1272478Z at Module.833 (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:7995:1) 2020-09-03T23:40:45.1273197Z at __webpack_require__ (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:22:30) 2020-09-03T23:40:45.1273826Z at startup (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:37:19) 2020-09-03T23:40:45.1274447Z at /home/runner/work/_actions/actions/github-script/v2/dist/index.js:43:18 2020-09-03T23:40:45.1276052Z ##[error]Unhandled error: ReferenceError: FAILED_CHECKPOINTS is not defined 2020-09-03T23:40:45.1279390Z at Object. (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:46:10) 2020-09-03T23:40:45.1279842Z at Module._compile (internal/modules/cjs/loader.js:959:30) 2020-09-03T23:40:45.1280723Z at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)

hamelsmu commented 4 years ago

Hi @Aylr I was not able to make the Action fail. I expanded the test coverage to test this scenario -- see https://github.com/superconductive/great_expectations_action/pull/74

Perhaps we can pair program again!!?? I could be missing something? Ping me on slack