Skip to content

Commit

Permalink
testing job summary
Browse files Browse the repository at this point in the history
  • Loading branch information
dzsquared committed Aug 9, 2024
1 parent c89ae91 commit d120c29
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ inputs:
description: 'Skip the firewall check when connecting to the Azure SQL Server.'
required: false
default: false
no-job-summary:
description: 'Do not contribute to a job summary displayed as a job result.'
required: false
default: false
runs:
using: 'node20'
main: 'lib/main.js'
2 changes: 1 addition & 1 deletion lib/main.js

Large diffs are not rendered by default.

24 changes: 23 additions & 1 deletion src/AzureSqlAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface IActionInputs {
filePath: string;
additionalArguments?: string;
skipFirewallCheck: boolean;
noJobSummary: boolean;
}

export interface IDacpacActionInputs extends IActionInputs {
Expand Down Expand Up @@ -115,7 +116,28 @@ export default class AzureSqlAction {
outputDir = path.join(path.dirname(inputs.filePath), "bin", configuration);
}

await exec.exec(`dotnet build "${inputs.filePath}" -p:NetCoreBuild=true ${additionalBuildArguments}`);
let buildOutput = '';
await exec.exec(`dotnet build "${inputs.filePath}" -p:NetCoreBuild=true ${additionalBuildArguments}`, [], {
listeners: {
stderr: (data: Buffer) => buildOutput += data.toString(),
stdout: (data: Buffer) => buildOutput += data.toString()
}
});

if (buildOutput.includes('Build succeeded.')) {
core.summary.addHeading(':white_check_mark: Build succeeded.');

if (!buildOutput.includes('0 Warning(s)')) {
// parse buildOutput into lines, filter out warnings, and deduplicate
const lines = buildOutput.split(/\r?\n/);
let warnings = lines.filter(line => line.includes('Build warning'));
warnings = [...new Set(warnings)];

core.summary.addList(warnings, false);
}
} else {
core.summary.addHeading(':x: Build failed.');
}

const dacpacPath = path.join(outputDir, projectName + Constants.dacpacExtension);
console.log(`Successfully built database project to ${dacpacPath}`);
Expand Down
13 changes: 10 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export default async function run() {
}

await azureSqlAction.execute();

if (inputs.noJobSummary != true) {
core.summary.write();
}
}
catch (error) {
core.setFailed(error.message);
Expand Down Expand Up @@ -77,7 +81,8 @@ function getInputs(): IActionInputs {
connectionConfig: connectionConfig,
filePath: filePath,
additionalArguments: core.getInput('arguments') || undefined,
skipFirewallCheck: core.getBooleanInput('skip-firewall-check')
skipFirewallCheck: core.getBooleanInput('skip-firewall-check'),
noJobSummary: core.getBooleanInput('no-job-summary')
};

case Constants.dacpacExtension:
Expand All @@ -92,7 +97,8 @@ function getInputs(): IActionInputs {
sqlpackageAction: AzureSqlActionHelper.getSqlpackageActionTypeFromString(action),
sqlpackagePath: core.getInput('sqlpackage-path') || undefined,
additionalArguments: core.getInput('arguments') || undefined,
skipFirewallCheck: core.getBooleanInput('skip-firewall-check')
skipFirewallCheck: core.getBooleanInput('skip-firewall-check'),
noJobSummary: core.getBooleanInput('no-job-summary')
} as IDacpacActionInputs;

case Constants.sqlprojExtension:
Expand All @@ -108,7 +114,8 @@ function getInputs(): IActionInputs {
sqlpackageAction: AzureSqlActionHelper.getSqlpackageActionTypeFromString(action),
sqlpackagePath: core.getInput('sqlpackage-path') || undefined,
additionalArguments: core.getInput('arguments') || undefined,
skipFirewallCheck: core.getBooleanInput('skip-firewall-check')
skipFirewallCheck: core.getBooleanInput('skip-firewall-check'),
noJobSummary: core.getBooleanInput('no-job-summary')
} as IBuildAndPublishInputs;

default:
Expand Down

0 comments on commit d120c29

Please sign in to comment.