Skip to content

Commit e7ef90e

Browse files
committed
Share and integrate workflow to commit analysis results
1 parent eabd86d commit e7ef90e

File tree

2 files changed

+89
-50
lines changed

2 files changed

+89
-50
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Commit Results
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
commit-author-name:
7+
description: "The display name of the commit author"
8+
required: false
9+
type: string
10+
default: '${{ github.event.repository.name }} Continuous Integration'
11+
commit-author-email:
12+
description: "The email address of the commit author"
13+
required: true
14+
type: string
15+
commit-message:
16+
description: "The commit message"
17+
required: false
18+
type: string
19+
default: "ci: Add automated results"
20+
commit-directory:
21+
description: "The directory to commit"
22+
required: true
23+
type: string
24+
uploaded-artifact-name:
25+
description: "The name of the uploaded artifact"
26+
required: true
27+
type: string
28+
secrets:
29+
repository-commit-token:
30+
description: "The token to use for committing to the repository"
31+
required: true
32+
33+
jobs:
34+
commit-results:
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Checkout GIT Repository
39+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
40+
with:
41+
token: ${{ secrets.repository-commit-token }}
42+
43+
- name: Download artifacts to commit
44+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
45+
with:
46+
name: ${{ inputs.uploaded-artifact-name }}
47+
path: ${{ inputs.commit-directory }}
48+
49+
- name: Display environment variable "github.event_name"
50+
run: echo "github.event_name=${{ github.event_name }}"
51+
52+
- name: Display changes in the ${{ inputs.commit-directory }} directory and prepare commit
53+
run: |
54+
git config --global user.name '${{ inputs.commit-author-name }}'
55+
git config --global user.email '${{ inputs.commit-author-email }}'
56+
git config --local http.postBuffer 524288000
57+
git fetch origin
58+
git status
59+
git add ${{ inputs.commit-directory }}
60+
git status
61+
62+
- name: Commit and push changes in the ${{ inputs.commit-directory }} directory
63+
# Only run when a pull request gets merged or a commit is pushed to the main branch
64+
if: github.event_name == 'push'
65+
run: |
66+
git commit --message "${{ inputs.commit-message }}"
67+
git status
68+
git rebase --strategy-option=theirs origin/main --verbose
69+
git status
70+
git add ${{ inputs.commit-directory }}
71+
git status
72+
git push --verbose

.github/workflows/java-code-analysis.yml

Lines changed: 17 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ on:
3939
jobs:
4040
prepare-code-to-analyze:
4141
runs-on: ubuntu-latest
42-
outputs:
43-
analysis-name: ${{ steps.set-analysis-name.outputs.analysis-name }}
44-
sources-upload-name: ${{ steps.set-sources-upload-name.outputs.sources-upload-name }}
45-
artifacts-upload-name: ${{ steps.set-artifacts-upload-name.outputs.artifacts-upload-name }}
46-
4742
env:
4843
PROJECT_NAME: AxonFramework
4944
# Version variable names matches renovate.json configuration entry
5045
AXON_FRAMEWORK_VERSION: 4.10.3
5146
# Java is in this example only used to download JARs for analysis using Maven
5247
JAVA_VERSION: 21
48+
outputs:
49+
project-name: ${{ env.PROJECT_NAME }}
50+
analysis-name: ${{ steps.set-analysis-name.outputs.analysis-name }}
51+
sources-upload-name: ${{ steps.set-sources-upload-name.outputs.sources-upload-name }}
52+
artifacts-upload-name: ${{ steps.set-artifacts-upload-name.outputs.artifacts-upload-name }}
5353

5454
steps:
5555
- name: (Prepare Code to Analyze) Checkout AxonFramework repository
@@ -113,6 +113,7 @@ jobs:
113113

114114

115115
analyze-code-graph:
116+
name: Run Code Graph Analysis
116117
needs: [prepare-code-to-analyze]
117118
uses: JohT/code-graph-analysis-pipeline/.github/workflows/public-analyze-code-graph.yml@7f43cf96d676f715cf278b020ce1dbb3338f900b # v2
118119
with:
@@ -122,49 +123,15 @@ jobs:
122123
ref: 7f43cf96d676f715cf278b020ce1dbb3338f900b
123124

124125

125-
analysis-results:
126+
commit-analysis-results:
127+
name: Commit Analysis Results
126128
needs: [prepare-code-to-analyze, analyze-code-graph]
127-
runs-on: ubuntu-latest
128-
129-
env:
130-
CI_COMMIT_MESSAGE: Automated code structure analysis analysis-results (CI)
131-
CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} Continuous Integration
132-
133-
steps:
134-
- name: Checkout GIT Repository
135-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
136-
with:
137-
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
138-
139-
- name: Download source code and artifacts for analysis
140-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
141-
with:
142-
name: ${{ needs.analyze-code-graph.outputs.uploaded-analysis-results }}
143-
path: analysis-results/${{ needs.prepare-code-to-analyze.outputs.analysis-name }}
144-
145-
# Commit and push the native image agent analysis-results
146-
- name: Display environment variable "github.event_name"
147-
run: echo "github.event_name=${{ github.event_name }}"
148-
- name: Display changes in the "analysis-results" directory and prepare commit
149-
# Only run when a pull request gets merged or a commit is pushed to the main branch
150-
# git add parameters need to match paths-ignore parameters above
151-
# Git pull before add/commit/push to reduce race conditions on parallel builds
152-
run: |
153-
git config --global user.name '${{ env.CI_COMMIT_AUTHOR }}'
154-
git config --global user.email "[email protected]"
155-
git config --local http.postBuffer 524288000
156-
git fetch origin
157-
git status
158-
git add analysis-results
159-
git status
160-
- name: Commit and push changes in the "analysis-results" directory
161-
# Only run when a pull request gets merged or a commit is pushed to the main branch
162-
# git add parameters need to match paths-ignore parameters above
163-
# Git pull before add/commit/push to reduce race conditions on parallel builds
164-
if: github.event_name == 'push'
165-
run: |
166-
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
167-
git status
168-
git rebase --strategy-option=theirs origin/main --verbose
169-
git status
170-
git push --verbose
129+
uses: ./.github/workflows/internal-commit-results.yml
130+
with:
131+
commit-author-name: "${{ github.event.repository.name }} Continuous Integration"
132+
commit-author-email: "[email protected]"
133+
commit-message: "Automated code structure analysis results (CI)"
134+
commit-directory: "analysis-results/${{ needs.prepare-code-to-analyze.outputs.project-name }}"
135+
uploaded-artifact-name: ${{ needs.analyze-code-graph.outputs.uploaded-analysis-results }}
136+
secrets:
137+
repository-commit-token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}

0 commit comments

Comments
 (0)