Skip to content

Commit 564709a

Browse files
committed
feat initial pattern
0 parents  commit 564709a

File tree

7 files changed

+129
-0
lines changed

7 files changed

+129
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Dependency Review Action
2+
#
3+
# This Action will scan dependency manifest files that change as part of a Pull Request,
4+
# surfacing known-vulnerable versions of the packages declared or updated in the PR.
5+
# Once installed, if the workflow run is marked as required,
6+
# PRs introducing known-vulnerable packages will be blocked from merging.
7+
#
8+
# Source repository: https://github.com/actions/dependency-review-action
9+
name: 'Dependency Review'
10+
on: [pull_request]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
dependency-review:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Harden Runner
20+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
21+
with:
22+
egress-policy: audit
23+
24+
- name: 'Checkout Repository'
25+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
26+
- name: 'Dependency Review'
27+
uses: actions/dependency-review-action@0efb1d1d84fc9633afcdaad14c485cbbc90ef46c # v2.5.1

.github/workflows/main.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Run grit patterns test
2+
3+
env:
4+
GRIT_TELEMETRY_DISABLED: "true"
5+
6+
on:
7+
push:
8+
branches: [main]
9+
pull_request:
10+
branches: [main]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
runs-on: ${{ matrix.runner }}
18+
19+
strategy:
20+
matrix:
21+
runner: [nscloud-ubuntu-22.04-amd64-4x16]
22+
node-version: [20.x]
23+
24+
steps:
25+
- name: Harden Runner
26+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
27+
with:
28+
egress-policy: audit
29+
30+
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
31+
32+
- name: Use Node.js ${{ matrix.node-version }}
33+
uses: actions/setup-node@7c12f8017d5436eb855f1ed4399f037a36fbd9e8 # v2.5.2
34+
with:
35+
node-version: ${{ matrix.node-version }}
36+
37+
- name: install-ruff
38+
run: |
39+
pip install ruff
40+
41+
- name: Install @getgrit/launcher
42+
run: npm install -g @getgrit/launcher
43+
44+
- name: Run doctor
45+
run: npx grit doctor
46+
47+
- name: Run grit patterns test
48+
run: npx grit patterns test

.grit/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
engine.log
2+
.gritmodules

.grit/grit.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version: 0.0.1
2+
patterns: []
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
engine marzano(0.1)
2+
language universal
3+
4+
pattern foo_to_bar() {
5+
contains `foo` => `bar`
6+
}

CONTRIBUTING.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Contributor Guide
2+
3+
## Getting started
4+
5+
Make sure you have the Grit CLI installed:
6+
7+
```sh
8+
npm install -g @getgrit/launcher
9+
```
10+
11+
To propose changes, fork this repository and open a pull request.
12+
13+
## Adding a new pattern
14+
15+
All patterns require at least one sample validating the functionality. As a result, the best way to develop a
16+
GritQL pattern is often by starting with before and after sample(s) of the code to be transformed. You can
17+
iterate in the [GritQL studio](https://app.grit.io/studio) to develop your pattern.
18+
19+
Once you have a pattern, you can add it to the repository by creating a new `.md` file in the `.grit/patterns`
20+
directory. The file name should be the snake-cased name of the pattern. Keep the file name short and
21+
descriptive, and add a concise description as well as any relevant tags. All PRs must contain at least
22+
one sample of before/after code with a descriptive name.
23+
24+
## Testing
25+
26+
Samples can be tested locally using the Grit CLI.
27+
28+
```sh
29+
grit patterns test
30+
```
31+
32+
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.

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Grit Patterns
2+
3+
This repository contains curated Grit patterns.
4+
5+
## License
6+
7+
This repository is licensed exclusively for usage with the Grit tool.
8+
All rights reserved.
9+
10+
## Contributing
11+
12+
We welcome contributions from the community. Please see the [contributing guide](CONTRIBUTING.md) for more information.

0 commit comments

Comments
 (0)