Skip to content

Commit

Permalink
feat initial pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
ilevyor committed Dec 7, 2023
0 parents commit 564709a
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Dependency Review Action
#
# This Action will scan dependency manifest files that change as part of a Pull Request,
# surfacing known-vulnerable versions of the packages declared or updated in the PR.
# Once installed, if the workflow run is marked as required,
# PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit

- name: 'Checkout Repository'
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: 'Dependency Review'
uses: actions/dependency-review-action@0efb1d1d84fc9633afcdaad14c485cbbc90ef46c # v2.5.1
48 changes: 48 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Run grit patterns test

env:
GRIT_TELEMETRY_DISABLED: "true"

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
build:
runs-on: ${{ matrix.runner }}

strategy:
matrix:
runner: [nscloud-ubuntu-22.04-amd64-4x16]
node-version: [20.x]

steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit

- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@7c12f8017d5436eb855f1ed4399f037a36fbd9e8 # v2.5.2
with:
node-version: ${{ matrix.node-version }}

- name: install-ruff
run: |
pip install ruff
- name: Install @getgrit/launcher
run: npm install -g @getgrit/launcher

- name: Run doctor
run: npx grit doctor

- name: Run grit patterns test
run: npx grit patterns test
2 changes: 2 additions & 0 deletions .grit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
engine.log
.gritmodules
2 changes: 2 additions & 0 deletions .grit/grit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version: 0.0.1
patterns: []
6 changes: 6 additions & 0 deletions .grit/patterns/universal/basic_example.grit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
engine marzano(0.1)
language universal

pattern foo_to_bar() {
contains `foo` => `bar`
}
32 changes: 32 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Contributor Guide

## Getting started

Make sure you have the Grit CLI installed:

```sh
npm install -g @getgrit/launcher
```

To propose changes, fork this repository and open a pull request.

## Adding a new pattern

All patterns require at least one sample validating the functionality. As a result, the best way to develop a
GritQL pattern is often by starting with before and after sample(s) of the code to be transformed. You can
iterate in the [GritQL studio](https://app.grit.io/studio) to develop your pattern.

Once you have a pattern, you can add it to the repository by creating a new `.md` file in the `.grit/patterns`
directory. The file name should be the snake-cased name of the pattern. Keep the file name short and
descriptive, and add a concise description as well as any relevant tags. All PRs must contain at least
one sample of before/after code with a descriptive name.

## Testing

Samples can be tested locally using the Grit CLI.

```sh
grit patterns test
```

Once you have your sample(s) passing locally, creating a PR will automatically trigger a CI build running the same tests in a range of environments.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Grit Patterns

This repository contains curated Grit patterns.

## License

This repository is licensed exclusively for usage with the Grit tool.
All rights reserved.

## Contributing

We welcome contributions from the community. Please see the [contributing guide](CONTRIBUTING.md) for more information.

0 comments on commit 564709a

Please sign in to comment.