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

Use Sentry instead of Raven SDK #1

Closed
wants to merge 15 commits into from
Closed
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
128 changes: 40 additions & 88 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,113 +1,65 @@
name: Deploy

# About this workflow:
# It is triggered on push events to branches production and testing. Then it performs a checkout of the current repo
# and sets up a node environment (v12). Following, it will run `npm ci` to build the package. Next, it will look at your
# commit message, if it includes '#patch', '#minor', or '#major' it will bump the package version accordingly.
# Finally, the `npm publish` command will be run, when on branch testing it will run `npm publish --tag beta` to publish
# it under the beta flag on npm. Note: if no '#patch', '#minor', or '#major' flag is present in the latest commit
# AND the package version is not bumped manually the publish step will fail because we can not publish to an existing
# version.

# GitHub repo configuration:
# 1. Go to Manage access and add 'Github Actions' team with role: admin.
# 2. If you have protected branches, go to Branches > edit protected branch > enable 'Restrict who can push to
# matching branches' and add the 'athombv/github-actions' team.

# Note: make sure to commit package-lock.json, this is needed for `npm ci`.

# Defines the trigger for this action, in general you want it to run when pushing to production | testing. For more
# information see: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#about-workflow-events)
on:
push:
branches:
- production
- testing
workflow_dispatch:
inputs:
versionBumpType:
description: 'Version bump (major, minor or patch)'
required: true
- master

jobs:
deploy_to_npm:
name: Deploy to NPM

# Only run this job if initiator is not the Homey Github Actions Bot to prevent loops and check if if a version bump is provided and current branch is production or testing
if: github.actor != 'homey-bot'
&& (github.ref == 'refs/heads/production' || github.ref == 'refs/heads/testing')
&& (github.event.inputs.versionBumpType == 'patch' || github.event.inputs.versionBumpType == 'minor' || github.event.inputs.versionBumpType == 'major' || contains(github.event.head_commit.message, '#patch') || contains(github.event.head_commit.message, '#minor') || contains(github.event.head_commit.message, '#major'))

check_if_sentry_updated:
name: Check whether Sentry was updated
outputs:
version_ok: ${{ steps.check.outputs.version_ok }}
sentry_version: ${{ steps.check.outputs.sentry_version }}
runs-on: ubuntu-latest
steps:

# Checks out the current repository.
- name: Checkout git repository
uses: actions/checkout@v2
with:
# The token below is only necessary if you want to push the version bump to a protected branch
token: ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}
uses: actions/checkout@v4

# Set git config to reflect Homey Github Actions Bot user
- name: Set up HomeyGithubActionsBot git user
- name: Check whether Sentry was updated
id: check
run: |
git config --local user.email "sysadmin+githubactions@athom.com"
git config --local user.name "Homey Github Actions Bot"

# Configures a Node.js environment.
- name: Set up node 12 environment
uses: actions/setup-node@v1
sentryVersion="$(jq -r '.devDependencies."@sentry/node"' package.json)"
echo "version_ok=$(jq -r ".version == \"$sentryVersion\"" package.json)" >> $GITHUB_OUTPUT
echo "sentry_version=$sentryVersion" >> $GITHUB_OUTPUT
update_package_version:
name: Update package version if Sentry was updated
permissions:
contents: write
runs-on: ubuntu-latest
needs: check_if_sentry_updated
if: needs.check_if_sentry_updated.outputs.version_ok == 'true'
steps:
- name: Checkout git repository
uses: actions/checkout@v4
- name: Set up node 18 environment
uses: actions/setup-node@v4
with:
node-version: '12'
# Needed for publishing to npm
node-version: 18
registry-url: 'https://registry.npmjs.org'
- name: Update package.json, commit and push
run: |
updatedManifest=$(jq ".version = \"${{ needs.check_if_sentry_updated.outputs.sentry_version }}\"" package.json)
echo -E "${updatedManifest}" > package.json
git config --global user.name 'Action User'
git config --global user.email 'noreply@drenso.nl'
git add package.json
git commit -m "Bump version to ${{ needs.check_if_sentry_updated.outputs.sentry_version }}"
git push

# Run `npm ci && npm run build` to re-create your local environment (make sure to commit your - package-lock.json!).
- name: Build
run: |
npm ci
npm run build

- name: Version bump patch
if: github.event.inputs.versionBumpType == 'patch' || contains(github.event.head_commit.message, '#patch') && !contains(github.event.head_commit.message, '#minor') && !contains(github.event.head_commit.message, '#major')
run: |
npm version patch
git pull
git push --follow-tags

- name: Version bump minor
if: github.event.inputs.versionBumpType == 'minor' || contains(github.event.head_commit.message, '#minor') && !contains(github.event.head_commit.message, '#major')
run: |
npm version minor
git pull
git push --follow-tags

- name: Version bump major
if: github.event.inputs.versionBumpType == 'major' || contains(github.event.head_commit.message, '#major')
run: |
npm version major
git pull
git push --follow-tags

- name: Generate TypeScript typings
run: npm run typings:generate

# Publish when this action is running on branch production
- name: Publish
if: github.ref == 'refs/heads/production'
run: |
npm publish
VERSION="$(node -p "require('./package.json').version")"
echo package_version=${VERSION} >> $GITHUB_ENV
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}

# Publish to beta when this action is running on branch testing
- name: Publish to beta
if: github.ref == 'refs/heads/testing'
run: |
npm publish --tag beta
VERSION="$(node -p "require('./package.json').version")@beta"
echo package_version=${VERSION} >> $GITHUB_ENV
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
- name: Generate Github Release
uses: softprops/action-gh-release@v2
with:
make_latest: true
tag_name: v${{ needs.check_if_sentry_updated.outputs.sentry_version }} # update with known version
48 changes: 24 additions & 24 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
name: Deploy Documentation To GitHub Pages

# v1.0.0
#
# This workflow runs `npm run build` and then syncs the `build` folder to GitHub Pages.
name: Deploy JSDoc To GitHub Pages

on:
push:
branches: [ production ]
release:
types: [ published ]

jobs:
deploy:
name: Build & Deploy
name: Build & Deploy to GitHub Pages
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '12'
# Setup
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://npm.pkg.github.com'

# Build
- name: Build
run: |
npm ci
npm run build
# Build
- name: Build
run: |
npm ci --ignore-scripts --audit=false
npm run jsdoc

# Deploy
- name: Deploy To GitHub Pages
uses: peaceiris/actions-gh-pages@v3.8.0
with:
personal_token: ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}
publish_dir: ./build
# Deploy
- name: Deploy To GitHub Pages
uses: peaceiris/actions-gh-pages@v3.9.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./jsdoc/
33 changes: 11 additions & 22 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,24 @@ name: Lint
# Defines the trigger for this action (e.g. [pull_request, push])
# For more information see: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#about-workflow-events)
on:
push:
branches:
- master
- production
workflow_dispatch:
pull_request:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# Checks out the current repository.
- uses: actions/checkout@v2

# Configures a Node.js environment.
- uses: actions/setup-node@v1
with:
node-version: '12'

# Set SSH key
- uses: webfactory/ssh-agent@v0.4.1
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
if: env.SSH_KEY != null
# Setup
- name: Setup Node.js
uses: actions/setup-node@v4
with:
ssh-private-key: ${{ env.SSH_KEY }}
node-version: 18
registry-url: 'https://npm.pkg.github.com'

# Run `npm ci` to re-create your local environment (make sure to commit your package-lock.json!).
# Finally run `npm run lint` (make sure you have defined a lint command in package.json e.g. "lint": "eslint .").
- run: npm ci
- run: npm run lint
# Lint
- run: |
npm ci --ignore-scripts --audit=false
npm run lint
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
/build
/types
/jsdoc
/.idea
15 changes: 8 additions & 7 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
build
docs

CONTRIBUTING.md
.eslintrc.json
.eslintignore
.editorconfig
.github
jsdoc
.editorconfig
.eslintignore
.eslintrc.json
build.js
index.js
jsdoc.json
tsconfig.json
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ class MyApp extends Homey.App {
* When running your app with `homey app run` events will not be sent to Sentry.

## Changelog

### 2.0.0

This version is only SDK version 3 compatible. It now requires a different way of setting up the `Log` instance, see _Getting Started_.

### 3.0.0

This version has replaced the raven SDK with [@sentry/node](https://docs.sentry.io/platforms/javascript/guides/node/) version 8. If you were using the basic configuration, nothing has changed.

- If you were passing custom options, you will need to review them.
- `setExtra` is deprecated by Sentry and has been removed.
37 changes: 37 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict';

// eslint-disable-next-line import/no-extraneous-dependencies
const { buildSync } = require('esbuild');
const { execSync } = require('child_process');

const defaultOptions = {
entryPoints: ['index.js'],
bundle: true,
outdir: 'build',
platform: 'node',
external: ['homey'],
minify: true,
treeShaking: true,
};

// CommonJS build
buildSync({
...defaultOptions,
...{
format: 'cjs',
},
});

// ESM build
buildSync({
...defaultOptions,
...{
format: 'esm',
outExtension: {
'.js': '.mjs',
},
},
});

// Generate types
execSync('npm run typings:generate');
Loading