-
Notifications
You must be signed in to change notification settings - Fork 1.7k
100 lines (90 loc) · 4.09 KB
/
solidity-jira.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# This is its own independent workflow since "solidity.yml" depends on "merge_group" and "push" events.
# But for ensuring that JIRA tickets are always updated, we only care about "pull_request" events.
#
# We still need to add "merge_group" event and noop so that we'll pass required workflow checks.
#
# I didn't add this to the "changeset.yml" workflow because the "changeset" job isnt required, and we'd need to add the "merge_group" event to the "changeset.yml" workflow.
# If we made the change to make it required.
name: Solidity Jira
on:
merge_group:
pull_request:
defaults:
run:
shell: bash
jobs:
skip-enforce-jira-issue:
name: Should Skip
# We want to skip merge_group events, and any release branches
# Since we only want to enforce Jira issues on pull requests related to feature branches
if: ${{ github.event_name != 'merge_group' && !startsWith(github.head_ref, 'release/') }}
outputs:
should-enforce: ${{ steps.changed_files.outputs.only_src_contracts }}
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
# We don't use detect-solidity-file-changes here because we need to use the "every" predicate quantifier
- name: Filter paths
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changed_files
with:
list-files: "csv"
# This is a valid input, see https://github.com/dorny/paths-filter/pull/226
predicate-quantifier: "every"
filters: |
only_src_contracts:
- contracts/**/*.sol
- '!contracts/**/*.t.sol'
- name: Collect Metrics
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d9da21a2747016b3e13de58c7d4115a3d5c97935 # v3.0.1
with:
id: solidity-jira
org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }}
this-job-name: Should Skip
continue-on-error: true
enforce-jira-issue:
name: Enforce Jira Issue
runs-on: ubuntu-latest
# If a needs job is skipped, this job will be skipped and counted as successful
# The job skips on merge_group events, and any release branches
# Since we only want to enforce Jira issues on pull requests related to feature branches
needs: [skip-enforce-jira-issue]
# In addition to the above conditions, we only want to running on solidity related PRs.
#
# Note: A job that is skipped will report its status as "Success".
# It will not prevent a pull request from merging, even if it is a required check.
if: ${{ needs.skip-enforce-jira-issue.outputs.should-enforce == 'true' }}
steps:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Setup NodeJS
uses: ./.github/actions/setup-nodejs
- name: Setup Jira
working-directory: ./.github/scripts/jira
run: pnpm i
- name: Enforce Jira Issue
working-directory: ./.github/scripts/jira
run: |
echo "COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s')" >> $GITHUB_ENV
pnpm issue:enforce
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JIRA_HOST: ${{ secrets.JIRA_HOST }}
JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
PR_TITLE: ${{ github.event.pull_request.title }}
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
- name: Collect Metrics
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d9da21a2747016b3e13de58c7d4115a3d5c97935 # v3.0.1
with:
id: solidity-jira
org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }}
this-job-name: Enforce Jira Issue
continue-on-error: true