Skip to content

Commit aaae2ca

Browse files
authored
Merge pull request #24 from MiraGeoscience/Feature_zizmor_security
added zizmor security to workflow
2 parents e9f7f9b + bdea372 commit aaae2ca

5 files changed

Lines changed: 151 additions & 74 deletions

File tree

.github/workflows/issue_to_jira.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# This workflow will create a JIRA issue upon creation of a GitHub issue
22

33
name: Create JIRA issue
4+
permissions:
5+
contents: read
6+
issues: write
7+
pull-requests: write
48

59
on:
610
issues:
@@ -12,14 +16,14 @@ jobs:
1216

1317
steps:
1418
- name: JIRA Login
15-
uses: atlassian/gajira-login@v3.0.1
19+
uses: atlassian/gajira-login@45fd029b9f1d6d8926c6f04175aa80c0e42c9026
1620
env:
1721
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
1822
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
1923
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
2024
- name: Jira Create issue
2125
id: create_jira_issue
22-
uses: atlassian/gajira-create@v3.0.1
26+
uses: atlassian/gajira-create@59e177c4f6451399df5b4911c2211104f171e669
2327
with:
2428
project: GEOPY
2529
issuetype: Story
@@ -28,9 +32,9 @@ jobs:
2832
# Additional fields in JSON format
2933
#fields: '{"components": [{"name": "grid-apps"}]}'
3034
- name: Post JIRA link
31-
uses: peter-evans/create-or-update-comment@v3
35+
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2
3236
with:
3337
# The number of the issue or pull request in which to create a comment.
3438
issue-number: ${{ github.event.issue.number }}
3539
# The comment body.
36-
body: "JIRA issue [${{ steps.create_jira_issue.outputs.issue }}] was created."
40+
body: "JIRA issue [${{ steps.create_jira_issue.outputs.issue }}] was created."
Lines changed: 71 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,83 @@
11
# This workflow will comment the PR with the JIRA issue summary
22
# if a JIRA issue number is detected in the branch name or title
33

4-
name: Add JIRA issue summary
4+
name: Add JIRA Summary to PR
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
59

610
on:
7-
pull_request_target:
11+
pull_request:
812
types: [opened]
913

1014
jobs:
1115
add_jira_summary:
16+
if: github.event.pull_request.head.repo.full_name == github.repository
1217
runs-on: ubuntu-latest
1318

1419
steps:
15-
- name: Find JIRA issue key
16-
id: find_jira_key
17-
env:
18-
HEAD_REF: ${{ github.head_ref}}
19-
PR_TITLE: ${{ github.event.pull_request.title }}
20-
run: >
21-
echo $HEAD_REF $PR_TITLE
22-
| echo "issue_key=$(
23-
grep -osi "\b\(GA\|GEOPY\|DEVOPS\)[ #-]*[0-9]\+"
24-
| head -n1
25-
| sed -E "s/([A-Z]+)[-# ]*([0-9]+)/\1-\2/i"
26-
| tr [:lower:] [:upper:]
27-
)"
28-
>> $GITHUB_OUTPUT
29-
- name: Get JIRA summary
30-
id: get_jira_summary
31-
if: ${{ steps.find_jira_key.outputs.issue_key }}
32-
env:
33-
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
34-
JIRA_BASIC_AUTH: ${{ secrets.JIRA_BASIC_AUTH }}
35-
run: >
36-
curl -sS -X GET
37-
-H "Authorization: Basic $JIRA_BASIC_AUTH"
38-
-H "Content-Type: application/json"
39-
"$JIRA_BASE_URL/rest/api/2/issue/${{ steps.find_jira_key.outputs.issue_key }}"
40-
| echo "summary=$(jq -r '.fields.summary // empty')" >> $GITHUB_OUTPUT
41-
- name: Extract PR title
42-
id: get_pr_title
43-
env:
44-
PR_TITLE: ${{ github.event.pull_request.title }}
45-
run: |
46-
echo "text=$(echo $PR_TITLE | sed -E "s/^\s*[?[A-Z]+[-# ]*[0-9]+]?[-: ]*(.*)/\1/i")" >> $GITHUB_OUTPUT
47-
- name: Add comment
48-
if: ${{ steps.find_jira_key.outputs.issue_key }}
49-
env:
50-
ISSUE_SUMMARY: ${{ steps.get_jira_summary.outputs.summary }}
51-
TITLE_TEXT: ${{ steps.get_pr_title.outputs.text }}
52-
PR_BODY: ${{ github.event.pull_request.body }}
53-
run: >
54-
jq
55-
--arg ISSUE_ID "${{ steps.find_jira_key.outputs.issue_key }}"
56-
--arg ISSUE_SUMMARY "$(cat <<< $ISSUE_SUMMARY)"
57-
--arg TITLE_TEXT "$(cat <<< ${TITLE_TEXT:-$ISSUE_SUMMARY})"
58-
--arg PR_BODY "$(cat <<< $PR_BODY)"
59-
-c '{"title": ($ISSUE_ID + ": " + $TITLE_TEXT), "body": ("**" + $ISSUE_ID + " - " + $ISSUE_SUMMARY + "**\n" + $PR_BODY)}' <<< {}
60-
| curl -sS -X POST -d @-
61-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}"
62-
-H "Content-Type: application/json"
63-
"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/${{ github.event.pull_request.number }}"
64-
> /dev/null
20+
- name: Find JIRA issue key
21+
id: find_jira_key
22+
env:
23+
HEAD_REF: ${{ github.head_ref }}
24+
PR_TITLE: ${{ github.event.pull_request.title }}
25+
run: |
26+
echo "$HEAD_REF $PR_TITLE" \
27+
| grep -osi "\b\(GA\|GEOPY\|DEVOPS\)[ #-]*[0-9]\+" \
28+
| head -n1 \
29+
| sed -E "s/([A-Z]+)[-# ]*([0-9]+)/\1-\2/i" \
30+
| tr '[:lower:]' '[:upper:]' \
31+
| xargs -I {} echo "issue_key={}" >> $GITHUB_OUTPUT
32+
33+
- name: Get JIRA summary
34+
id: get_jira_summary
35+
if: ${{ steps.find_jira_key.outputs.issue_key }}
36+
env:
37+
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
38+
JIRA_BASIC_AUTH: ${{ secrets.JIRA_BASIC_AUTH }}
39+
ISSUE_KEY: ${{ steps.find_jira_key.outputs.issue_key }}
40+
run: |
41+
curl -sS -X GET \
42+
-H "Authorization: Basic $JIRA_BASIC_AUTH" \
43+
-H "Content-Type: application/json" \
44+
"$JIRA_BASE_URL/rest/api/2/issue/$ISSUE_KEY" \
45+
| jq -r '.fields.summary // empty' \
46+
| xargs -I {} echo "summary={}" >> $GITHUB_OUTPUT
47+
48+
- name: Extract PR title
49+
id: get_pr_title
50+
env:
51+
PR_TITLE: ${{ github.event.pull_request.title }}
52+
run: |
53+
echo "text=$(echo "$PR_TITLE" | sed -E 's/^\s*[?[A-Z]+[-# ]*[0-9]+]?[-: ]*(.*)/\1/i')" >> $GITHUB_OUTPUT
54+
55+
- name: Add comment
56+
if: ${{ steps.find_jira_key.outputs.issue_key }}
57+
env:
58+
ISSUE_KEY: ${{ steps.find_jira_key.outputs.issue_key }}
59+
ISSUE_SUMMARY: ${{ steps.get_jira_summary.outputs.summary }}
60+
TITLE_TEXT: ${{ steps.get_pr_title.outputs.text }}
61+
PR_BODY: ${{ github.event.pull_request.body }}
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
GITHUB_API_URL: ${{ github.api_url }}
64+
GITHUB_REPOSITORY: ${{ github.repository }}
65+
PR_NUMBER: ${{ github.event.pull_request.number }}
66+
run: |
67+
FINAL_TITLE="${TITLE_TEXT:-$ISSUE_SUMMARY}"
68+
COMMENT_PAYLOAD=$(jq -c --null-input \
69+
--arg ISSUE_ID "$ISSUE_KEY" \
70+
--arg ISSUE_SUMMARY "$ISSUE_SUMMARY" \
71+
--arg TITLE_TEXT "$FINAL_TITLE" \
72+
--arg PR_BODY "$PR_BODY" \
73+
'{
74+
title: ($ISSUE_ID + ": " + $TITLE_TEXT),
75+
body: ("**" + $ISSUE_ID + " - " + $ISSUE_SUMMARY + "**\n" + $PR_BODY)
76+
}')
77+
78+
curl -sS -X POST \
79+
-H "Authorization: token $GITHUB_TOKEN" \
80+
-H "Content-Type: application/json" \
81+
-d "$COMMENT_PAYLOAD" \
82+
"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER" \
83+
> /dev/null

.github/workflows/pytest-unix-os.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ on:
1717
- feature/**
1818
- hotfix/**
1919

20+
permissions:
21+
contents: read
22+
pull-requests: read
23+
2024
concurrency:
2125
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
2226
cancel-in-progress: true
@@ -40,17 +44,28 @@ jobs:
4044
env:
4145
PYTHONUTF8: 1
4246
CONDA_CHANNEL_PRIORITY: strict
43-
PIP_NO_DEPS: 1 # all dependencies are installed from conda
47+
PIP_NO_DEPS: 1
4448
CONDA_LOCK_ENV_FILE: environments/py-${{ matrix.python_ver }}-${{ startsWith(matrix.os, 'macos') && 'osx' || 'linux' }}-64-dev.conda.lock.yml
49+
4550
steps:
46-
- uses: actions/checkout@v4
51+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
4752
with:
4853
lfs: true
54+
persist-credentials: false
55+
4956
- name: Setup conda env
50-
uses: mamba-org/setup-micromamba@v1
57+
uses: mamba-org/setup-micromamba@4b9113af4fba0e9e1124b252dd6497a419e7396d
5158
with:
5259
environment-file: ${{ env.CONDA_LOCK_ENV_FILE }}
5360
environment-name: test_env
5461
cache-downloads: true
62+
5563
- name: pytest
5664
run: pytest --cov --cov-report=xml
65+
66+
- name: Upload coverage to Codecov
67+
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457
68+
with:
69+
token: ${{ secrets.CODECOV_TOKEN }}
70+
files: ./coverage.xml
71+
flags: unix

.github/workflows/pytest-windows.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: pytest on Windows
22

3+
permissions:
4+
contents: read
5+
pull-requests: read
6+
37
on:
48
pull_request:
59
types: [opened, synchronize, reopened, ready_for_review]
@@ -42,11 +46,12 @@ jobs:
4246
PIP_NO_DEPS: 1 # all dependencies are installed from conda
4347
CONDA_LOCK_ENV_FILE: environments/py-${{ matrix.python_ver }}-win-64-dev.conda.lock.yml
4448
steps:
45-
- uses: actions/checkout@v4
49+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
4650
with:
4751
lfs: true
52+
persist-credentials: false
4853
- name: Setup conda env
49-
uses: mamba-org/setup-micromamba@v1
54+
uses: mamba-org/setup-micromamba@4b9113af4fba0e9e1124b252dd6497a419e7396d
5055
with:
5156
environment-file: ${{ env.CONDA_LOCK_ENV_FILE }}
5257
environment-name: test_env
@@ -56,7 +61,7 @@ jobs:
5661
run: pytest --cov --cov-report=xml
5762
- name: Codecov
5863
if: ${{ success() && matrix.python_ver == '3.10' }}
59-
uses: codecov/codecov-action@v3
64+
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457
6065
with:
6166
name: GitHub
62-
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
67+
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos

.github/workflows/static-analysis.yml

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: static analysis
22

3+
permissions:
4+
contents: read
5+
6+
37
on:
48
pull_request:
59
types: [opened, synchronize, reopened, ready_for_review]
@@ -27,30 +31,44 @@ env:
2731
jobs:
2832
pre-commit:
2933
name: pre-commit
30-
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
34+
#if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
3135
strategy:
3236
fail-fast: false
3337
runs-on: ubuntu-latest
3438
env:
3539
SKIP: pylint
3640
steps:
37-
- uses: actions/checkout@v4
38-
- uses: actions/setup-python@v4
41+
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2
42+
with:
43+
persist-credentials: true
44+
- name: Setup conda env
45+
uses: mamba-org/setup-micromamba@4b9113af4fba0e9e1124b252dd6497a419e7396d
46+
with:
47+
environment-file: environments/py-3.10-linux-64-dev.conda.lock.yml
48+
environment-name: linter_env
49+
cache-downloads: true
50+
- uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c
51+
- name: Set base_ref
52+
if: github.event_name == 'pull_request'
53+
run: |
54+
echo "BASE_REF<<EOF" >> $GITHUB_ENV
55+
echo "${GITHUB_BASE_REF}" >> $GITHUB_ENV
56+
echo "EOF" >> $GITHUB_ENV
3957
- name: capture modified files
4058
if: github.event_name == 'pull_request'
4159
run: >-
42-
git fetch --deepen=500 origin ${{github.base_ref}}
60+
git fetch --deepen=500 origin "$BASE_REF"
4361
&& echo "FILES_PARAM=$(
44-
git diff --diff-filter=AM --name-only refs/remotes/origin/${{github.base_ref}}... -- | grep -E "^(${source_dir}|tests)/.*\.py$" | xargs
62+
git diff --diff-filter=AM --name-only refs/remotes/origin/"$BASE_REF"... -- | grep -E "^(${source_dir}|tests)/.*\.py$" | xargs
4563
)" >> $GITHUB_ENV
4664
- name: Run pre-commit on modified files
4765
if: github.event_name == 'pull_request' && env.FILES_PARAM
48-
uses: pre-commit/action@v3.0.0
66+
uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507
4967
with:
5068
extra_args: --hook-stage push --files ${{ env.FILES_PARAM }}
5169
- name: Run pre-commit on all files
5270
if: github.event_name == 'push'
53-
uses: pre-commit/action@v3.0.0
71+
uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507
5472
with:
5573
extra_args: --hook-stage push --all-files
5674

@@ -67,23 +85,39 @@ jobs:
6785
PIP_NO_DEPS: 1 # all dependencies are installed from conda
6886
CONDA_LOCK_ENV_FILE: environments/py-3.10-linux-64-dev.conda.lock.yml
6987
steps:
70-
- uses: actions/checkout@v4
88+
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2
89+
with:
90+
persist-credentials: true
7191
- name: Setup conda env
72-
uses: mamba-org/setup-micromamba@v1
92+
uses: mamba-org/setup-micromamba@feb7656f829886af1ab11cf61126b048557b2e19
7393
with:
7494
environment-file: ${{ env.CONDA_LOCK_ENV_FILE }}
7595
environment-name: linter_env
7696
cache-downloads: true
97+
- name: Set base_ref
98+
if: github.event_name == 'pull_request'
99+
run: |
100+
echo "BASE_REF<<EOF" >> $GITHUB_ENV
101+
echo "${GITHUB_BASE_REF}" >> $GITHUB_ENV
102+
echo "EOF" >> $GITHUB_ENV
77103
- name: capture modified files
78104
if: github.event_name == 'pull_request'
79105
run: >-
80-
git fetch --deepen=500 origin ${{github.base_ref}}
106+
git fetch --deepen=500 origin "$BASE_REF"
81107
&& echo "FILES_PARAM=$(
82-
git diff --diff-filter=AM --name-only refs/remotes/origin/${{github.base_ref}}... -- | grep -E "^(${source_dir}|tests)/.*\.py$" | xargs
108+
git diff --diff-filter=AM --name-only refs/remotes/origin/"$BASE_REF"... -- | grep -E "^(${source_dir}|tests)/.*\.py$" | xargs
83109
)" >> $GITHUB_ENV
84110
- name: Run pylint on modified files
85111
if: github.event_name == 'pull_request' && env.FILES_PARAM
86112
run: pylint $FILES_PARAM
87113
- name: Run pylint on all files
88114
if: github.event_name == 'push'
89115
run: pylint $source_dir tests
116+
call-workflow-zizmor:
117+
name: Zizmor Security Scan
118+
permissions:
119+
contents: read
120+
actions: read
121+
uses: MiraGeoscience/CI-tools/.github/workflows/reusable-zizmor-security.yml@feature_zizmor_security
122+
with:
123+
app-name: 'grid-apps'

0 commit comments

Comments
 (0)