Skip to content

Commit

Permalink
Refactored the project to match other TS projects:
Browse files Browse the repository at this point in the history
- Set up editorconfig, linting, prettier rules
- Renamed folders to match other projects
- Changed unit testing stack from mocha/chai to jest
- Added github actions for npm publishing and CI
- Fixed linting errors
- Other various minor changes
  • Loading branch information
Andrew Bird committed Mar 31, 2021
1 parent a0732a4 commit 6345883
Show file tree
Hide file tree
Showing 51 changed files with 6,275 additions and 5,287 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = 2
indent_style = space
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
node_modules
coverage
.eslintrc.js
generated
56 changes: 56 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
},
plugins: ["@typescript-eslint", "eslint-comments", "jest", "promise"],
extends: [
"airbnb-typescript/base",
"plugin:@typescript-eslint/recommended",
"plugin:eslint-comments/recommended",
"plugin:jest/recommended",
"plugin:promise/recommended",
"prettier",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
env: {
node: true,
browser: true,
jest: true,
},
rules: {
// note you must disable the base rule as it can report incorrect errors
"quotes": ["error", "double"],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"],
"no-underscore-dangle": "off",
"lines-between-class-members": ["warn", "always"],
"@typescript-eslint/explicit-function-return-type": ["error"],
"@typescript-eslint/naming-convention": [
"error",
{ selector: "typeLike", format: ["PascalCase"] },
{ selector: "enumMember", format: ["PascalCase"] },
{ selector: "variableLike", format: ["camelCase"] },
{
selector: "interface",
format: ["PascalCase"],
custom: {
regex: "^I[A-Z]",
match: false,
},
},
{
selector: "typeAlias",
format: ["PascalCase"],
custom: {
regex: "^I[A-Z]",
match: false,
},
},
],
"class-methods-use-this": "off",
"jest/no-conditional-expect": "off"
},
};
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Code owners:
* @greenemcg @AndrewBird81 @adongare @jkotanchik-SB @serhii-ilin @RohitKandimalla
55 changes: 55 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: npm-publish
on:
push:
branches:
- main
jobs:
npm-publish:
name: npm-publish
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Use Node.js 14.x
uses: actions/setup-node@v2-beta
with:
node-version: 14.x

- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install node dependencies
run: npm ci

- name: Audit dependencies for security vulnerabilities
run: npm audit

- name: Lint the source code
run: npm run-script lint

- name: Build the source code
run: npm run build

- name: Execute test coverage
run: npm run-script coverage

- name: Publish if version has been updated
uses: pascalgn/npm-publish-action@master
with: # All of theses inputs are optional
tag_name: "v%s"
tag_message: "v%s"
commit_pattern: "[\\s\\S]*Release (\\S+)"
env: # More info about the environment variables in the README
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
86 changes: 86 additions & 0 deletions .github/workflows/unit_test_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# This workflow will do the following:
# - perform a clean install of node dependencies
# - lint the source code for errors
# - build the source code
# - run tests and capture code coverage
# - upload the code coverage report to Codacy
# - upload the code coverage report to Codecov

name: Continuous Integration

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

jobs:
build:
name: Checkout, install, lint, build and test with coverage
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Use Node.js 14.x
uses: actions/setup-node@v2-beta
with:
node-version: 14.x

- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install node dependencies
run: npm ci

- name: Audit dependencies for security vulnerabilities
run: npm audit

- name: Lint the source code
run: npm run-script lint

- name: Build the source code
run: npm run build

- name: Execute test coverage
run: npm run-script coverage

- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: coverage/lcov.info
fail_ci_if_error: true # optional (default = false)
# flags: unittests # optional
# name: codecov-umbrella # optional

- name: Store the coverage report as an artifact
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage/lcov.info

upload-codacy-coverage:
name: Upload code coverage to Codacy
needs: build
runs-on: ubuntu-latest
steps:
- name: Download coverage artifact
uses: actions/download-artifact@v2
with:
name: coverage

- name: Upload code coverage to Codacy
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: lcov.info
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ typings/

node_modules

lib
dist
.idea
/tests/*.test.js
/tests/*.test.js.map
/tests/testCql.js.map
/tests/testCql.js
coverage
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
coverage
generated
11 changes: 11 additions & 0 deletions cql-antlr-parser.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/dist" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/antlr/generated/cqlLexer.ts → generated/cqlLexer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated from antlr/generated/cql.g4 by ANTLR 4.9.0-SNAPSHOT
// Generated from generated/cql.g4 by ANTLR 4.9.0-SNAPSHOT


import { ATN } from "antlr4ts/atn/ATN";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated from antlr/generated/cql.g4 by ANTLR 4.9.0-SNAPSHOT
// Generated from generated/cql.g4 by ANTLR 4.9.0-SNAPSHOT


import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener";
Expand Down
Loading

0 comments on commit 6345883

Please sign in to comment.