Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish a GHA that ensures bluehawk snip was run #142

Open
nlarew opened this issue Apr 26, 2023 · 1 comment
Open

Publish a GHA that ensures bluehawk snip was run #142

nlarew opened this issue Apr 26, 2023 · 1 comment

Comments

@nlarew
Copy link
Contributor

nlarew commented Apr 26, 2023

The goal here is to ensure that the snippets generated from a given file/directory are up-to-date with the source files they're generated from via CI/CD in a reusable way.

The action should accept the path for a file or directory and run bluehawk snip on it.

Then, it should compare the output of the snippets it created with those in the PR branch (e.g. with git diff or md5 hashing if we have to).

If the snippets are identical, the action succeeds.

Otherwise, the action fails and reports out-of-date snippets & source files in the GHA stdout.

name: Ensure Node.js Bluehawk Snippets Are Up To Date

on:
  pull_request:
    paths:
      - "examples/node/**"

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: mongodb-university/bluehawk/github-actions/check-snip@main
        with:
          source: examples/node/Examples
          output: source/examples/generated/node

Example failure output:

Found 2 out-of-date snippets:

  { "source": "examples/node/Examples/mongodb.js", "snippet": "source/examples/generated/node/mongodb.snippet.find-a-single-document.js" }
  { "source": "examples/node/Examples/mongodb.js", "snippet": "source/examples/generated/node/mongodb.snippet.find-multiple-documents.js" }

To fix this, run:
   npx bluehawk snip examples/node/Examples -o source/examples/generated/node
@nlarew nlarew added this to Bluehawk Apr 26, 2023
@nlarew nlarew converted this from a draft issue Apr 26, 2023
@ragudigispoc
Copy link

bgg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants