Skip to content

Commit

Permalink
Merge pull request #21 from jjshoe/master
Browse files Browse the repository at this point in the history
Add a test for passing multiple commands, Support multiple commands to one action, Support manually triggering tests
  • Loading branch information
GabrielBB authored Nov 12, 2021
2 parents 4d056b2 + b5eca01 commit 86d97bd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/local.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

jobs:
build:
Expand Down Expand Up @@ -26,4 +26,14 @@ jobs:
uses: ./
with:
options: -screen 0 1600x1200x24
run: xrandr
run: xrandr

- name: Test XVFB with multiple commands
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: ./
with:
options: -screen 0 1600x1200x24
run: |
echo 'Testing xvfb'
pwd
xrandr
18 changes: 12 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ const exec = require('@actions/exec');
async function main() {

try {
const command = core.getInput('run', { required: true });
if (process.platform == "linux") {
await exec.exec("sudo apt-get install -y xvfb");
}

const commands = core.getInput('run', { required: true }).split("\n");
const directory = core.getInput('working-directory');
const serverOptions = core.getInput('options');

if (process.platform == "linux") {
await runCommandWithXvfb(command, directory, serverOptions);
} else {
await runCommand(command, directory);
for (i in commands) {
if (process.platform == "linux") {
console.log('Command: ' + commands[i]);
await runCommandWithXvfb(commands[i], directory, serverOptions);
} else {
await runCommand(commands[i], directory);
}
}
}
catch (error) {
Expand All @@ -20,7 +27,6 @@ async function main() {
}

async function runCommandWithXvfb(command, directory, options) {
await exec.exec("sudo apt-get install -y xvfb");
const optionsArgument = options ? `-s "${options}"` : '';
command = `xvfb-run --auto-servernum ${optionsArgument} ${command}`;

Expand Down

0 comments on commit 86d97bd

Please sign in to comment.