Skip to content

Commit

Permalink
#119 Update CI/CD flow
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRefactoring committed Oct 28, 2023
1 parent 2528a2d commit 575dd2e
Show file tree
Hide file tree
Showing 4 changed files with 370 additions and 215 deletions.
60 changes: 48 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,63 @@ on: push

jobs:
build:
name: Build
runs-on: self-hosted
strategy:
max-parallel: 1
matrix:
node-version: [16.x, 18.x]
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v2
- name: Checkout sources
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- name: Create .env file
- name: Installing dependencies
run: npm ci
- name: Building sources
run: npm run build

lint:
name: Lint Code
needs: build
runs-on: self-hosted
strategy:
matrix:
node-version: [20.x]
steps:
- name: Linting
run: npm run lint
env:
CI: true

test_unit:
name: Unit Tests
needs: build
runs-on: self-hosted
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Running unit tests
run: npm run test:unit

test_integration:
name: Integration Tests
needs:
- lint
- test_unit
runs-on: self-hosted
strategy:
max-parallel: 1
matrix:
node-version: [18.x, 20.x]
steps:
- name: Creating `.env` file
run: |
touch .env
echo HOST=${{ secrets.HOST }} >> .env
echo EMAIL=${{ secrets.EMAIL }} >> .env
echo API_TOKEN=${{ secrets.API_TOKEN }} >> .env
- run: npm run build
- run: npm run test:unit
- run: npm run test:integration
- run: npm run lint
env:
CI: true
- name: Running integration tests
run: npm run test:integration
97 changes: 89 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,106 @@ name: NPM publish
on: workflow_dispatch

jobs:
publish:
build:
name: Build
runs-on: self-hosted
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Use Node.js 16
uses: actions/setup-node@v2
uses: actions/checkout@v4
- name: Use Node.js 18.x.x
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Install dependencies
node-version: 18
- name: Installing dependencies
run: npm ci
- name: Create .env file
- name: Building sources
run: npm run build

lint:
name: Lint Code
needs: build
runs-on: self-hosted
steps:
- name: Linting
run: npm run lint
env:
CI: true

test_unit:
name: Unit Tests
needs: build
runs-on: self-hosted
steps:
- name: Running unit tests
run: npm run test:unit

test_integration:
name: Integration Tests
needs:
- lint
- test_unit
runs-on: self-hosted
steps:
- name: Creating `.env` file
run: |
touch .env
echo HOST=${{ secrets.HOST }} >> .env
echo EMAIL=${{ secrets.EMAIL }} >> .env
echo API_TOKEN=${{ secrets.API_TOKEN }} >> .env
- name: Running integration tests
run: npm run test:integration

publish:
name: Package publish
needs:
- test_integration
runs-on: self-hosted
steps:
- name: Publishing
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-docs:
name: Docs publish
needs:
- publish
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: master

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: npm ci

- name: Generate docs
run: npm run doc

- name: Extract version
id: pkg
run: echo "::set-output name=version::$(node -p "require('./package.json').version")"

- name: Checkout docs branch
uses: actions/checkout@v4
with:
ref: docs
clean: false

- name: Copy docs to root
run: |
cp -r docs/* .
- name: Commit and push docs
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add .
git commit -m "Update documentation for version v${{ steps.pkg.outputs.version }}"
git push
Loading

0 comments on commit 575dd2e

Please sign in to comment.