Skip to content

Commit

Permalink
[#ICC-321] remove danger (#30)
Browse files Browse the repository at this point in the history
* remove Danger.ts

* remove danger from pipeline

* remove danger packages

* add github action to validate pr title

* remove danger ref from .eslintrc
  • Loading branch information
Garma00 authored Jan 30, 2023
1 parent 2a9b34a commit 761dda5
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 730 deletions.
19 changes: 1 addition & 18 deletions .devops/code-review-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# Azure DevOps pipeline to build, check source codes and run tests.
# To make Danger JS run on a pull request you need to add the following pipeline
# variable and set it with a GitHub access token (scope public_repo); otherwise
# set its value to 'skip' without marking it secret:
# - DANGER_GITHUB_API_TOKEN

# Automatically triggered on PR
# https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema#pr-trigger
Expand Down Expand Up @@ -38,20 +34,7 @@ stages:
- bash: |
yarn lint
displayName: 'Lint'
- job: danger
condition:
and(
succeeded(),
ne(variables['DANGER_GITHUB_API_TOKEN'], 'skip')
)
steps:
- template: templates/node-job-setup/template.yaml@pagopaCommons
- bash: |
yarn danger ci
env:
DANGER_GITHUB_API_TOKEN: '$(DANGER_GITHUB_API_TOKEN)'
displayName: 'Danger CI'
- stage: Test
dependsOn: []
jobs:
Expand Down
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
"generated",
"**/__tests__/*",
"**/__mocks__/*",
"Dangerfile.*",
"*.d.ts"
],
"parser": "@typescript-eslint/parser",
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/pr-title-linter-and-linker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: "Lint and Link PR title"

on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize

jobs:
lint:
name: Validate PR title And link Jira Issue
runs-on: ubuntu-22.04
env:
JIRA_COMMENT_REGEX: "^.*Jira.*"
steps:
- uses: Slashgear/action-check-pr-title@860e8dc639f8e60335a6f5e8936ba67ed2536890
id: lint
with:
regexp: "\\[(#?[A-Z]*-[0-9]*( |, )?){1,}\\]" # Regex the title should match.
continue-on-error: true

- name: Find Jira Comment
uses: peter-evans/find-comment@81e2da3af01c92f83cb927cf3ace0e085617c556
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-regex: "${{ env.JIRA_COMMENT_REGEX }}"

- name: Extract Jira Issue to Link
id: extract_jira_issue
if: steps.lint.outcome == 'success'
run: |
PR_TITLE=$(echo "${{ github.event.pull_request.title }}")
ISSUES_STR=$(awk -F'\\[|\\]' '{print $2}' <<< "$PR_TITLE" | sed "s/#//g" | sed "s/,//g")
ISSUES=($ISSUES_STR)
JIRA_ISSUE=$(echo ${ISSUES_STR##* })
MARKDOWN_CARRIAGE_RETURN="<br>"
MARKDOWN_PREFIX="- Link to"
JIRA_COMMENT_MARKDOWN="This Pull Request refers to Jira issues:<br>"
if [[ ${#ISSUES[@]} -eq 1 ]]
then
JIRA_COMMENT_MARKDOWN="This Pull Request refers to the following Jira issue"
MARKDOWN_PREFIX=""
fi
for ISSUE in "${ISSUES[@]}"
do
JIRA_COMMENT_MARKDOWN+="$MARKDOWN_PREFIX [$ISSUE](https://pagopa.atlassian.net/browse/$ISSUE) $MARKDOWN_CARRIAGE_RETURN"
done
echo "JIRA_ISSUE=$JIRA_ISSUE" >> $GITHUB_ENV
echo "JIRA_COMMENT_MARKDOWN=$JIRA_COMMENT_MARKDOWN" >> $GITHUB_ENV
- name: Create Jira Link comment
if: steps.lint.outcome == 'success'
uses: peter-evans/create-or-update-comment@5adcb0bb0f9fb3f95ef05400558bdb3f329ee808
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## Jira Pull Request Link ##
${{ env.JIRA_COMMENT_MARKDOWN }}
edit-mode: replace
- name: Create Empty Jira Link comment
if: steps.lint.outcome != 'success'
uses: peter-evans/create-or-update-comment@5adcb0bb0f9fb3f95ef05400558bdb3f329ee808
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## Jira Pull request Link ##
It seems this Pull Request has no issues that refers to Jira!!!
Please check it out.
edit-mode: replace
- name: Failure message
if: steps.lint.outcome != 'success'
run: |
echo "Pull request title (${{ github.event.pull_request.title }}) is not properly formatted or it is not related to any Jira issue"
exit 1
6 changes: 0 additions & 6 deletions Dangerfile.ts

This file was deleted.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
"lint": "eslint . -c .eslintrc.js --ext .ts,.tsx"
},
"devDependencies": {
"@pagopa/danger-custom-rules": "^2.0.3",
"@pagopa/eslint-config": "^1.3.1",
"@types/jest": "^25.2.1",
"@types/node": "^14.17.0",
"danger": "^11.0.7",
"danger-plugin-digitalcitizenship": "*",
"eslint-plugin-prettier": "^3.1.1",
"jest": "^25.2.7",
"prettier": "^1.12.1",
Expand Down
Loading

0 comments on commit 761dda5

Please sign in to comment.