Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pattern-metrics: Merge to one report #599

Merged
merged 3 commits into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 13 additions & 51 deletions .github/workflows/pattern-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,69 +60,31 @@ jobs:
HIDE_TIME_TO_ANSWER: "True"
HIDE_LABEL_METRICS: "True"

- name: Create issue
uses: peter-evans/create-issue-from-file@v4
with:
title: Monthly New Issues Data ${{ env.last_month }}
token: ${{ secrets.GITHUB_TOKEN }}
content-filepath: ./issue_metrics.md
assignees: spier

pr-metrics:
name: pull request metrics
runs-on: ubuntu-latest

steps:

- name: Get dates for last month
- name: Change markdown file name to prep for a merge
shell: bash
run: |
# Calculate the first day of the previous month
first_day=$(date -d "last month" +%Y-%m-01)
mv ./issue_metrics.md ready_to_merge_issues_report.md

# Calculate the last day of the previous month
last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d)

#Set an environment variable with the date range
echo "$first_day..$last_day"
echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV"

- name: Check out the code so we can get the CODEOWNERS names
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/CODEOWNERS
sparse-checkout-cone-mode: false

- name: Get usernames from CODEOWNERS file
shell: bash
run: |
# open a file called CODEOWNERS and load the content into a variable
CODEOWNERS_FILE=$(cat .github/CODEOWNERS)

# Extract words from CODEOWNERS that start with @ and convert them into a comma-separated string
# ie, "-author:spier -author:zkoppert"
# This will be used to filter out these codeowners from certain stats in later steps
CODEOWNERS_FILTER=$(echo $CODEOWNERS_FILE | grep -o "@[a-zA-Z0-9\-]*" | sed 's/@/-author:/g' | sort | uniq | tr '\n' ' ')

# Print usernames to terminal for easy debugging
echo "CODEOWNERS_FILTER: $CODEOWNERS_FILTER"

# Store CODEOWNERS_FILTERto GitHub Action environment (not permanent)
echo "CODEOWNERS_FILTER=$CODEOWNERS_FILTER" >> "$GITHUB_ENV"

- name: Run issue-metrics tool
- name: Run issue-metrics tool for PRs
uses: github/issue-metrics@v2
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEARCH_QUERY: 'repo:InnerSourceCommons/InnerSourcePatterns is:pr created:${{ env.last_month }} -reason:"not planned" ${{ env.CODEOWNERS_FILTER }}'
HIDE_TIME_TO_ANSWER: "True"
HIDE_LABEL_METRICS: "True"

- name: Merge files for report
shell: bash
run: |
echo $'\n\n---\n\n' > hr.md
cat ready_to_merge_issues_report.md hr.md issue_metrics.md > all.md

- name: Create issue
uses: peter-evans/create-issue-from-file@v4
with:
title: Monthly New Pull Request Data ${{ env.last_month }}
title: Monthly Metrics: New Issues + New Pull Requests ${{ env.last_month }}
token: ${{ secrets.GITHUB_TOKEN }}
content-filepath: ./issue_metrics.md
content-filepath: ./all.md
assignees: spier
spier marked this conversation as resolved.
Show resolved Hide resolved
labels: |
community metrics
Loading