Skip to content

Commit

Permalink
ci: test ci/cd
Browse files Browse the repository at this point in the history
  • Loading branch information
robsonos committed Dec 6, 2023
1 parent b97d8a1 commit cd215a3
Show file tree
Hide file tree
Showing 10 changed files with 2,552 additions and 247 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Continuous deployment
on:
push:
branches:
- main

permissions:
contents: read # for checkout

jobs:
release:
runs-on: macos-12
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
95 changes: 95 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Continuous integration
on:
push:
branches:
- dev

env:
JAVA_VERSION: 17

jobs:
lint:
runs-on: macos-13
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Lint
run: yarn lint

verify-web:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Verify web
run: yarn verify:web

verify-android:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Java
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'zulu'

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Verify android
run: yarn verify:android

verify-ios:
runs-on: macos-13
steps:
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-12-Readme.md#xcode
- name: Set up Xcode
run: sudo xcode-select --switch /Applications/Xcode_14.2.app

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Verify ios
run: yarn verify:ios
24 changes: 24 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"branches": [
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
{
"path": "@semantic-release/npm",
"npmPublish": true,
"pkgRoot": "."
},
{
"path": "@semantic-release/git",
"assets": [
"package.json",
"yarn.lock",
"CHANGELOG.md"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
}
21 changes: 21 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
excluded:
- 'node_modules'
- 'ios/Pods'

opt_in_rules:
- 'implicitly_unwrapped_optional'
- 'file_name_no_space'
- 'force_unwrapping'
- 'function_default_parameter_at_end'
- 'lower_acl_than_parent'
- 'modifier_order'
- 'overridden_super_call'
- 'unowned_variable_capture'
- 'unused_import'

line_length:
warning: 150
ignores_function_declarations: true
ignores_comments: true
ignores_interpolated_strings: true
ignores_urls: true
23 changes: 9 additions & 14 deletions android/src/main/java/com/example/plugin/nordicdfu/NordicDfu.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ public void onEnablingDfuMode(@NonNull final String deviceAddress) {

@Override
public void onProgressChanged(
@NonNull final String deviceAddress,
final int percent,
final float speed,
final float avgSpeed,
final int currentPart,
final int partsTotal) {
@NonNull final String deviceAddress,
final int percent,
final float speed,
final float avgSpeed,
final int currentPart,
final int partsTotal
) {
JSObject ret = new JSObject();
ret.put("deviceAddress", deviceAddress);
ret.put("percent", percent);
Expand Down Expand Up @@ -116,7 +117,6 @@ public void onDfuCompleted(@NonNull final String deviceAddress) {
JSObject ret = new JSObject();
ret.put("deviceAddress", deviceAddress);
dfuEventListener.onDfuEvent("DFU_COMPLETED", ret);

// TODO: end activity
// new Handler()
// .postDelayed(
Expand Down Expand Up @@ -144,11 +144,7 @@ public void onDfuAborted(@NonNull final String deviceAddress) {
}

@Override
public void onError(
@NonNull final String deviceAddress,
final int error,
final int errorType,
final String message) {
public void onError(@NonNull final String deviceAddress, final int error, final int errorType, final String message) {
JSObject ret = new JSObject();
ret.put("deviceAddress", deviceAddress);
ret.put("error", error);
Expand All @@ -162,8 +158,7 @@ public void onResume(Context context) {
DfuServiceListenerHelper.registerProgressListener(context, dfuProgressListener);
}

public void onPause(Context context) {
}
public void onPause(Context context) {}

public void onDestroy(Context context) {
DfuServiceListenerHelper.unregisterProgressListener(context, dfuProgressListener);
Expand Down
10 changes: 2 additions & 8 deletions example/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
);
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
15 changes: 7 additions & 8 deletions ios/Plugin/NordicDfuPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import UserNotifications

@objc(NordicDfuPlugin)
public class NordicDfuPlugin: CAPPlugin, CBCentralManagerDelegate, DFUServiceDelegate, DFUProgressDelegate, NotificationHandlerProtocol {
public var DFU_CHANGE_EVENT: String = "DFUStateChanged"
public var dfuChangeEvent: String = "DFUStateChanged"
var notificationRequestLookup = [String: JSObject]()
private var manager: CBCentralManager?

Expand All @@ -18,7 +18,7 @@ public class NordicDfuPlugin: CAPPlugin, CBCentralManagerDelegate, DFUServiceDel
var notification: JSObject = [
"id": Int(request.identifier) ?? -1,
"title": request.content.title,
"body": request.content.body,
"body": request.content.body
]

if let userInfo = JSTypes.coerceDictionaryToJSObject(request.content.userInfo) {
Expand Down Expand Up @@ -72,7 +72,7 @@ public class NordicDfuPlugin: CAPPlugin, CBCentralManagerDelegate, DFUServiceDel
return [
.badge,
.sound,
.alert,
.alert
]
}

Expand Down Expand Up @@ -137,17 +137,17 @@ public class NordicDfuPlugin: CAPPlugin, CBCentralManagerDelegate, DFUServiceDel
"speed": currentSpeedBytesPerSecond / 1000,
"avgSpeed": avgSpeedBytesPerSecond / 1000,
"currentPart": part,
"partsTotal": totalParts,
"partsTotal": totalParts
]
sendStateUpdate("DFU_PROGRESS", data)
}

private func sendStateUpdate(_ state: String, _ data: JSObject = [:]) {
let ret: JSObject = [
"state": state,
"data": data,
"data": data
]
notifyListeners(DFU_CHANGE_EVENT, data: ret)
notifyListeners(dfuChangeEvent, data: ret)
}

@objc func startDFU(_ call: CAPPluginCall) {
Expand Down Expand Up @@ -238,8 +238,7 @@ public class NordicDfuPlugin: CAPPlugin, CBCentralManagerDelegate, DFUServiceDel
// }

if let packetsReceiptNotificationsValueStr = dfuOption["packetsReceiptNotificationsValue"] as? String,
let packetsReceiptNotificationsValue = UInt16(packetsReceiptNotificationsValueStr)
{
let packetsReceiptNotificationsValue = UInt16(packetsReceiptNotificationsValueStr) {
starter.packetReceiptNotificationParameter = packetsReceiptNotificationsValue
}

Expand Down
9 changes: 0 additions & 9 deletions ios/PluginTests/ExampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ import XCTest
@testable import Plugin

class ExampleTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}

func testEcho() {
// This is an example of a functional test case for a plugin.
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"author": "Robson Oliveira dos Santos",
"license": "MIT",
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},
"repository": {
"type": "git",
Expand All @@ -41,10 +41,10 @@
"verify:android": "cd android && ./gradlew clean build test && cd ..",
"verify:web": "npm run build",
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- autocorrect --format",
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
"eslint": "eslint . --ext ts",
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
"swiftlint": "node-swiftlint",
"swiftlint": "swiftlint",
"docgen": "docgen --api NordicDfuPlugin --output-readme README.md --output-json dist/docs.json",
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
"clean": "rimraf ./dist",
Expand All @@ -59,7 +59,9 @@
"@capacitor/ios": "^5.3.0",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "^2.0.0",
"@ionic/swiftlint-config": "^1.1.2",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/npm": "^11.0.1",
"eslint": "^7.26.0",
"husky": "^8.0.3",
"np": "^8.0.4",
Expand All @@ -68,14 +70,13 @@
"pretty-quick": "^3.1.3",
"rimraf": "^3.0.2",
"rollup": "^2.79.1",
"swiftlint": "^1.0.1",
"semantic-release": "^22.0.8",
"typescript": "~4.9.4"
},
"peerDependencies": {
"@capacitor/core": "^5.0.0"
},
"prettier": "@ionic/prettier-config",
"swiftlint": "@ionic/swiftlint-config",
"eslintConfig": {
"extends": "@ionic/eslint-config/recommended"
},
Expand Down
Loading

0 comments on commit cd215a3

Please sign in to comment.