Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# This workflow tests the ModbusSimulator with Bun
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI
name: Bun CI

on:
push:
Expand All @@ -14,22 +14,18 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- name: Run tests
run: npm run test:unit && npm run test:integration
- uses: oven-sh/setup-bun@v2

- name: Install dependencies (bun)
run: bun install

- name: Run unit and integration tests
run: bun run test:unit && bun run test:integration
env:
NODE_ENV: test
- run: npm run build --if-present

- name: Build release
run: bun run build

154 changes: 92 additions & 62 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,98 @@ on:
- 'v*'

jobs:
build-and-release:
build-linux:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2

- name: Install dependencies (bun)
run: bun install

- name: Run tests (e2e)
run: bun run test:e2e

- name: Build release (linux)
run: bun run build

- name: Package linux artifacts
run: |
tar -czf linux-release.tar.gz -C Releases .

- name: Upload linux artifact
uses: actions/upload-artifact@v4
with:
name: linux-release
path: linux-release.tar.gz

build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/bun@v2

- name: Install dependencies (bun)
run: bun install

- name: Run tests (e2e)
run: bun run test:e2e

- name: Build release (windows)
run: bun run build

- name: Package windows artifacts
shell: pwsh
run: |
Compress-Archive -Path "Releases/*" -DestinationPath windows-release.zip

- name: Upload windows artifact
uses: actions/upload-artifact@v4
with:
name: windows-release
path: windows-release.zip

create-release:
runs-on: ubuntu-latest
needs: [build-linux, build-windows]
steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Build release
run: npm run build

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false

- name: Upload Windows executable
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Releases/modbussimulator-win.exe
asset_name: modbussimulator-win.exe
asset_content_type: application/octet-stream

- name: Upload Linux executable
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Releases/modbussimulator-linux
asset_name: modbussimulator-linux
asset_content_type: application/octet-stream

- name: Upload schema files
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Releases
asset_name: schemas.tar.gz
asset_content_type: application/gzip
- name: Download linux artifact
uses: actions/download-artifact@v4
with:
name: linux-release

- name: Download windows artifact
uses: actions/download-artifact@v4
with:
name: windows-release

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false

- name: Upload Linux bundle
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: linux-release.tar.gz
asset_name: linux-release.tar.gz
asset_content_type: application/gzip

- name: Upload Windows bundle
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: windows-release.zip
asset_name: windows-release.zip
asset_content_type: application/zip
10 changes: 10 additions & 0 deletions .mocharc.ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extensions": ["ts"],
"spec": ["test/unit/**/*.test.ts"],
"timeout": 5000,
"color": true,
"loader": "ts-node/esm",
"node-option": [
"loader=ts-node/esm"
]
}
4 changes: 2 additions & 2 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extensions": ["ts"],
"spec": ["test/unit/**/*.test.ts"],
"timeout": 5000,
"spec": ["test/**/*.test.ts"],
"timeout": 10000,
"color": true,
"loader": "ts-node/esm",
"node-option": [
Expand Down
87 changes: 0 additions & 87 deletions ModbusSimulator.js

This file was deleted.

Loading