Skip to content

Commit

Permalink
Add ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lo1tuma committed Mar 20, 2024
1 parent 3b8fbb4 commit defae16
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Job Setup
description: Reusable action to set up the working directory of the current job

runs:
using: composite
steps:
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies from cache
shell: bash
run: 'npm clean-install --prefer-offline'
73 changes: 73 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Continuous Integration Workflow

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

jobs:
install:
name: Install Dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout git repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup

compile:
name: Typescript compilation
runs-on: ubuntu-latest
needs: ['install']
steps:
- name: Checkout git repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Compile
run: 'npm run compile'
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: target/build/**/*

static-code-analysis:
name: Static Code Analysis
runs-on: ubuntu-latest
needs: ['install']
steps:
- name: Checkout git repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Run linters
run: 'npm run lint'

unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
needs: ['compile', 'static-code-analysis']
steps:
- name: Checkout git repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
- uses: actions/download-artifact@v4
with:
name: build-artifacts
path: target/build
- name: Run unit tests
run: 'unshare --map-root-user -n npm run test:unit:with-coverage'

integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: ['compile', 'static-code-analysis']
steps:
- name: Checkout git repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
- uses: actions/download-artifact@v4
with:
name: build-artifacts
path: target/build
- name: Run integration tests
run: 'npm run test:integration'
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"eslint:fix": "npm run eslint -- --fix",
"lint": "npm run eslint && npm run format:check",
"lint:fix": "npm run eslint:fix && npm run format:fix",
"test": "c8 npm run test:unit && npm run test:integration",
"test": "npm run test:unit:with-coverage && npm run test:integration",
"pretest:unit": "tsc -b source/tsconfig.unit-tests.json",
"test:unit": "mt target/build/source",
"test:unit:with-coverage": "c8 mt target/build/source",
"pretest:integration": "tsc -b integration-tests/tsconfig.json",
"test:integration": "mt target/build/integration-tests"
},
Expand Down

0 comments on commit defae16

Please sign in to comment.