diff --git a/.github/workflows/develop.yaml b/.github/workflows/develop.yaml index 5e9bf9d..efbd15c 100644 --- a/.github/workflows/develop.yaml +++ b/.github/workflows/develop.yaml @@ -12,12 +12,12 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/cache@v2 + - uses: actions/checkout@v3 + - uses: actions/cache@v3 with: path: node_modules key: node-${{ hashFiles('yarn.lock') }} - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: ~/.m2 key: maven-${{ hashFiles('shadow-cljs.edn') }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fdb9a9a..cec5637 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,7 +9,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: wrike-ist env: WRIKE_TOKEN: ${{ secrets.WRIKE_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2af5256..d642317 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -8,12 +8,12 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/cache@v2 + - uses: actions/checkout@v3 + - uses: actions/cache@v3 with: path: node_modules key: node-${{ hashFiles('yarn.lock') }} - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: ~/.m2 key: maven-${{ hashFiles('shadow-cljs.edn') }} diff --git a/README.md b/README.md index 7d517ed..b589ec7 100644 --- a/README.md +++ b/README.md @@ -72,12 +72,16 @@ Specifies the status to move the task to when the linked PR is merged. If not specified or not found, falls back to the first Completed status in your workflow. +The transition can be disabled by setting the `merged` value to `"-"`. + #### `closed` Specifies the status to move the task to when the linked PR is closed without merging. If not specified or not found, falls back to the first Cancelled status in your workflow. +The transition can be disabled by setting the `closed` value to `"-"`. + ## Development ```shell diff --git a/action.yaml b/action.yaml index c7e0e0a..f087955 100644 --- a/action.yaml +++ b/action.yaml @@ -9,7 +9,7 @@ branding: inputs: merged: required: false - description: Status to move task to when the PR is merged. Defaults to the first Completed status in your workflow. + description: Status to move task to when the PR is merged. Defaults to the first Completed status in your workflow. Can be disabled by setting it to "-". closed: required: false - description: Status to move task to when the PR is closed without merging. Defaults to the first Cancelled status in your workflow. + description: Status to move task to when the PR is closed without merging. Defaults to the first Cancelled status in your workflow. Can be disabled by setting it to "-". diff --git a/package.json b/package.json index 79acfcf..77981fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wrike-ist", - "version": "1.3.2", + "version": "1.4.0", "description": "GitHub Action for Wrike automation", "main": "resources/main.js", "scripts": { diff --git a/resources/index.js b/resources/index.js index 05cf51a..469debc 100755 --- a/resources/index.js +++ b/resources/index.js @@ -14212,8 +14212,8 @@ wrike_ist.wrike.next_status=function(a,b){b=cljs.core.__destructure_map(b);var c c)?cljs.core.reduced(g):cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.get.cljs$core$IFn$_invoke$arity$2(f,"group"),d)?f:g},cljs.core.PersistentArrayMap.EMPTY,e)})}; wrike_ist.wrike.update_task_status=function(a,b){a=cljs.core.__destructure_map(a);var c=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,"id");a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,"parentIds");a=cljs.core.nth.cljs$core$IFn$_invoke$arity$3(a,0,null);return wrike_ist.wrike.next_status(a,b).then(function(d){d=cljs.core.__destructure_map(d);var e=cljs.core.get.cljs$core$IFn$_invoke$arity$2(d,"id");d=["https://www.wrike.com/api/v4/tasks/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(c)].join(""); e=cljs.core.clj__GT_js(new cljs.core.PersistentArrayMap(null,1,[cljs$cst$213$customStatus,e],null));return httpurr.client.node.put(d,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$183$headers,wrike_ist.wrike.headers(),cljs$cst$184$body,JSON.stringify(e)],null))})}; -wrike_ist.wrike.complete_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$207$permalink);return wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$211$wanted_status,b,cljs$cst$212$wanted_group,"Completed"],null))})}; -wrike_ist.wrike.cancel_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$207$permalink);return wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$211$wanted_status,b,cljs$cst$212$wanted_group,"Cancelled"],null))})};wrike_ist.core={}; +wrike_ist.wrike.complete_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$207$permalink);return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("-",b)?console.log('Skipping `merged` transition because it\'s set to "-"'):wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$211$wanted_status,b,cljs$cst$212$wanted_group,"Completed"],null))})}; +wrike_ist.wrike.cancel_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$207$permalink);return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("-",b)?console.log('Skipping `closed` transition because it\'s set to "-"'):wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$211$wanted_status,b,cljs$cst$212$wanted_group,"Cancelled"],null))})};wrike_ist.core={}; wrike_ist.core.extract_details=function(a){var b=a.body;return cljs.core.truth_(b)&&(b=cljs.core.re_find(/https:\/\/www.wrike.com\/open\.htm\?id=(\d+)/,b),cljs.core.truth_(b))?(b=cljs.core.nth.cljs$core$IFn$_invoke$arity$3(b,0,null),new cljs.core.PersistentArrayMap(null,4,[cljs$cst$214$state,a.merged?cljs$cst$215$merged:cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(a.state,"closed")?cljs$cst$216$closed:cljs$cst$217$open,cljs$cst$207$permalink,b,cljs$cst$205$pr_url,a.html_url,cljs$cst$206$title,a.title], null)):null}; wrike_ist.core.main=function(){var a=shadow.js.shim.module$$actions$github.context.payload.pull_request;if(cljs.core.truth_(a)){a=wrike_ist.core.extract_details(a);if(cljs.core.truth_(a)){var b=cljs.core.__destructure_map(a),c=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$214$state);return function(){switch(c instanceof cljs.core.Keyword?c.fqn:null){case "open":return wrike_ist.wrike.link_pr(b);case "merged":return wrike_ist.wrike.complete_task(b,shadow.js.shim.module$$actions$core.getInput("merged"));case "closed":return wrike_ist.wrike.cancel_task(b, diff --git a/resources/main.js b/resources/main.js index 9e61dc9..8b49ca8 100644 --- a/resources/main.js +++ b/resources/main.js @@ -2561,8 +2561,8 @@ wrike_ist.wrike.next_status=function(a,b){b=cljs.core.__destructure_map(b);var c c)?cljs.core.reduced(g):cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.get.cljs$core$IFn$_invoke$arity$2(f,"group"),d)?f:g},cljs.core.PersistentArrayMap.EMPTY,e)})}; wrike_ist.wrike.update_task_status=function(a,b){a=cljs.core.__destructure_map(a);var c=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,"id");a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,"parentIds");a=cljs.core.nth.cljs$core$IFn$_invoke$arity$3(a,0,null);return wrike_ist.wrike.next_status(a,b).then(function(d){d=cljs.core.__destructure_map(d);var e=cljs.core.get.cljs$core$IFn$_invoke$arity$2(d,"id");d=["https://www.wrike.com/api/v4/tasks/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(c)].join(""); e=cljs.core.clj__GT_js(new cljs.core.PersistentArrayMap(null,1,[cljs$cst$213$customStatus,e],null));return httpurr.client.node.put(d,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$183$headers,wrike_ist.wrike.headers(),cljs$cst$184$body,JSON.stringify(e)],null))})}; -wrike_ist.wrike.complete_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$207$permalink);return wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$211$wanted_status,b,cljs$cst$212$wanted_group,"Completed"],null))})}; -wrike_ist.wrike.cancel_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$207$permalink);return wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$211$wanted_status,b,cljs$cst$212$wanted_group,"Cancelled"],null))})};wrike_ist.core={}; +wrike_ist.wrike.complete_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$207$permalink);return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("-",b)?console.log('Skipping `merged` transition because it\'s set to "-"'):wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$211$wanted_status,b,cljs$cst$212$wanted_group,"Completed"],null))})}; +wrike_ist.wrike.cancel_task=function(a,b){a=cljs.core.__destructure_map(a);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(a,cljs$cst$207$permalink);return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("-",b)?console.log('Skipping `closed` transition because it\'s set to "-"'):wrike_ist.wrike.find_task(a).then(function(c){return wrike_ist.wrike.update_task_status(c,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$211$wanted_status,b,cljs$cst$212$wanted_group,"Cancelled"],null))})};wrike_ist.core={}; wrike_ist.core.extract_details=function(a){var b=a.body;return cljs.core.truth_(b)&&(b=cljs.core.re_find(/https:\/\/www.wrike.com\/open\.htm\?id=(\d+)/,b),cljs.core.truth_(b))?(b=cljs.core.nth.cljs$core$IFn$_invoke$arity$3(b,0,null),new cljs.core.PersistentArrayMap(null,4,[cljs$cst$214$state,a.merged?cljs$cst$215$merged:cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(a.state,"closed")?cljs$cst$216$closed:cljs$cst$217$open,cljs$cst$207$permalink,b,cljs$cst$205$pr_url,a.html_url,cljs$cst$206$title,a.title], null)):null}; wrike_ist.core.main=function(){var a=shadow.js.shim.module$$actions$github.context.payload.pull_request;if(cljs.core.truth_(a)){a=wrike_ist.core.extract_details(a);if(cljs.core.truth_(a)){var b=cljs.core.__destructure_map(a),c=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$214$state);return function(){switch(c instanceof cljs.core.Keyword?c.fqn:null){case "open":return wrike_ist.wrike.link_pr(b);case "merged":return wrike_ist.wrike.complete_task(b,shadow.js.shim.module$$actions$core.getInput("merged"));case "closed":return wrike_ist.wrike.cancel_task(b, diff --git a/src/wrike_ist/wrike.cljs b/src/wrike_ist/wrike.cljs index e1720da..0dc50ac 100644 --- a/src/wrike_ist/wrike.cljs +++ b/src/wrike_ist/wrike.cljs @@ -112,14 +112,18 @@ (defn complete-task [{:keys [permalink]} wanted-status] - (.then - (find-task permalink) - #(update-task-status % {:wanted-status wanted-status - :wanted-group "Completed"}))) + (if-not (= "-" wanted-status) + (.then + (find-task permalink) + #(update-task-status % {:wanted-status wanted-status + :wanted-group "Completed"})) + (js/console.log "Skipping `merged` transition because it's set to \"-\""))) (defn cancel-task [{:keys [permalink]} wanted-status] - (.then - (find-task permalink) - #(update-task-status % {:wanted-status wanted-status - :wanted-group "Cancelled"}))) + (if-not (= "-" wanted-status) + (.then + (find-task permalink) + #(update-task-status % {:wanted-status wanted-status + :wanted-group "Cancelled"})) + (js/console.log "Skipping `closed` transition because it's set to \"-\""))) diff --git a/test/wrike_ist/wrike_test.cljs b/test/wrike_ist/wrike_test.cljs index f41ddb0..fc69be8 100644 --- a/test/wrike_ist/wrike_test.cljs +++ b/test/wrike_ist/wrike_test.cljs @@ -1,6 +1,8 @@ (ns wrike-ist.wrike-test - (:require [cljs.test :refer-macros [deftest is testing run-tests]] - [wrike-ist.wrike :refer [link-html]])) + (:require [cljs.test :refer-macros [deftest is testing]] + [wrike-ist.wrike :refer [cancel-task + complete-task + link-html]])) (deftest link-html-test (testing "No title" @@ -13,3 +15,11 @@ data {:pr-url url :title title}] (is (= url (re-find (re-pattern url) (link-html data)))) (is (= title (re-find (re-pattern title) (link-html data))))))) + +(deftest cancel-task-test + (testing "Does nothing if `merged` is configured explicitly as \"-\"" + (is (= nil (cancel-task {} "-"))))) + +(deftest complete-task-test + (testing "Does nothing if `merged` is configured explicitly as \"-\"" + (is (= nil (complete-task {} "-")))))