Skip to content

Commit

Permalink
Merge pull request #2 from Bandwidth/v1.0.0-beta
Browse files Browse the repository at this point in the history
DX-2726 Initial Development of Linter CLI
  • Loading branch information
ajrice6713 authored Aug 11, 2022
2 parents 67538f4 + d363e77 commit dfb5f71
Show file tree
Hide file tree
Showing 16 changed files with 8,606 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Global rule:
* @Bandwidth/dx
51 changes: 51 additions & 0 deletions .github/workflows/deploy-beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy Beta

on:
release:
types: [published]

jobs:
deploy_beta:
name: Deploy Beta
runs-on: ubuntu-latest
if: ${{ github.event.release.prerelease }}
steps:
- name: Check Branch Name Format
run: |
re=v[0-9]+.[0-9]+.[0-9]+-beta
if ! [[ ${{ github.event.release.target_commitish }} =~ $re ]]; then
echo 'Target branch does not match expected regex pattern for beta releases (v[0-9]+.[0-9]+.[0-9]+-beta)'
echo '${{ github.event.release.target_commitish }}'
echo 'Please update your branch name to match the expected regex pattern'
exit 1
fi
- name: Set Release Version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV

- name: Check Release Version Format
run: |
re=[0-9]+.[0-9]+.[0-9]+-beta
if ! [[ $RELEASE_VERSION =~ $re ]]; then
echo 'Tag does not match expected regex pattern for beta releases (v[0-9]+.[0-9]+.[0-9]+-beta)'
echo $RELEASE_VERSION
echo 'Please update your tag to match the expected regex pattern'
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'

- name: Build and Test npm Package
run: |
npm install
npm run build
npm run test
- name: Publish npm Package
run: |
npm version $RELEASE_VERSION --no-git-tag-version
npm publish --tag beta
33 changes: 33 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy
on:
release:
types:
- published
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'main' }}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set Release Version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'

- name: Build and Test npm Package
run: |
npm install
npm run build
npm run test
- name: Publish npm Package
run: |
npm version $RELEASE_VERSION --no-git-tag-version
npm publish
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test

on:
pull_request:
workflow_dispatch:

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 16

- name: Test
run: |
npm install
npm run test
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# pkg files
node_modules
ruleset.yml
downloaded_ruleset.yml

# build
build/

# VS Code
.vscode
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
# oas-linter-cli

This is a CLI tool that enables users to run an OAS (Open API Spec) file through the DevX ruleset before opening a pull request against [api-specs](https://github.com/Bandwidth/api-specs)

## Setup and Install

```sh
# if your npm profile isnt setup to download npm packages published to githubs npm registry - run these commands first
npm login --registry https://npm.pkg.github.com # Requires a github token with Bandwidth SSO access
npm config set @Bandwidth:registry https://npm.pkg.github.com

# note the uppercase `B`
npm install -g @Bandwidth/oas-linter-cli
```

## Usage

```sh
bw-oas-lint -h # Help
bw-oas-lint lint ../path/to/my/spec.yml # must be in Yaml format

# add -s flag to save the terminal output to a .json file in your home directory
```

## Uninstall

```sh
# note the lowercase `b`
npm uninstall -g @bandwidth/oas-linter-cli
```
9 changes: 9 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: {
"^commands/(.*)$": "<rootDir>/build/commands/$1",
"^static/(.*)$": "<rootDir>/build/static/$1",
"^tests/fixtures/(.*)$": "<rootDir>/tests/fixtures/$1"
}
};
Loading

0 comments on commit dfb5f71

Please sign in to comment.