Skip to content

Commit

Permalink
test ui is running in GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
oznu committed Aug 31, 2020
1 parent 74bdf1f commit 8f0cccb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,21 @@ jobs:
- run: npm run lint:server
- run: npm run test:e2e

# remove dev deps
- run: npm clean-install --production

# test hb-service
- run: node dist/bin/hb-service.js -v
- if: runner.os == 'Linux'
run: sudo node dist/bin/hb-service.js install --user homebridge
run: |
sudo node dist/bin/hb-service.js install --user homebridge
sleep 15
- if: runner.os == 'macOS'
run: sudo node dist/bin/hb-service.js install
run: |
sudo node dist/bin/hb-service.js install
sleep 15
- if: runner.os == 'Windows'
run: node dist/bin/hb-service.js install
run: |
node dist/bin/hb-service.js install
Start-Sleep -s 15
- run: node dist/bin/hb-service.js status --port 8581
26 changes: 25 additions & 1 deletion src/bin/hb-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { LinuxInstaller } from './platforms/linux';
import { DarwinInstaller } from './platforms/darwin';

export class HomebridgeServiceHelper {
public action: 'install' | 'uninstall' | 'start' | 'stop' | 'restart' | 'rebuild' | 'run' | 'logs' | 'update-node' | 'before-start';
public action: 'install' | 'uninstall' | 'start' | 'stop' | 'restart' | 'rebuild' | 'run' | 'logs' | 'update-node' | 'before-start' | 'status';
public selfPath = __filename;
public serviceName = 'Homebridge';
public storagePath;
Expand Down Expand Up @@ -144,6 +144,10 @@ export class HomebridgeServiceHelper {
process.exit(0);
break;
}
case 'status': {
this.checkStatus();
break;
}
default: {
commander.outputHelp();

Expand Down Expand Up @@ -1102,6 +1106,26 @@ export class HomebridgeServiceHelper {
}
}

/**
* Check the current status of the Homebridge UI by calling it's API
*/
private async checkStatus() {
this.logger(`Testing hb-service is running on port ${this.uiPort}...`);

try {
const res = await axios.get(`http://localhost:${this.uiPort}/api`);
if (res.data === 'Hello World!') {
this.logger('Homebridge UI Running', 'succeed');
} else {
this.logger('Unexpected Response', 'fail');
process.exit(1);
}
} catch (e) {
this.logger('Homebridge UI Not Running', 'fail');
process.exit(1);
}
}

}

function bootstrap() {
Expand Down

0 comments on commit 8f0cccb

Please sign in to comment.