You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2020/12/27 14:02:09 UTC
[airflow-checks-action] 07/27: Fix tests
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow-checks-action.git
commit 7ab3930b26f3e12c9c76b16b2de65abcd2137f10
Author: Louis Brunner <lo...@gmail.com>
AuthorDate: Sat Feb 29 21:47:13 2020 +0000
Fix tests
---
__tests__/main.test.ts | 13 +++++++++++--
dist/index.js | 2 +-
src/inputs.ts | 14 ++++++--------
src/main.ts | 5 +++++
4 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts
index bced80d..334e324 100644
--- a/__tests__/main.test.ts
+++ b/__tests__/main.test.ts
@@ -4,12 +4,21 @@ import * as path from 'path';
// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
- process.env['TOKEN'] = 'ABC';
+ process.env['GITHUB_REPOSITORY'] = 'LB/ABC';
+ process.env['INPUT_TOKEN'] = 'ABC';
+ process.env['INPUT_NAME'] = 'ABC';
+ process.env['INPUT_STATUS'] = 'completed';
+ process.env['INPUT_CONCLUSION'] = 'success';
const ip = path.join(__dirname, '..', 'lib', 'main.js');
const options: cp.ExecSyncOptions = {
env: process.env,
};
- console.log(cp.execSync(`node ${ip}`, options).toString());
+ try {
+ console.log(cp.execSync(`node ${ip}`, options).toString());
+ } catch (e) {
+ console.log(e.stdout.toString());
+ throw e;
+ }
});
// TODO: add more
diff --git a/dist/index.js b/dist/index.js
index 37237e3..ea61a7f 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1 +1 @@
-module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var n=r[t]={i:t,l:false,exports:{}};e[t].call(n.exports,n,n.exports,__webpack_require__);n.l=true;return n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(429)}return startup()}({87:function(e){e.exports=require("os")},429:function(e,t,r){e.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t] [...]
\ No newline at end of file
+module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var n=r[t]={i:t,l:false,exports:{}};e[t].call(n.exports,n,n.exports,__webpack_require__);n.l=true;return n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(429)}return startup()}({87:function(e){e.exports=require("os")},429:function(e,t,r){e.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t] [...]
\ No newline at end of file
diff --git a/src/inputs.ts b/src/inputs.ts
index 6b5ed0d..c2e734e 100644
--- a/src/inputs.ts
+++ b/src/inputs.ts
@@ -19,18 +19,16 @@ const parseJSON = <T>(getInput: GetInput, property: string): T | undefined => {
export const parseInputs = (getInput: GetInput): Inputs.Args => {
const token = getInput('token', {required: true});
const name = getInput('name', {required: true});
- const statusStr = getInput('status', {required: true});
- const conclusionStr = getInput('conclusion', {required: true});
+ const status = getInput('status', {required: true}) as Inputs.Status;
+ const conclusion = getInput('conclusion', {required: true}) as Inputs.Conclusion;
- if (!(statusStr in Inputs.Status)) {
- throw new Error(`invalid value for 'status': '${statusStr}'`);
+ if (!Object.values(Inputs.Status).includes(status)) {
+ throw new Error(`invalid value for 'status': '${status}'`);
}
- const status = statusStr as Inputs.Status;
- if (!(conclusionStr in Inputs.Conclusion)) {
- throw new Error(`invalid value for 'conclusion': '${conclusionStr}'`);
+ if (!Object.values(Inputs.Conclusion).includes(conclusion)) {
+ throw new Error(`invalid value for 'conclusion': '${conclusion}'`);
}
- const conclusion = conclusionStr as Inputs.Conclusion;
const output = parseJSON<Inputs.Output>(getInput, 'output');
const annotations = parseJSON<Inputs.Annotations>(getInput, 'annotations');
diff --git a/src/main.ts b/src/main.ts
index 2a5ff19..8755104 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -22,6 +22,7 @@ async function run(): Promise<void> {
switch (inputs.status) {
case 'in_progress':
case 'queued': {
+ core.debug(`Creating a new Run`);
const id = await createRun(octokit, sha, ownership, inputs, {completed: false});
core.saveState(stateID, id.toString());
break;
@@ -29,14 +30,18 @@ async function run(): Promise<void> {
case 'completed': {
const id = core.getState(stateID);
if (id) {
+ core.debug(`Updating a Run (${id})`);
updateRun(octokit, parseInt(id), ownership, inputs);
} else {
+ core.debug(`Creating a new Run`);
createRun(octokit, sha, ownership, inputs);
}
break;
}
}
+ core.debug(`Done`);
} catch (error) {
+ core.debug(`Error: ${error}`);
core.setFailed(error.message);
}
}