Skip to content

Commit

Permalink
start implement search for defect keys
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueck committed Jun 4, 2021
1 parent cd23f86 commit 9dc21e8
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 42 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ on: push
name: Test on push
jobs:
addComment:
name: add comment to defect DF001268
name: search for defect keys on different sources
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -12,16 +12,14 @@ jobs:
env:
AQUA_USERNAME: ${{ secrets.AQUA_USERNAME }}
AQUA_PASSWORD: ${{ secrets.AQUA_PASSWORD }}
- name: add comment
- name: find defect key on commits
uses: ./
env:
NODE_DEBUG: http, net, stream
with:
aqua-token: ${{ steps.login.outputs.token }}
defect: DF001268
comment: "${{ github.event.pusher.name }} pushed to repository: ${{ github.event.repository.full_name }}"
from: "${{ github.event.commits }}"
- name: logout to aqua saas instance
uses: aqua-github-actions/ga-aqua-logout@v1.0.0
with:
aqua-token: ${{ steps.login.outputs.token }}

aqua-token: ${{ steps.login.outputs.token }}
20 changes: 7 additions & 13 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ ifdef::env-github[]
:warning-caption: :warning:
endif::[]

= https://aqua-cloud.io[Aqua] Defect Comment
= https://aqua-cloud.io[Aqua] Find Defect Key

Add a comment / note to an aqua defect
Search for defect keys on a provided string.

_This github actions is inspired by https://github.com/atlassian/gajira-comment[gajira-comment]_
_This github actions is inspired by https://github.com/atlassian/gajira-find-issue-key[gajira-find-issue-key]_

NOTE: This GitHub Action requires https://github.com/uniqueck/ga-aqua-login[Aqua Login Action]
NOTE: This GitHub Action requires https://github.com/{organization}/ga-aqua-login[Aqua Login Action]

== Usage
An example workflow to add a comment to a defect:
Expand Down Expand Up @@ -45,13 +45,8 @@ jobs:
with:
aqua-base-url: ${{ secrets.AQUA_BASE_URL }}
aqua-token: ${{ steps.login.outputs.token }}
defect: DF001268
comment: new
- name: Logout
uses: {organization}/ga-aqua-logout@{ga-aqua-logout-version}
with:
aqua-base-url: ${{ secrets.AQUA_BASE_URL }}
aqua-token: ${{ steps.login.outputs.token }}
from: {{ github.event.commits.map(t.message).join(' ') }}
----

== Action Spec:
Expand All @@ -62,5 +57,4 @@ jobs:
=== Arguments
- `aqua-base-url` - URL of aqua instance. Example `https://aqua-saas2.andagon.com/aquaWebNG`
- `aqua-token` - Bearer token for authentication against aqua cloud instance.
- `defect` - Id of defect to update
- `comment` - Name of transition to update to e.g. (new, solved, reopened, paused, closed, in processing)
- `from` - String to search for defect keys
15 changes: 9 additions & 6 deletions action.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const Aqua = require('./lib/common/Aqua');
const core = require('@actions/core');


module.exports = class {
constructor({argv}) {
Expand All @@ -7,14 +9,15 @@ module.exports = class {
token: argv.token,
});

this.defect = argv.defect;
this.comment = argv.comment;
this.from = argv.from;
}

async execute() {
await this.Aqua.addComment({
defect: this.defect,
comment: this.comment,
});
core.info('From: ' + this.from);
// search for defect keys on from

// search for defect on aqua

// if defect on aqua exists, return this key
}
};
14 changes: 7 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Aqua Defect Comment'
description: 'Add a comment to a specific aqua defect.'
name: 'Aqua find defect key'
description: 'Find defect keys in commit messages or branch names.'
branding:
icon: 'droplet'
color: 'blue'
Expand All @@ -11,12 +11,12 @@ inputs:
aqua-token:
description: 'Bearer token for authentication against aqua cloud instance'
required: true
defect:
description: 'Key of the defect'
required: true
comment:
description: 'The comment to add'
from:
description: 'Provide a string to search for defect keys.'
required: true
outputs:
defect:
description: 'Key of the found defect key. If more than one are found, than the first one is returned.'
runs:
using: 'node12'
main: 'dist/index.js'
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ async function exec() {
/* eslint max-len: "off" */
if (!(process.env.AQUA_BASE_URL || core.getInput('aqua-base-url'))) throw new Error('Please specify aqua-base-url as input or AQUA_BASE_URL as env');
if (!(process.env.AQUA_TOKEN || core.getInput('aqua-token'))) throw new Error('Please specify aqua-token as input or AQUA_TOKEN as env');
if (!core.getInput('defect')) throw new Error('Please specify defect as input');
if (!core.getInput('comment')) throw new Error('Please specify comment as input');
if (!core.getInput('from')) throw new Error('Please specify from as input');

const argv = {
baseUrl: process.env.AQUA_BASE_URL || core.getInput('aqua-base-url'),
token: process.env.AQUA_TOKEN || core.getInput('aqua-token'),
defect: core.getInput('defect'),
comment: core.getInput('comment'),
from: core.getInput('from'),
};

await new Action({argv}).execute();
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "aqua-transition",
"name": "aqua-find-defect-key",
"version": "1.0.0",
"description": "Used to change status of defect on aqua cloud instance",
"description": "Used to find a defect key on a provided string",
"main": "index.js",
"scripts": {
"build": "ncc build index.js --minify",
Expand All @@ -10,15 +10,15 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/aqua-github-actions/ga-aqua-transition.git"
"url": "git+https://github.com/aqua-github-actions/ga-aqua-find-defect-key.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/aqua-github-actions/ga-aqua-transition/issues"
"url": "https://github.com/aqua-github-actions/ga-aqua-find-defect-key/issues"
},
"homepage": "https://github.com/aqua-github-actions/ga-aqua-transition#readme",
"homepage": "https://github.com/aqua-github-actions/ga-aqua-find-defect-key#readme",
"dependencies": {
"@actions/core": "^1.2.7",
"@actions/github": "^5.0.0",
Expand Down

0 comments on commit 9dc21e8

Please sign in to comment.