-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 745d241
Showing
18 changed files
with
274 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Test the action | ||
|
||
permissions: | ||
contents: read | ||
|
||
# this will be executed on every push on a branch (hence on every commit), but not when pushing a tag | ||
on: | ||
push: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
# check a non working app | ||
- name: Test action with a non working app | ||
id: test_not_working | ||
uses: ./ | ||
with: | ||
path: test/app | ||
device: fenix7 | ||
continue-on-error: true | ||
- name: Check that action returned a failure status | ||
if: steps.test_not_working.outputs.status != 'failure' | ||
run: exit 1 | ||
|
||
# check a working app | ||
- name: Remove failing test to get a working app | ||
run: rm test/app/source/test/NotWorkingTest.mc | ||
- name: Test action with a working app | ||
id: test_working | ||
uses: ./ | ||
with: | ||
path: test/app | ||
device: fenix7 | ||
continue-on-error: true | ||
- name: Check that action returned a success status | ||
if: steps.test_working.outputs.status != 'success' | ||
run: exit 1 | ||
|
||
# check a working app with a custom certificate | ||
- name: Generate certificate | ||
run: openssl genrsa -out test/app/key.pem 4096 && openssl pkcs8 -topk8 -inform PEM -outform DER -in test/app/key.pem -out test/app/key.der -nocrypt | ||
|
||
- name: Test action with a working app and a custom certificate | ||
id: test_working_custom_certificate | ||
uses: ./ | ||
with: | ||
path: test/app | ||
device: fenix7 | ||
certificate: key.der | ||
continue-on-error: true | ||
- name: Check that action returned a success status | ||
if: steps.test_working_custom_certificate.outputs.status != 'success' | ||
run: exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/test/app/key.der | ||
/test/app/key.pem | ||
/test/app/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"files.exclude": { | ||
"test/app/bin": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM ghcr.io/matco/connectiq-tester:latest | ||
|
||
COPY entrypoint.sh /root/entrypoint.sh | ||
|
||
ENTRYPOINT ["/root/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# ConnectIQ Tester for GitHub Actions | ||
|
||
ConnectIQ Tester is a GitHub Action that can be used to run the test "Run No Evil" of a ConnectIQ application. It relies on the Docker image [ghcr.io/matco/connectiq-tester](https://github.com/matco/connectiq-tester). | ||
|
||
## Usage | ||
|
||
Here is sample step to test your application in your CI workflows: | ||
``` | ||
- name: Test application | ||
id: run_tests | ||
uses: matco/connectiq-tester@v1 | ||
with: | ||
device: fenix5 | ||
``` | ||
|
||
### Inputs | ||
* path: The path of the application to test. By default the root of the repository will be used. | ||
* device: The id of the device used to run the tests. By default, a Fenix 7 will be used. | ||
* certificate: The optional path of a certificate used to compile the application relatively to the path of the application. If not specified, a temporary certificate will be generated automatically. | ||
|
||
### Outputs | ||
* status: "success" if tests succeeded, "failure" if not |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: "ConnectIQ Tester" | ||
description: "Test a ConnectIQ application" | ||
inputs: | ||
path: | ||
description: "The path of the application to test" | ||
required: true | ||
default: . | ||
device: | ||
description: "The id of the device used to run the tests" | ||
required: true | ||
default: fenix7 | ||
certificate: | ||
description: "The path of the certificate used to compile the application relatively to the path of the application" | ||
required: false | ||
outputs: | ||
status: | ||
description: "'success' if tests succeeded, 'failure' if not" | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- ${{inputs.path}} | ||
- ${{inputs.device}} | ||
- ${{inputs.certificate}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
#fail if one of the commands fails | ||
set -e | ||
|
||
#retrieve parameters | ||
APP_PATH=$1 | ||
DEVICE_ID=$2 | ||
CERTIFICATE_PATH=$3 | ||
|
||
function info { | ||
#retrieve message from the parameter | ||
if [[ -n $1 ]] | ||
then | ||
message="$1" | ||
echo -e "::debug::$message" | ||
#or read the message directly | ||
else | ||
while read -r message | ||
do | ||
info "$message" | ||
done | ||
fi | ||
} | ||
|
||
#override the HOME enviroment variable | ||
#when executing a Docker Action, GitHub overrides the HOME variable in the command used to run the Docker (it is set to the home of the runner user) | ||
#the HOME must be restored to the standard home of the root user because ConnectIQ depends on it (the devices files are stored in the home folder of the root user) | ||
export HOME=/root | ||
|
||
#entering folder when the app is stored relatively to the GitHub workspace | ||
if [[ -n $1 ]] | ||
then | ||
info "Entering folder $APP_PATH..." | ||
cd "$APP_PATH" | ||
info "Now in folder $(pwd)" | ||
fi | ||
|
||
#run tests | ||
info "Running tests on device [$DEVICE_ID] with certificate [$CERTIFICATE_PATH]..." | ||
tester.sh "$DEVICE_ID" "$CERTIFICATE_PATH" | info | ||
result="${PIPESTATUS[0]}" | ||
info "Test finished with result code $result" | ||
|
||
#set output variable | ||
if [[ $result -eq 0 ]]; | ||
then | ||
echo "::set-output name=status::success" | ||
else | ||
echo "::set-output name=status::failure" | ||
|
||
fi | ||
|
||
exit "$result" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. --><iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="1"> | ||
<iq:application entry="TestApp" id="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" launcherIcon="@Drawables.application_launcher_icon" minSdkVersion="1.3.1" name="@Strings.application_name" type="watch-app"> | ||
<iq:products> | ||
<iq:product id="fenix7"/> | ||
</iq:products> | ||
<iq:languages> | ||
<iq:language>eng</iq:language> | ||
</iq:languages> | ||
</iq:application> | ||
</iq:manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
project.manifest = manifest.xml |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<layout id="main"> | ||
<label x="center" y="center" text="Test application" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" /> | ||
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<bitmap id="application_launcher_icon" filename="images/application_launcher_icon.png" /> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string id="application_name">App</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Toybox.Application; | ||
using Toybox.System; | ||
|
||
class TestApp extends Application.AppBase { | ||
|
||
function initialize() { | ||
AppBase.initialize(); | ||
System.println("Starting test application"); | ||
} | ||
|
||
function getInitialView() { | ||
return [new MainView()]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Toybox.Test; | ||
|
||
module NotWorkingTest { | ||
|
||
(:test) | ||
function testSuccess(logger) { | ||
Test.assertEqualMessage(1, 1, "1 is equal to 1"); | ||
return true; | ||
} | ||
|
||
(:test) | ||
function testFailure(logger) { | ||
Test.assertEqualMessage(1, -1, "1 is equal to -1"); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Toybox.Test; | ||
|
||
module WorkingTest { | ||
|
||
(:test) | ||
function testFirstSuccess(logger) { | ||
Test.assertEqualMessage(1, 1, "1 is equal to 1"); | ||
return true; | ||
} | ||
|
||
(:test) | ||
function testSecondSuccess(logger) { | ||
Test.assertNotEqualMessage(1, -1, "1 is not equal to -1"); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Toybox.WatchUi; | ||
using Toybox.Graphics; | ||
using Toybox.Timer; | ||
|
||
class MainView extends WatchUi.View { | ||
function initialize() { | ||
View.initialize(); | ||
} | ||
|
||
function onLayout(dc) { | ||
setLayout(Rez.Layouts.main(dc)); | ||
} | ||
} |