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 04eff86
Show file tree
Hide file tree
Showing 13 changed files with 2,536 additions and 264 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:
cd:
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
40 changes: 40 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Continuous integration
on:
push:
branches:
- dev

env:
JAVA_VERSION: 17

jobs:
ci:
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: Set up Xcode
run: sudo xcode-select --switch /Applications/Xcode_14.2.app

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

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

- name: Lint
run: yarn lint

- name: Verify
run: yarn verify
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}"
}
]
}
24 changes: 24 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
excluded:
- 'node_modules'
- 'ios/Pods'
- 'example/node_modules'
- 'example/ios/App/Pods'
- 'example/ios/DerivedData'

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
42 changes: 29 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ Please check the sample permissions in [Android](./example/android/app/src/main/

<docgen-index>

- [`startDFU(...)`](#startdfu)
- [`checkPermissions()`](#checkpermissions)
- [`requestPermissions()`](#requestpermissions)
- [`addListener('DFUStateChanged', ...)`](#addlistenerdfustatechanged)
- [`removeAllListeners()`](#removealllisteners)
- [Interfaces](#interfaces)
- [Type Aliases](#type-aliases)
- [Enums](#enums)
* [`startDFU(...)`](#startdfu)
* [`checkPermissions()`](#checkpermissions)
* [`requestPermissions()`](#requestpermissions)
* [`addListener('DFUStateChanged', ...)`](#addlistenerdfustatechanged)
* [`removeAllListeners()`](#removealllisteners)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
* [Enums](#enums)

</docgen-index>

Expand All @@ -78,7 +78,8 @@ Initiates the DFU process with the specified options.

**Since:** 1.0.0

---
--------------------


### checkPermissions()

Expand All @@ -92,7 +93,8 @@ Check status of permissions needed by the plugin

**Since:** 1.0.0

---
--------------------


### requestPermissions()

Expand All @@ -106,7 +108,8 @@ Request permissions needed by the plugin

**Since:** 1.0.0

---
--------------------


### addListener('DFUStateChanged', ...)

Expand All @@ -125,7 +128,8 @@ Listen for when the DFU state changes

**Since:** 1.0.0

---
--------------------


### removeAllListeners()

Expand All @@ -137,16 +141,19 @@ Removes all listeners for the DFUStateChanged event

**Since:** 1.0.0

---
--------------------


### Interfaces


#### PluginResultError

| Prop | Type |
| ------------- | ------------------- |
| **`message`** | <code>string</code> |


#### DfuUpdateOptions

Specifies the options required for initiating the DFU process.
Expand All @@ -158,6 +165,7 @@ Specifies the options required for initiating the DFU process.
| **`filePath`** | <code>string</code> | The path to the firmware file | 1.0.0 |
| **`dfuOptions`** | <code><a href="#dfuoptions">DfuOptions</a></code> | The additional options for the DFU process | 1.0.0 |


#### DfuOptions

Outlines additional options for configuring the DFU process.
Expand All @@ -182,6 +190,7 @@ Outlines additional options for configuring the DFU process.
| **`mbrSize`** | <code>number</code> | This method sets the size of an MBR (Master Boot Record). It should be used only when updating a file from a HEX file. If you use BIN or ZIP, value set here will be ignored. | <code>4096</code> | 1.0.0 |
| **`unsafeExperimentalButtonlessServiceInSecureDfuEnabled`** | <code>boolean</code> | Set this flag to true to enable experimental buttonless feature in Secure DFU. When the experimental Buttonless DFU Service is found on a device, the service will use it to switch the device to the bootloader mode, connect to it in that mode and proceed with DFU. | <code>false</code> | 1.0.0 |


#### PermissionStatus

Represents the current status of permissions in the plugin.
Expand All @@ -190,12 +199,14 @@ Represents the current status of permissions in the plugin.
| ------------------- | ----------------------------------------------------------- | ------------------------------------------------ | ----- |
| **`notifications`** | <code><a href="#permissionstate">PermissionState</a></code> | Indicates the permission state of notifications. | 1.0.0 |


#### PluginListenerHandle

| Prop | Type |
| ------------ | ----------------------------------------- |
| **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |


#### DfuUpdate

The DFU update object that is passed to the DFUStateChanged event
Expand All @@ -205,6 +216,7 @@ The DFU update object that is passed to the DFUStateChanged event
| **`state`** | <code><a href="#dfustate">DfuState</a></code> | Defines the structure for the DFU update object passed to the DFUStateChanged event. | 1.0.0 |
| **`data`** | <code><a href="#dfuupdatedata">DfuUpdateData</a></code> | The DFU data that is passed to the <a href="#dfuupdate">DfuUpdate</a> object | 1.0.0 |


#### DfuUpdateData

Contains data related to the DFU update process, such as progress and speed.
Expand All @@ -217,14 +229,18 @@ Contains data related to the DFU update process, such as progress and speed.
| **`currentPart`** | <code>number</code> | The number of parts being sent. In case the ZIP file contains a Soft Device and/or a Bootloader together with the application the SD+BL are sent as part 1, then the service starts again and send the application as part 2. | 1.0.0 |
| **`partsTotal`** | <code>number</code> | The total number of parts. | 1.0.0 |


### Type Aliases


#### PermissionState

<code>'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'</code>


### Enums


#### DfuState

| Members | Value | Description | Since |
Expand Down
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
2 changes: 1 addition & 1 deletion example/android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include ':capacitor-community-bluetooth-le'
project(':capacitor-community-bluetooth-le').projectDir = new File('../node_modules/@capacitor-community/bluetooth-le/android')

include ':capacitor-community-nordic-dfu'
project(':capacitor-community-nordic-dfu').projectDir = new File('../../android')
project(':capacitor-community-nordic-dfu').projectDir = new File('../node_modules/@capacitor-community/nordic-dfu/android')

include ':capacitor-filesystem'
project(':capacitor-filesystem').projectDir = new File('../node_modules/@capacitor/filesystem/android')
Expand Down
2 changes: 1 addition & 1 deletion example/ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def capacitor_pods
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCommunityBluetoothLe', :path => '../../node_modules/@capacitor-community/bluetooth-le'
pod 'CapacitorCommunityNordicDfu', :path => '../../..'
pod 'CapacitorCommunityNordicDfu', :path => '../../node_modules/@capacitor-community/nordic-dfu'
pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem'
pod 'CapawesomeCapacitorFilePicker', :path => '../../node_modules/@capawesome/capacitor-file-picker'
end
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());
Loading

0 comments on commit 04eff86

Please sign in to comment.