Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test-and-release.yml #680

Merged
merged 2 commits into from
Jan 4, 2025
Merged
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
174 changes: 66 additions & 108 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Test and Release
on:
push:
branches:
- master
- "master"
tags:
# normal versions
- "v[0-9]+.[0-9]+.[0-9]+"
Expand All @@ -19,116 +19,74 @@ concurrency:
cancel-in-progress: true

jobs:
# Runs unit tests on all supported node versions and OSes
unit-tests:
# Performs quick checks before the expensive test runs
check-and-lint:
if: contains(github.event.head_commit.message, '[skip ci]') == false

runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
os: [ubuntu-latest]

steps:
- name: Checkout code
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 component tests
run: npm t
env:
REQUEST_TIMEOUT: 20000
TESTING: true

- name: Test template creation
run: bash .github/test_template_creation.sh
env:
REQUEST_TIMEOUT: 20000
TESTING: true

- name: Compile TypeScript code
run: npm run build

- name: Start the CLI on a production environment
run: |
npm ci --omit=dev
TEST_STARTUP=true node ./bin/create-adapter.js
# TODO: Test the console output

# ===================

# Deploys the final package to NPM and Github Releases
deploy:
# Trigger this step only when a commit is tagged with a version number
if: |
contains(github.event.head_commit.message, '[skip ci]') == false &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/v')

needs: [unit-tests]

runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]

steps:
- name: Checkout code
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: 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

- name: Install dependencies
run: npm ci

# This is unnecessary, since npm publish will run prepublishOnly, which will run build
# - name: Create a clean build
# run: npm run build

- name: Publish package to npm
run: |
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm whoami
npm publish

- name: Create Github Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: ioBroker/testing-action-check@v1
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: Update ioBroker.template repo
run: bash .github/update_templates.sh
env:
GITHUB_TOKEN: ${{ secrets.ALCALZONE_GITHUB_TOKEN }}
node-version: '20.x'
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
# install-command: 'npm install'
lint: false

# # Runs adapter tests on all supported node versions and OSes
# adapter-tests:
# if: contains(github.event.head_commit.message, '[skip ci]') == false

# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# node-version: [18.x, 20.x, 22.x]
# os: [ubuntu-latest, windows-latest, macos-latest]

# steps:
# - uses: ioBroker/testing-action-adapter@v1
# with:
# node-version: ${{ matrix.node-version }}
# os: ${{ matrix.os }}
# # Uncomment the following line if your adapter cannot be installed using 'npm ci'
# # install-command: 'npm install'

# TODO: To enable automatic npm releases, create a token on npmjs.org
# Enter this token as a GitHub secret (with name NPM_TOKEN) in the repository options
# Then uncomment the following block:

# # Deploys the final package to NPM
# deploy:
# needs: [check-and-lint, adapter-tests]
#
# # Trigger this step only when a commit on any branch is tagged with a version number
# if: |
# contains(github.event.head_commit.message, '[skip ci]') == false &&
# github.event_name == 'push' &&
# startsWith(github.ref, 'refs/tags/v')
#
# runs-on: ubuntu-latest
#
# # Write permissions are required to create Github releases
# permissions:
# contents: write
#
# steps:
# - uses: ioBroker/testing-action-deploy@v1
# with:
# node-version: '20.x'
# # Uncomment the following line if your adapter cannot be installed using 'npm ci'
# # install-command: 'npm install'
# npm-token: ${{ secrets.NPM_TOKEN }}
# github-token: ${{ secrets.GITHUB_TOKEN }}
#
# # When using Sentry for error reporting, Sentry can be informed about new releases
# # To enable create a API-Token in Sentry (User settings, API keys)
# # Enter this token as a GitHub secret (with name SENTRY_AUTH_TOKEN) in the repository options
# # Then uncomment and customize the following block:
# sentry: true
# sentry-token: ${{ secrets.SENTRY_AUTH_TOKEN }}
# sentry-project: "iobroker-template"
# sentry-version-prefix: "iobroker.template"
# # If your sentry project is linked to a GitHub repository, you can enable the following option
# # sentry-github-integration: true
Loading