Skip to content

Commit

Permalink
ci: added 'build' and 'lint' workflow files
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowplay1 committed Oct 29, 2023
1 parent f3e2ae9 commit bdebeea
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build the package

on:
workflow_dispatch:
pull_request:
types: [opened, reopened]
push:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16

- name: Install dependencies
run: npm ci

- name: Build the package
run: npm run build
20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build the package

on:
workflow_dispatch:
pull_request:
types: [opened, reopened]
push:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16

- name: Build the package
run: bash ./scripts/lint.sh
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# ci/cd
.github/

# bash scripts
scripts/

# dependencies
node_modules/

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"test": "ts-node ./utils/test.ts",
"build": "npx tsc",
"postinstall": "node postinstall.js",
"lint": "eslint ./",
"lint:fix": "eslint ./ --fix"
"lint": "bash ./scripts/lint.sh",
"lint:fix": "bash ./scripts/lint.sh --fix"
},
"author": "shadowplay1 <[email protected]>",
"license": "MIT",
Expand Down
29 changes: 29 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

output=""


lint() {
if [[ $1 == '--fix' ]]; then
echo 'Fixing all the fixable linting issues...'
echo

eslint ./src --fix & output=$(eslint ./src --fix)
else
echo 'Checking the code for linting issues...'
echo

eslint ./src & output=$(eslint ./src)
fi
}


lint $1

if [ -n "$output" ]; then
echo 'Linting check failed.'
exit 1
else
echo 'Linting check passed!'
exit 0
fi

0 comments on commit bdebeea

Please sign in to comment.