Skip to content

Commit 510fe45

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

File tree

3 files changed

+104
-95
lines changed

3 files changed

+104
-95
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: Prepare commit of changes in `${{ inputs.commit-directory }}`
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 `${{ inputs.commit-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: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,19 @@ on:
3838

3939
jobs:
4040
prepare-code-to-analyze:
41+
name: Prepare Code to Analyze
4142
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-
4743
env:
4844
PROJECT_NAME: AxonFramework
4945
# Version variable names matches renovate.json configuration entry
5046
AXON_FRAMEWORK_VERSION: 4.10.3
5147
# Java is in this example only used to download JARs for analysis using Maven
5248
JAVA_VERSION: 21
49+
outputs:
50+
project-name: ${{ env.PROJECT_NAME }}
51+
analysis-name: ${{ steps.set-analysis-name.outputs.analysis-name }}
52+
sources-upload-name: ${{ steps.set-sources-upload-name.outputs.sources-upload-name }}
53+
artifacts-upload-name: ${{ steps.set-artifacts-upload-name.outputs.artifacts-upload-name }}
5354

5455
steps:
5556
- name: (Prepare Code to Analyze) Checkout AxonFramework repository
@@ -113,6 +114,7 @@ jobs:
113114

114115

115116
analyze-code-graph:
117+
name: Analyze Code Graph
116118
needs: [prepare-code-to-analyze]
117119
uses: JohT/code-graph-analysis-pipeline/.github/workflows/public-analyze-code-graph.yml@7f43cf96d676f715cf278b020ce1dbb3338f900b # v2
118120
with:
@@ -122,49 +124,15 @@ jobs:
122124
ref: 7f43cf96d676f715cf278b020ce1dbb3338f900b
123125

124126

125-
analysis-results:
127+
commit-analysis-results:
128+
name: Commit Analysis Results
126129
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
130+
uses: ./.github/workflows/internal-commit-results.yml
131+
with:
132+
commit-author-name: "${{ github.event.repository.name }} Continuous Integration"
133+
commit-author-email: "[email protected]"
134+
commit-message: "Automated code structure analysis results (CI)"
135+
commit-directory: "analysis-results/${{ needs.prepare-code-to-analyze.outputs.project-name }}/${{ needs.prepare-code-to-analyze.outputs.analysis-name }}"
136+
uploaded-artifact-name: ${{ needs.analyze-code-graph.outputs.uploaded-analysis-results }}
137+
secrets:
138+
repository-commit-token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}

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

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ on:
3838

3939
jobs:
4040
prepare-code-to-analyze:
41+
name: Prepare Code to Analyze
4142
runs-on: ubuntu-latest
4243
outputs:
44+
project-name: ${{ env.PROJECT_NAME }}
4345
analysis-name: ${{ steps.set-analysis-name.outputs.analysis-name }}
4446
sources-upload-name: ${{ steps.set-sources-upload-name.outputs.sources-upload-name }}
4547

@@ -85,6 +87,7 @@ jobs:
8587

8688

8789
analyze-code-graph:
90+
name: Analyze Code Graph
8891
needs: [prepare-code-to-analyze]
8992
uses: JohT/code-graph-analysis-pipeline/.github/workflows/public-analyze-code-graph.yml@7f43cf96d676f715cf278b020ce1dbb3338f900b # v2
9093
with:
@@ -93,49 +96,15 @@ jobs:
9396
ref: 7f43cf96d676f715cf278b020ce1dbb3338f900b
9497

9598

96-
analysis-results:
99+
commit-analysis-results:
100+
name: Commit Analysis Results
97101
needs: [prepare-code-to-analyze, analyze-code-graph]
98-
runs-on: ubuntu-latest
99-
100-
env:
101-
CI_COMMIT_MESSAGE: Automated code structure analysis analysis-results (CI)
102-
CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} Continuous Integration
103-
104-
steps:
105-
- name: Checkout GIT Repository
106-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
107-
with:
108-
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
109-
110-
- name: (Code Analysis Setup) Download source code and artifacts for analysis
111-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
112-
with:
113-
name: ${{ needs.analyze-code-graph.outputs.uploaded-analysis-results }}
114-
path: analysis-results/${{ needs.prepare-code-to-analyze.outputs.analysis-name }}
115-
116-
# Commit and push the native image agent analysis-results
117-
- name: Display environment variable "github.event_name"
118-
run: echo "github.event_name=${{ github.event_name }}"
119-
- name: Display changes in the "analysis-results" directory and prepare commit
120-
# Only run when a pull request gets merged or a commit is pushed to the main branch
121-
# git add parameters need to match paths-ignore parameters above
122-
# Git pull before add/commit/push to reduce race conditions on parallel builds
123-
run: |
124-
git config --global user.name '${{ env.CI_COMMIT_AUTHOR }}'
125-
git config --global user.email "[email protected]"
126-
git config --local http.postBuffer 524288000
127-
git fetch origin
128-
git status
129-
git add analysis-results
130-
git status
131-
- name: Commit and push changes in the "analysis-results" directory
132-
# Only run when a pull request gets merged or a commit is pushed to the main branch
133-
# git add parameters need to match paths-ignore parameters above
134-
# Git pull before add/commit/push to reduce race conditions on parallel builds
135-
if: github.event_name == 'push'
136-
run: |
137-
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
138-
git status
139-
git rebase --strategy-option=theirs origin/main --verbose
140-
git status
141-
git push --verbose
102+
uses: ./.github/workflows/internal-commit-results.yml
103+
with:
104+
commit-author-name: "${{ github.event.repository.name }} Continuous Integration"
105+
commit-author-email: "[email protected]"
106+
commit-message: "Automated code structure analysis results (CI)"
107+
commit-directory: "analysis-results/${{ needs.prepare-code-to-analyze.outputs.project-name }}/${{ needs.prepare-code-to-analyze.outputs.analysis-name }}"
108+
uploaded-artifact-name: ${{ needs.analyze-code-graph.outputs.uploaded-analysis-results }}
109+
secrets:
110+
repository-commit-token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}

0 commit comments

Comments
 (0)