Kaynağa Gözat

Merge pull request #136 from amaanq/ci-lint

Add CI & Lint actions
pull/138/head
Yoann Padioleau 3 yıl önce
işlemeyi yapan: GitHub
ebeveyn
işleme
a015709e7d
Veri tabanında bu imza için bilinen anahtar bulunamadı GPG Anahtar Kimliği: 4AEE18F83AFDEB23
13 değiştirilmiş dosya ile 326 ekleme ve 196 silme
  1. +20
    -0
      .eslintrc.js
  2. +4
    -0
      .gitattributes
  3. +30
    -0
      .github/workflows/ci.yml
  4. +19
    -0
      .github/workflows/lint.yml
  5. +0
    -1
      .npmignore
  6. +2
    -1
      Cargo.toml
  7. +1
    -1
      Package.swift
  8. +3
    -3
      README.md
  9. +15
    -13
      bindings/node/binding.cc
  10. +4
    -4
      bindings/node/index.js
  11. +1
    -1
      bindings/rust/build.rs
  12. +220
    -172
      grammar.js
  13. +7
    -0
      package.json

+ 20
- 0
.eslintrc.js Dosyayı Görüntüle

@ -0,0 +1,20 @@
module.exports = {
'env': {
'commonjs': true,
'es2021': true,
},
'extends': 'google',
'overrides': [
],
'parserOptions': {
'ecmaVersion': 'latest',
'sourceType': 'module',
},
'rules': {
'indent': ['error', 2, {'SwitchCase': 1}],
'max-len': [
'error',
{'code': 120, 'ignoreComments': true, 'ignoreUrls': true, 'ignoreStrings': true},
],
},
};

+ 4
- 0
.gitattributes Dosyayı Görüntüle

@ -1,2 +1,6 @@
/src/** linguist-vendored
/examples/* linguist-vendored
src/grammar.json -diff
src/node-types.json -diff
src/parser.c -diff

+ 30
- 0
.github/workflows/ci.yml Dosyayı Görüntüle

@ -0,0 +1,30 @@
name: CI
on:
workflow_dispatch:
pull_request:
push:
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm install
- run: npm test
test_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm install
- run: npm run test-windows

+ 19
- 0
.github/workflows/lint.yml Dosyayı Görüntüle

@ -0,0 +1,19 @@
name: Lint
on:
push:
branches:
- master
pull_request:
branches:
- "**"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install modules
run: npm install
- name: Run ESLint
run: npm run lint

+ 0
- 1
.npmignore Dosyayı Görüntüle

@ -3,4 +3,3 @@
/build
/script
/target

+ 2
- 1
Cargo.toml Dosyayı Görüntüle

@ -9,6 +9,7 @@ keywords = ["incremental", "parsing", "c"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-c"
edition = "2018"
autoexamples = false
build = "bindings/rust/build.rs"
include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"]
@ -17,7 +18,7 @@ include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"]
path = "bindings/rust/lib.rs"
[dependencies]
tree-sitter = "0.20"
tree-sitter = "0.20.10"
[build-dependencies]
cc = "1.0"

+ 1
- 1
Package.swift Dosyayı Görüntüle

@ -33,4 +33,4 @@ let package = Package(
publicHeadersPath: "bindings/swift",
cSettings: [.headerSearchPath("src")])
]
)
)

+ 3
- 3
README.md Dosyayı Görüntüle

@ -1,7 +1,7 @@
tree-sitter-c
==================
# tree-sitter-c
[![Build Status](https://travis-ci.org/tree-sitter/tree-sitter-c.svg?branch=master)](https://travis-ci.org/tree-sitter/tree-sitter-c)
[![Build status](https://ci.appveyor.com/api/projects/status/7u0sy6ajmxro4wfh/branch/master?svg=true)](https://ci.appveyor.com/project/maxbrunsfeld/tree-sitter-c/branch/master)
C grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter). Adapted from [this C99 grammar](http://slps.github.io/zoo/c/iso-9899-tc3.html).
C grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
Adapted from [this C99 grammar](http://slps.github.io/zoo/c/iso-9899-tc3.html).

+ 15
- 13
bindings/node/binding.cc Dosyayı Görüntüle

@ -1,28 +1,30 @@
#include "nan.h"
#include "tree_sitter/parser.h"
#include <node.h>
#include "nan.h"
using namespace v8;
extern "C" TSLanguage * tree_sitter_c();
extern "C" TSLanguage *tree_sitter_c();
namespace {
NAN_METHOD(New) {}
void Init(Local<Object> exports, Local<Object> module) {
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_c());
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("c").ToLocalChecked());
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
Local<Object> instance =
constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_c());
Nan::Set(instance, Nan::New("name").ToLocalChecked(),
Nan::New("c").ToLocalChecked());
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
}
NODE_MODULE(tree_sitter_c_binding, Init)
} // namespace
} // namespace

+ 4
- 4
bindings/node/index.js Dosyayı Görüntüle

@ -1,19 +1,19 @@
try {
module.exports = require("../../build/Release/tree_sitter_c_binding";);
module.exports = require('../../build/Release/tree_sitter_c_binding';);
} catch (error1) {
if (error1.code !== 'MODULE_NOT_FOUND') {
throw error1;
}
try {
module.exports = require("../../build/Debug/tree_sitter_c_binding";);
module.exports = require('../../build/Debug/tree_sitter_c_binding';);
} catch (error2) {
if (error2.code !== 'MODULE_NOT_FOUND') {
throw error2;
}
throw error1
throw error1;
}
}
try {
module.exports.nodeTypeInfo = require("../../src/node-types.json";);
module.exports.nodeTypeInfo = require('../../src/node-types.json';);
} catch (_) {}

+ 1
- 1
bindings/rust/build.rs Dosyayı Görüntüle

@ -5,7 +5,7 @@ fn main() {
let src_dir = Path::new("src");
let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable")

+ 220
- 172
grammar.js
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 7
- 0
package.json Dosyayı Görüntüle

@ -17,10 +17,13 @@
"nan": "^2.14.0"
},
"devDependencies": {
"eslint": "^8.41.0",
"eslint-config-google": "^0.14.0",
"tree-sitter-cli": "^0.20.0"
},
"scripts": {
"build": "tree-sitter generate && node-gyp build",
"lint": "eslint grammar.js",
"test": "tree-sitter test && tree-sitter parse examples/* --quiet --time",
"test-windows": "tree-sitter test"
},
@ -30,6 +33,10 @@
"file-types": [
"c",
"h"
],
"injection-regex": "^(c|h)$",
"highlights": [
"queries/highlights.scm"
]
}
]

Yükleniyor…
İptal
Kaydet