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 51c8f468c1542786e63909240c0c43de11b3c347
Author: Louis Brunner <[email protected]>
AuthorDate: Mon Sep 7 15:06:56 2020 +0100

    Make 'conclusion' optional unless 'status' is required, closes #4, based on 
@Akrog's fork
---
 .github/workflows/examples.yml |  2 ++
 README.md                      |  3 ++-
 action.yml                     |  2 +-
 dist/index.js                  |  2 +-
 src/checks.ts                  |  9 +++++++--
 src/inputs.ts                  | 19 ++++++++++++++++---
 src/namespaces/Inputs.ts       |  2 +-
 7 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml
index 9c909fc..fbdc0c1 100644
--- a/.github/workflows/examples.yml
+++ b/.github/workflows/examples.yml
@@ -200,6 +200,7 @@ jobs:
     - uses: ./
       with:
         token: ${{ secrets.GITHUB_TOKEN }}
+        name: Will not be used
         status: completed
         conclusion: failure
 
@@ -216,6 +217,7 @@ jobs:
     - uses: ./
       with:
         token: ${{ secrets.GITHUB_TOKEN }}
+        name: Will not be used
         conclusion: failure
 
   ## Based on job
diff --git a/README.md b/README.md
index 951bf26..4e24efa 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@ See the [examples workflow](.github/workflows/examples.yml) 
for more details and
 
 ### `conclusion`
 
-**Required** The conclusion of your check, can be either `success`, `failure`, 
`neutral`, `cancelled`, `timed_out` or `action_required`
+_Optional_ (**Required** if `status` is `completed`, the default) The 
conclusion of your check, can be either `success`, `failure`, `neutral`, 
`cancelled`, `timed_out` or `action_required`
 
 ### `status`
 
@@ -88,3 +88,4 @@ Supports the same properties with the same types and names as 
the [Check Runs AP
  - Action Required conclusion: button doesn't work
  - Action elements: button doesn't work
  - Non-completed status: too many arguments required
+ - Name is required when completing a non-`completed` `status` check even 
though we don't use it (see examples `test_with_init*`)
diff --git a/action.yml b/action.yml
index a494317..eea8209 100644
--- a/action.yml
+++ b/action.yml
@@ -13,7 +13,7 @@ inputs:
     required: true
   conclusion:
     description: 'the conclusion of your check'
-    required: true
+    required: false
   status:
     description: 'the status of your check'
     required: false
diff --git a/dist/index.js b/dist/index.js
index 02b2c42..bdd3296 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1 +1 @@
-module.exports=(()=>{var __webpack_modules__={321:function(e,t,r){"use 
strict";var 
s=this&&this.__createBinding||(Object.create?function(e,t,r,s){if(s===undefined)s=r;Object.defineProperty(e,s,{enumerable:true,get:function(){return
 t[r]}})}:function(e,t,r,s){if(s===undefined)s=r;e[s]=t[r]});var 
o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var
 n=this&&this.__importStar||function(e [...]
\ No newline at end of file
+module.exports=(()=>{var __webpack_modules__={321:function(e,t,r){"use 
strict";var 
s=this&&this.__createBinding||(Object.create?function(e,t,r,s){if(s===undefined)s=r;Object.defineProperty(e,s,{enumerable:true,get:function(){return
 t[r]}})}:function(e,t,r,s){if(s===undefined)s=r;e[s]=t[r]});var 
o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var
 n=this&&this.__importStar||function(e [...]
\ No newline at end of file
diff --git a/src/checks.ts b/src/checks.ts
index 961d1a1..3dc3dff 100644
--- a/src/checks.ts
+++ b/src/checks.ts
@@ -21,13 +21,18 @@ const unpackInputs = (inputs: Inputs.Args): Record<string, 
unknown> => {
       images: inputs.images,
     };
   }
-  const more: {details_url?: string} = {};
+  const more: {
+    details_url?: string;
+    conclusion?: string;
+  } = {};
   if (inputs.conclusion === Inputs.Conclusion.ActionRequired || 
inputs.actions) {
     more.details_url = inputs.actionURL;
   }
+  if (inputs.conclusion) {
+    more.conclusion = inputs.conclusion.toString();
+  }
   return {
     status: inputs.status.toString(),
-    conclusion: inputs.conclusion.toString(),
     output,
     actions: inputs.actions,
     ...more,
diff --git a/src/inputs.ts b/src/inputs.ts
index 96ad747..775be8e 100644
--- a/src/inputs.ts
+++ b/src/inputs.ts
@@ -20,15 +20,28 @@ export const parseInputs = (getInput: GetInput): 
Inputs.Args => {
   const token = getInput('token', {required: true});
   const name = getInput('name', {required: true});
   const status = getInput('status', {required: true}) as Inputs.Status;
-  const conclusion = getInput('conclusion', {required: true}).toLowerCase() as 
Inputs.Conclusion;
+  let conclusion = getInput('conclusion') as Inputs.Conclusion;
   const actionURL = getInput('action_url');
 
   if (!Object.values(Inputs.Status).includes(status)) {
     throw new Error(`invalid value for 'status': '${status}'`);
   }
 
-  if (!Object.values(Inputs.Conclusion).includes(conclusion)) {
-    throw new Error(`invalid value for 'conclusion': '${conclusion}'`);
+  if (conclusion) {
+    conclusion = conclusion.toLowerCase() as Inputs.Conclusion;
+    if (!Object.values(Inputs.Conclusion).includes(conclusion)) {
+      throw new Error(`invalid value for 'conclusion': '${conclusion}'`);
+    }
+  }
+
+  if (status === Inputs.Status.Completed) {
+    if (!conclusion) {
+      throw new Error(`'conclusion' is required when 'status' is 'completed'`);
+    }
+  } else {
+    if (conclusion) {
+      throw new Error(`can't provide a 'conclusion' with a non-'completed' 
'status'`);
+    }
   }
 
   const output = parseJSON<Inputs.Output>(getInput, 'output');
diff --git a/src/namespaces/Inputs.ts b/src/namespaces/Inputs.ts
index 793fedd..cc5a54e 100644
--- a/src/namespaces/Inputs.ts
+++ b/src/namespaces/Inputs.ts
@@ -3,7 +3,7 @@ import {RestEndpointMethodTypes} from '@octokit/rest';
 export type Args = {
   name: string;
   token: string;
-  conclusion: Conclusion;
+  conclusion?: Conclusion;
   status: Status;
 
   actionURL: string;

Reply via email to