Skip to content

Commit

Permalink
Add screen size configuration, update default (#9)
Browse files Browse the repository at this point in the history
* Pass xvfb-server-args to start-xvfb.bash

* Change to only screen size arg

* Remove source map

* Update default screen size. Echo screen size when running.
  • Loading branch information
aganders3 authored Dec 6, 2023
1 parent 5124e2e commit 946613f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 16 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
description: 'directory where commands from `run` will be executed - defaults to cwd'
required: false
default: ""
xvfb-screen-size:
description: 'screen size passed to Xvfb'
required: false
default: '1280x1024x24'
# snake_case alternatives for backward-compatibility
# not adding deprecation notice at this time, but it can be done with
# <input_id>.deprecationMessage: "don't use this!"
Expand Down
11 changes: 5 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({

/***/ 109:
Expand Down Expand Up @@ -100,7 +100,7 @@ function startXvfb(env) {
return __awaiter(this, void 0, void 0, function* () {
console.log("::group::starting XVfb");
const options = { env: env };
const output = yield exec.getExecOutput("bash", [__nccwpck_require__.ab + "start-xvfb.bash"], options);
const output = yield exec.getExecOutput("bash", [__nccwpck_require__.ab + "start-xvfb.bash", core.getInput("xvfb-screen-size")], options);
if (output.exitCode == 0) {
const result = output.stdout.split("\n");
console.log("sleep for 1000ms");
Expand Down Expand Up @@ -157,8 +157,8 @@ function main() {
console.log(`running on ${process.platform}`);
if (process.platform == "linux") {
yield installDeps(env);
const [pid, display] = yield startXvfb(env);
console.log(`xvfb pid=${pid}, display=${display}`);
const [pid, display, screen] = yield startXvfb(env);
console.log(`xvfb pid=${pid}, display=${display}, screen=${screen}`);
env.DISPLAY = `:${display}`;
yield linuxSetup(env);
}
Expand Down Expand Up @@ -4303,5 +4303,4 @@ module.exports = require("util");
/******/ module.exports = __webpack_exports__;
/******/
/******/ })()
;
//# sourceMappingURL=index.js.map
;
1 change: 0 additions & 1 deletion dist/index.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/sourcemap-register.js

This file was deleted.

5 changes: 3 additions & 2 deletions dist/start-xvfb.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ find_free_servernum() {
}

SERVERNUM=$(find_free_servernum)
SCREEN_SIZE=${1:-"1280x1024x24"}

# TODO: allow configuration of screen
Xvfb :$SERVERNUM -screen 0, 1024x768x16 > /tmp/xvfb-output 2>&1 &
Xvfb :"$SERVERNUM" -screen 0 "$SCREEN_SIZE" > /tmp/xvfb-output 2>&1 &

echo "$!"
echo "$SERVERNUM"
echo "$SCREEN_SIZE"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"format": "prettier --write '**/*.ts'",
"format-check": "prettier --check '**/*.ts'",
"lint": "eslint src/**/*.ts",
"package": "ncc build --source-map --license licenses.txt && npm run _copy-files-dist",
"package": "ncc build --license licenses.txt && npm run _copy-files-dist",
"test": "jest",
"all": "npm run build && npm run format && npm run lint && npm run package && npm test",
"_copy-files-lib": "cp src/start-xvfb.bash lib/",
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function startXvfb(env: { [key: string]: string }): Promise<string[]> {
const options: exec.ExecOptions = { env: env };
const output: exec.ExecOutput = await exec.getExecOutput(
"bash",
[`${__dirname}/start-xvfb.bash`],
[`${__dirname}/start-xvfb.bash`, core.getInput("xvfb-screen-size")],
options
);
if (output.exitCode == 0) {
Expand Down Expand Up @@ -135,8 +135,8 @@ async function main() {

if (process.platform == "linux") {
await installDeps(env);
const [pid, display] = await startXvfb(env);
console.log(`xvfb pid=${pid}, display=${display}`);
const [pid, display, screen] = await startXvfb(env);
console.log(`xvfb pid=${pid}, display=${display}, screen=${screen}`);
env.DISPLAY = `:${display}`;
await linuxSetup(env);
}
Expand Down
5 changes: 3 additions & 2 deletions src/start-xvfb.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ find_free_servernum() {
}

SERVERNUM=$(find_free_servernum)
SCREEN_SIZE=${1:-"1280x1024x24"}

# TODO: allow configuration of screen
Xvfb :$SERVERNUM -screen 0, 1024x768x16 > /tmp/xvfb-output 2>&1 &
Xvfb :"$SERVERNUM" -screen 0 "$SCREEN_SIZE" > /tmp/xvfb-output 2>&1 &

echo "$!"
echo "$SERVERNUM"
echo "$SCREEN_SIZE"

0 comments on commit 946613f

Please sign in to comment.