Skip to content

Commit

Permalink
ci: use shared testing action (#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Dec 19, 2021
1 parent 7f8f350 commit 3cdd88d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 91 deletions.
105 changes: 15 additions & 90 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ name: Test and Release
on:
push:
branches:
# This avoids having duplicate builds in non-forked PRs
- "master"
- master
tags:
# normal versions
- "v[0-9]+.[0-9]+.[0-9]+"
Expand All @@ -21,69 +20,36 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
- uses: ioBroker/testing-action-check@v1
with:
node-version: ${{ matrix.node-version }}
node-version: '14.x'
type-checking: true
lint: true

- name: Install Dependencies
run: npm ci

- name: Perform a type check
run: npm run check:ts
env:
CI: true
# - name: Lint TypeScript code
# run: npm run lint
- name: Test package files
run: npm run test:package

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

needs: [check-and-lint]

runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
- uses: ioBroker/testing-action-adapter@v1
with:
node-version: ${{ matrix.node-version }}
os: ${{ matrix.os }}
build: true
extra-tests: 'npm run test:ts'

- name: Install Dependencies
run: npm ci

- name: Run local tests
run: npm test
- name: Run unit tests
run: npm run test:unit
- name: Run integration tests (unix only)
if: startsWith(runner.OS, 'windows') == false
run: DEBUG=testing:* npm run test:integration
- name: Run integration tests (windows only)
if: startsWith(runner.OS, 'windows')
run: set DEBUG=testing:* & npm run test:integration

# Deploys the final package to NPM
deploy:
needs: [adapter-tests]
needs: [check-and-lint, adapter-tests]

# Trigger this step only when a commit on any branch is tagged with a version number
if: |
Expand All @@ -92,52 +58,11 @@ jobs:
startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- 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 "::set-output name=VERSION::$VERSION"
BODY=$(git show -s --format=%b)
BODY="${BODY//'%'/'%25'}"
BODY="${BODY//$'\n'/'%0A'}"
BODY="${BODY//$'\r'/'%0D'}"
echo "::set-output name=BODY::$BODY"
- name: Install Dependencies
run: npm ci

- 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: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: ioBroker/testing-action-deploy@v1
with:
tag_name: ${{ github.ref }}
release_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 }}
node-version: "14.x" # This should be LTS
build: 'true'
npm-token: ${{ secrets.NPM_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"prebuild": "rimraf ./build",
"build:react": "node .build.js -react",
"build:ts": "node .build.js -typescript",
"check:ts": "tsc -p tsconfig.build.json --noEmit",
"check": "tsc -p tsconfig.build.json --noEmit",
"build": "node .build.js -typescript -react",
"watch:react": "npm run build:react -- --watch",
"watch:ts": "npm run build:ts -- --watch",
Expand Down

0 comments on commit 3cdd88d

Please sign in to comment.