-
Notifications
You must be signed in to change notification settings - Fork 1
Add organization repository report workflow and report generation script #89
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
Open
mimiflynn
wants to merge
16
commits into
main
Choose a base branch
from
workflow-github-org-report
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
27266ea
Add organization repository report workflow and report generation script
mimiflynn 3420a7d
Potential fix for pull request finding
mimiflynn 83b6c9a
Potential fix for pull request finding
mimiflynn 0f336ab
Refactor GitHub API request handling and improve report generation logic
mimiflynn edc3117
Merge branch 'workflow-github-org-report' of github.com:morganstanley…
mimiflynn aeda25a
Refactor CSV and Markdown writing functions to use a consistent UNKNO…
mimiflynn 3ae6e9a
Enhance workflow to support pull request validation and artifact uplo…
mimiflynn ff11c88
Refactor GitHub API request handling for improved readability and err…
mimiflynn edbfcba
dependabot config for actions
mimiflynn d5916cf
Enhance GitHub workflow to validate report script changes and run tes…
mimiflynn a0bf516
Refactor report script change detection to use GitHub API for improve…
mimiflynn 526d1cb
Refactor import statement for report module to improve code organization
mimiflynn 38f550c
Refactor GitHubClient to improve data handling and simplify audit sup…
mimiflynn d92cf9a
Fix import statement for report module to enhance code organization
mimiflynn 7165a7b
Fix import statement for report module to comply with linting rules
mimiflynn 889ba60
Remove workflow_dispatch and pull_request triggers from org-repo-repo…
mimiflynn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: github-actions | ||
| directory: / | ||
| schedule: | ||
| interval: weekly | ||
| open-pull-requests-limit: 5 | ||
| commit-message: | ||
| prefix: chore | ||
| - package-ecosystem: pip | ||
| directory: /reporting | ||
| schedule: | ||
| interval: weekly | ||
| open-pull-requests-limit: 5 | ||
| commit-message: | ||
| prefix: chore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| name: Organization Repository Report | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 6 * * 1' | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: read | ||
|
|
||
| concurrency: | ||
| group: org-repo-report-github-org-stats | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| generate-org-repo-report: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GH_TOKEN }} | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Detect report script changes | ||
| if: ${{ github.event_name == 'pull_request' }} | ||
| id: report-script-changes | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const files = await github.paginate(github.rest.pulls.listFiles, { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| pull_number: context.payload.pull_request.number, | ||
| per_page: 100, | ||
| }); | ||
|
|
||
| const reportScriptChanged = files.some( | ||
| (file) => file.filename === 'reporting/generate_org_repo_report.py' | ||
| ); | ||
|
|
||
| core.info(`report_script changed: ${reportScriptChanged}`); | ||
| core.setOutput('report_script', reportScriptChanged ? 'true' : 'false'); | ||
|
|
||
| - name: Run report script tests | ||
| if: ${{ github.event_name == 'pull_request' && steps.report-script-changes.outputs.report_script == 'true' }} | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -r reporting/requirements-dev.txt | ||
| ruff check reporting | ||
| mypy reporting/generate_org_repo_report.py | ||
| pytest -q reporting/tests | ||
|
|
||
| - name: Generate report | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| ORG_NAME: morganstanley | ||
| OUTPUT_CSV: reporting/org-repo-report.csv | ||
| OUTPUT_MD: reporting/org-repo-report.md | ||
| run: python reporting/generate_org_repo_report.py | ||
|
mimiflynn marked this conversation as resolved.
|
||
|
|
||
| - name: Upload report artifacts for PR validation | ||
| if: ${{ github.event_name == 'pull_request' }} | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: org-repo-report | ||
| path: | | ||
| reporting/org-repo-report.csv | ||
| reporting/org-repo-report.md | ||
|
|
||
| - name: Commit and push report | ||
| if: ${{ github.event_name != 'pull_request' }} | ||
| run: | | ||
|
mimiflynn marked this conversation as resolved.
|
||
| set -euo pipefail | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| git checkout -B github-org-stats | ||
| git add reporting/org-repo-report.csv reporting/org-repo-report.md | ||
| if git diff --cached --quiet; then | ||
| echo "No report changes to commit." | ||
| exit 0 | ||
| fi | ||
| git commit -m "chore(reporting): update organization repository report" | ||
| git push origin HEAD:github-org-stats | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| __pycache__/ | ||
| *.py[cod] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.