Skip to content

Update tz88.json #16690

Update tz88.json

Update tz88.json #16690

name: Test and Release
# Run this job on all pushes to master, for pull requests
# as well as tags with a semantic version
on:
push:
branches:
# This avoids having duplicate builds in non-forked PRs
- "master"
tags:
# normal versions
- "v[0-9]+.[0-9]+.[0-9]+"
# pre-releases
- "v[0-9]+.[0-9]+.[0-9]+-**"
pull_request: {}
merge_group:
types: [checks_requested]
# Cancel previous PR/branch runs when a new commit is pushed
concurrency:
group: 'test-and-release-${{ github.ref }}'
cancel-in-progress: true
env:
TURBO_API: "http://127.0.0.1:9080"
# The token and team are required by the TurboRepo server, just set them to anything
TURBO_TOKEN: foo
TURBO_TEAM: me
# Additional CLI flags for turbo commands
TURBO_FLAGS: "" # "--concurrency=2"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Compile TypeScript code
run: yarn build $TURBO_FLAGS
- name: Save Turbo Cache between jobs
uses: ./.github/actions/build-cache-upload
# ===================
# Makes sure that the published packages can be require'd without issues in a production environment
test-packages:
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Restore Turbo Cache from previous jobs
uses: ./.github/actions/build-cache-download
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Compile TypeScript code
run: yarn build $TURBO_FLAGS
# Test that the generated packages are ok
# I'd love to use yalc or something for this, but it doesn't use yarn pack to pack the tarballs
# so we need to fake the install
- name: Import main entry points for each package
id: monopack
run: |
TMP_DIR=$(mktemp -d)
echo TMP_DIR=$TMP_DIR >> $GITHUB_OUTPUT
echo "Re-creating a production environment..."
yarn monopack --target "$TMP_DIR/.tarballs" --no-version
cd $TMP_DIR
npm init -y
npm i .tarballs/zwave-js.tgz
echo "Testing ESM entry points..."
# Now all entrypoints should work
node -e '(async () => { await import("zwave-js") })()'
node -e '(async () => { await import("@zwave-js/cc") })()'
node -e '(async () => { await import("@zwave-js/config") })()'
node -e '(async () => { await import("@zwave-js/core") })()'
node -e '(async () => { await import("@zwave-js/host") })()'
node -e '(async () => { await import("@zwave-js/nvmedit") })()'
node -e '(async () => { await import("@zwave-js/serial") })()'
node -e '(async () => { await import("@zwave-js/shared") })()'
node -e '(async () => { await import("@zwave-js/testing") })()'
node -e '(async () => { await import("zwave-js/safe") })()'
node -e '(async () => { await import("@zwave-js/cc/safe") })()'
node -e '(async () => { await import("@zwave-js/config/safe") })()'
node -e '(async () => { await import("@zwave-js/core/safe") })()'
node -e '(async () => { await import("@zwave-js/nvmedit/safe") })()'
node -e '(async () => { await import("@zwave-js/serial/safe") })()'
node -e '(async () => { await import("@zwave-js/shared/safe") })()'
echo "Testing CJS entry points..."
# Now all entrypoints should work
node -e 'require("zwave-js")'
node -e 'require("@zwave-js/cc")'
node -e 'require("@zwave-js/config")'
node -e 'require("@zwave-js/core")'
node -e 'require("@zwave-js/host")'
node -e 'require("@zwave-js/nvmedit")'
node -e 'require("@zwave-js/serial")'
node -e 'require("@zwave-js/shared")'
node -e 'require("@zwave-js/testing")'
node -e 'require("zwave-js/safe")'
node -e 'require("@zwave-js/cc/safe")'
node -e 'require("@zwave-js/config/safe")'
node -e 'require("@zwave-js/core/safe")'
node -e 'require("@zwave-js/nvmedit/safe")'
node -e 'require("@zwave-js/serial/safe")'
node -e 'require("@zwave-js/shared/safe")'
echo "Testing version exports..."
node -e 'assert.equal(require("@zwave-js/config").PACKAGE_VERSION, require("@zwave-js/config/package.json").version)'
node -e 'assert.equal(require("zwave-js").libVersion, require("zwave-js/package.json").version)'
node -e 'assert.equal(require("zwave-js").libName, require("zwave-js/package.json").name)'
echo "Doing spot checks for some exports"
node -e 'assert.equal(typeof require("@zwave-js/core").randomBytes, "function")'
# Test if bundling for the browser is supported yet
- name: Are we browser yet?
continue-on-error: true
env:
TMP_DIR: ${{ steps.monopack.outputs.TMP_DIR }}
run: |
cd $TMP_DIR
npm i -D esbuild
echo "import 'zwave-js'" > test.mjs
npx esbuild test.mjs --bundle --format=esm --outdir=build --sourcemap --target=es2022 --platform=browser --analyze=verbose --external:node:crypto
# ===================
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Run linters
run: yarn run lint $TURBO_FLAGS
- name: Prepare lint auto-fix patch
if: |
failure() &&
github.event_name == 'pull_request'
id: lint
run: |
# Run all lint commands and abort if one has unfixable errors
yarn run lint:ts:fix $TURBO_FLAGS
yarn fmt $TURBO_FLAGS
git diff --name-only || true
if ! git diff --quiet ; then
echo "has changes"
git diff > fix.patch
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "unchanged"
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Upload Patch
if: |
failure() &&
github.event_name == 'pull_request' &&
steps.lint.outputs.changed == 'true'
uses: actions/upload-artifact@v4
with:
name: lint-fix
path: fix.patch
# ===================
lint-zwave:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Lint config files and Z-Wave specifics
# Disable log prefix, so GitHub recognizes annotations in the output
run: yarn run lint:zwave $TURBO_FLAGS --log-prefix=none
# ===================
# Runs unit tests on all supported node versions and OSes
unit-tests:
name: "Unit tests: ${{ matrix.os }}, Node.js ${{ matrix.node-version }} (part ${{ matrix.shard }})"
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18, 20]
os: [ubuntu-latest]
shard: [1/4, 2/4, 3/4, 4/4]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
# # For pull requests, only run tests for changed files
# - name: Run component tests (changes)
# if: github.event_name == 'pull_request'
# run: |
# git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1
# yarn run test:dirty --resolve --base origin/${{ github.event.pull_request.base.ref }}
# For all other events, especially on master and releases, run the full test suite
# Run the full test suite on master, release branches and tags
- name: Run component tests (full)
# if: github.event_name != 'pull_request'
run: yarn run test:ts --shard ${{ matrix.shard }}
# ===================
# Test if the transformers are working
test-transformers:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18, 20]
os: [ubuntu-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
# Transformer tests need their dependencies to be compiled
- name: Compile test dependencies
run: |
yarn workspace @zwave-js/shared run build
yarn workspace @zwave-js/core run build
# For pull requests, only run tests for changed files
- name: Test transformers
run: yarn workspace @zwave-js/transformers run test:ts
# # ===================
# # This job checks if a PR changes the public API surface
# api-surface:
# name: Check public API surface
# # Only run for PRs
# if: github.event_name == 'pull_request'
# needs: [build]
# runs-on: ubuntu-latest
# strategy:
# matrix:
# node-version: [18] # This should be LTS
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Restore Turbo Cache from previous jobs
# uses: ./.github/actions/build-cache-download
# - name: Prepare testing environment
# uses: ./.github/actions/prepare-env
# with:
# node-version: ${{ matrix.node-version }}
# githubToken: ${{ secrets.GITHUB_TOKEN }}
# - name: Generate API report
# run: yarn run extract-api $TURBO_FLAGS
# - name: Show changes
# if: failure()
# run: |
# cat packages/*/.tmp/api.md
# - name: Comment on PR
# if: failure()
# run: |
# echo "The public API surface has changed!" >> $GITHUB_STEP_SUMMARY
# echo "Please run" >> $GITHUB_STEP_SUMMARY
# echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
# echo "yarn accept-api" >> $GITHUB_STEP_SUMMARY
# echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
# echo "and review the changes, then commit them if desired." >> $GITHUB_STEP_SUMMARY
# echo "" >> $GITHUB_STEP_SUMMARY
# ===================
gh-cc-table:
name: Update CC implementation status
# Only run for master branch and don't run in forks
if: |
github.repository == 'zwave-js/node-zwave-js' &&
github.ref == 'refs/heads/master' &&
github.event_name == 'push'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Update CC table # (maybe)
uses: actions/github-script@v7
with:
github-token: ${{secrets.BOT_TOKEN}}
result-encoding: string
script: |
const main = require(`${process.env.GITHUB_WORKSPACE}/.github/action-scripts/updateCCImplementationOverview.cjs`);
return main({github, context});
# ===================
generate-overview:
name: Update toLogEntry overview
# Only run for master branch and don't run in forks
if: |
github.repository == 'zwave-js/node-zwave-js' &&
github.ref == 'refs/heads/master' &&
github.event_name == 'push'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Update overview
uses: actions/github-script@v7
with:
github-token: ${{secrets.BOT_TOKEN}}
result-encoding: string
script: |
const main = require(`${process.env.GITHUB_WORKSPACE}/.github/action-scripts/updateToLogEntryOverview.cjs`);
return main({github, context});
# ===================
# Deploys the final package to NPM
deploy:
# Trigger this step only when a commit on any branch is tagged with a version number
if: |
github.actor == 'AlCalzone' &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/v')
needs:
- build
- lint
- lint-zwave
- unit-tests
- test-transformers
- test-packages
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Restore Turbo Cache from previous jobs
uses: ./.github/actions/build-cache-download
- name: Prepare testing environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Compile TypeScript code
run: yarn build $TURBO_FLAGS
- name: Extract the version and commit body from the tag
id: extract_release
# The body may be multiline, therefore we need to escape some characters
run: |
VERSION="${{ github.ref }}"
VERSION=${VERSION##*/v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
EOF=$(od -An -N6 -x /dev/urandom | tr -d ' ')
BODY=$(git show -s --format=%b)
echo "BODY<<$EOF" >> $GITHUB_OUTPUT
echo "$BODY" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
if [[ $VERSION == *"-"* ]] ; then
echo "TAG=--tag next" >> $GITHUB_OUTPUT
fi
- name: Publish packages to npm
env:
TAG: ${{ steps.extract_release.outputs.TAG }}
run: |
yarn config set npmAuthToken "${{ secrets.NPM_TOKEN }}"
yarn npm whoami
yarn workspaces foreach --all -vti --no-private npm publish --tolerate-republish $TAG
- name: Create Github Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
name: Release v${{ steps.extract_release.outputs.VERSION }}
draft: false
# Prerelease versions create prereleases on Github
prerelease: ${{ contains(steps.extract_release.outputs.VERSION, '-') }}
body: ${{ steps.extract_release.outputs.BODY }}
# - name: Notify Sentry.io about the release
# run: |
# npm i -g @sentry/cli
# export SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
# export SENTRY_URL=https://sentry.iobroker.net
# export SENTRY_ORG=iobroker
# export SENTRY_PROJECT=zwave-js
# export SENTRY_VERSION=zwave-js@${{ steps.extract_release.outputs.VERSION }}
# sentry-cli releases new $SENTRY_VERSION
# # Commits disabled until the Github integration can be enabled
# sentry-cli releases set-commits $SENTRY_VERSION --auto
# sentry-cli releases files $SENTRY_VERSION upload-sourcemaps ./packages/*/build
# sentry-cli releases finalize $SENTRY_VERSION