Skip to content

Commit

Permalink
feat: Add advanced github actions to pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Drla <[email protected]>
  • Loading branch information
mimotej committed Jun 25, 2022
1 parent ab3c8c3 commit 66aae25
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 8 deletions.
22 changes: 22 additions & 0 deletions .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build
description: Build the project
runs:
using: "composite"
steps:
- name: Use Node.js 16.14
uses: actions/setup-node@v3
with:
node-version: 16.14
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Install dependencies
shell: bash
run: npm ci
- name: Optional build
shell: bash
run: npm run build --if-present
11 changes: 11 additions & 0 deletions .github/actions/lint/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Lint project
description: Test if linting is followed
runs:
using: "composite"
steps:
- name: Lint using eslint
shell: bash
run: npm run lint
- name: Lint using prettier
shell: bash
run: npm run prettier-check
8 changes: 8 additions & 0 deletions .github/actions/test/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Test
description: Tests nodejs project
runs:
using: "composite"
steps:
- name: Test
shell: bash
run: npm test
22 changes: 14 additions & 8 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js 16.14
uses: actions/setup-node@v3
with:
node-version: 16.14
- run: npm ci
- run: npm run build --if-present
- run: npm run test
uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/build
- name: Test
uses: ./.github/actions/test
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/build
- name: Lint project
uses: ./.github/actions/lint
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"start": "ts-node src/index.ts",
"test": "jest",
"prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
"prettier-check": "prettier --config .prettierrc 'src/**/*.ts' --check",
"lint": "eslint . --ext .ts"
},
"repository": {
Expand Down

0 comments on commit 66aae25

Please sign in to comment.