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

ADF - Downstream check #9958

Open
wants to merge 62 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
2bff148
Boilerplate to trigger and wait external workflow
mauriziovitale Jul 17, 2024
2864879
Simulate major change
mauriziovitale Jul 17, 2024
8e5d9b9
Speed up workflow
mauriziovitale Jul 17, 2024
ea4d6cd
set status
mauriziovitale Jul 17, 2024
33094d3
Target fix branch and link adf
mauriziovitale Jul 17, 2024
e56add6
Simulate breaking change
mauriziovitale Jul 17, 2024
857157b
Simulate breaking change 2
mauriziovitale Jul 17, 2024
ec62de3
Simulate breaking change 3
mauriziovitale Jul 17, 2024
ad3ced0
Simulate breaking change 4
mauriziovitale Jul 17, 2024
9f9e31d
Simulate breaking change 5
mauriziovitale Jul 17, 2024
2cbd466
Simulate breaking change 6
mauriziovitale Jul 17, 2024
6f67261
Simulate breaking change 7
mauriziovitale Jul 18, 2024
d3c2e03
Simulate breaking change 8
mauriziovitale Jul 18, 2024
7939643
Simulate breaking change 9
mauriziovitale Jul 18, 2024
1d3a15c
Simulate breaking change 8
mauriziovitale Jul 18, 2024
ce0b429
Pass use local adf
mauriziovitale Jul 18, 2024
01e5933
Simulate breaking change 9
mauriziovitale Jul 18, 2024
d8c277d
Simulate breaking change 10
mauriziovitale Jul 18, 2024
04b5611
Use local adf branch as input
mauriziovitale Jul 18, 2024
f107b6e
Use local adf branch as input fix
mauriziovitale Jul 18, 2024
73a4bc3
Simulate breaking change 11
mauriziovitale Jul 18, 2024
c1926fb
Simulate breaking change 12
mauriziovitale Jul 18, 2024
bf8d559
Simulate breaking change 13
mauriziovitale Jul 18, 2024
f7ad618
Simulate breaking change 14
mauriziovitale Jul 18, 2024
2883b6e
Simulate breaking change 14
mauriziovitale Jul 18, 2024
c957239
Simulate breaking change 15
mauriziovitale Jul 18, 2024
2d9c6b8
Simulate breaking change 16
mauriziovitale Jul 18, 2024
9115bf0
Simulate breaking change 17
mauriziovitale Jul 19, 2024
d776c0c
Simulate breaking change 17
mauriziovitale Jul 19, 2024
b5d3b80
Simulate breaking change 18
mauriziovitale Jul 19, 2024
c230d48
Simulate breaking change 19
mauriziovitale Jul 19, 2024
f8981a4
Simulate breaking change 20
mauriziovitale Jul 19, 2024
d87e3bc
Simulate breaking change 20
mauriziovitale Jul 19, 2024
d8fc788
Simulate breaking change 20
mauriziovitale Jul 19, 2024
13670d2
Simulate breaking change 20
mauriziovitale Jul 19, 2024
683c0fd
Simulate breaking change 20
mauriziovitale Jul 19, 2024
f3d30ef
Simulate breaking change 20
mauriziovitale Jul 19, 2024
9f93d30
Fix branch name
mauriziovitale Jul 19, 2024
9803dcc
Create an action for determine the complexity
mauriziovitale Jul 19, 2024
ace533c
Create an action for determine the complexity
mauriziovitale Jul 19, 2024
275ba33
Create an action for determine the complexity
mauriziovitale Jul 19, 2024
eded939
Export level
mauriziovitale Jul 19, 2024
0d50846
Change params
mauriziovitale Jul 19, 2024
cab5d21
Rely on limit
mauriziovitale Jul 19, 2024
16c79cd
Rely on limit fix
mauriziovitale Jul 19, 2024
6d76497
Rely on limit fix 2
mauriziovitale Jul 19, 2024
d556b8b
Rely on limit fix 4
mauriziovitale Jul 19, 2024
fca6f0d
Remove change on core
mauriziovitale Jul 19, 2024
3839a73
Remove change on core
mauriziovitale Jul 19, 2024
80b44de
Remove change on core
mauriziovitale Jul 19, 2024
daf8c68
Remove change on core
mauriziovitale Jul 19, 2024
cd08a54
Remove change on core
mauriziovitale Jul 19, 2024
db66db6
Remove change on core 2
mauriziovitale Jul 19, 2024
5c5e825
Remove change on core 3
mauriziovitale Jul 19, 2024
9df84cc
Check new algoritm
mauriziovitale Jul 19, 2024
94193a0
Handle js-api
mauriziovitale Jul 23, 2024
cbc3454
Revert test
mauriziovitale Jul 23, 2024
a7df807
Revert test
mauriziovitale Jul 23, 2024
53c8c35
Revert simulation
mauriziovitale Jul 23, 2024
d484201
Revert simulation
mauriziovitale Jul 23, 2024
fadb0bf
Use slack channel
mauriziovitale Jul 23, 2024
baa3dce
Start with a limit
mauriziovitale Jul 23, 2024
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
35 changes: 35 additions & 0 deletions .github/actions/determine-complexity/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Determine Complexity
description: 'Determine the complexity of the PR'

inputs:
file-changed-limit:
description: 'The limit of files changed in the PR to throw a major complexity'
required: true
type: number
lines-changed-limit:
description: 'The limit of lines changed in the PR to throw a major complexity'
required: true
type: number

runs:
using: "composite"

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Determine complexity
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
fileChangedLimit: ${{ inputs.file-changed-limit }}
lineChangedLimit: ${{ inputs.lines-changed-limit }}
with:
script: |
const determineComplexity = require('./.github/actions/determine-complexity/determine-pr-complexity.js');

determineComplexity({
core,
github,
context,
fileChangedLimit: process.env.fileChangedLimit,
linesChangedLimit: process.env.lineChangedLimit
});

74 changes: 74 additions & 0 deletions .github/actions/determine-complexity/determine-pr-complexity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

function determineComplexity(changedFiles, totalFilesChanged, totalLinesChanged, limitFileChanged, limitLinesChanged) {
let level = 'unknown';
let packagesAffected = new Set();

// Determine packagesAffected and if the level should be major based on file paths
for (let filePath of changedFiles) {
if (filePath.startsWith('lib/core/') || filePath.startsWith('lib/extensions/') || filePath.startsWith('lib/js-api/')) {
level = 'major';
packagesAffected.add(filePath.split('/')[2]);
}
}

// Check if the number of files or lines changed exceeds limits
if (totalFilesChanged > limitFileChanged || totalLinesChanged > limitLinesChanged) {
level = 'major';
}

return {
filesChanged: totalFilesChanged,
linesChanged: totalLinesChanged,
level: level,
packagesAffected: Array.from(packagesAffected) // Convert Set to Array for the output
};
}

async function getPRDetails(github, core, owner, repo, pull_number, limitFileChanged, limitLinesChanged) {
const { data: files } = await github.rest.pulls.listFiles({
owner,
repo,
pull_number
});

const result = determineComplexity(
files.map((file) => file.filename),
files.length,
files.reduce((total, file) => total + file.additions + file.deletions, 0),
limitFileChanged,
limitLinesChanged
);

return result;
}

module.exports = async ({ core, github, context, fileChangedLimit = 5, linesChangedLimit = 50 }) => {
const owner = context.repo.owner;
const repo = context.repo.repo;
const pull_number = context.payload.pull_request.number;

core.info(`Getting PR details for ${owner}/${repo}#${pull_number}`);
core.info(`Limit for files changed: ${fileChangedLimit}`);
core.info(`Limit for lines changed: ${linesChangedLimit}`);

const details = await getPRDetails(github, core, owner, repo, pull_number, fileChangedLimit, linesChangedLimit);

core.info(`PR details: ${JSON.stringify(details)}`);
core.setOutput('level', details.level);
};
46 changes: 44 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ jobs:
fetch-depth: 0

- name: Get branch name
uses: Alfresco/alfresco-build-tools/.github/actions/get-branch-name@76affd16a4dd9a440cf66bf42656b1d826e8dfc2 # v5.34.0

uses: Alfresco/alfresco-build-tools/.github/actions/get-branch-name@a288b9efdaa50413573b2e130896d906478b8e50 # v5.31.0
- name: Save commit message
uses: Alfresco/alfresco-build-tools/.github/actions/get-commit-message@76affd16a4dd9a440cf66bf42656b1d826e8dfc2 # v5.34.0

Expand Down Expand Up @@ -492,6 +491,49 @@ jobs:
echo "result ${{ toJson(steps.pr-forbidden.*.result) }}" && echo "result ${{ steps.pr-forbidden.*.result }}"
echo "result ${{ contains(toJson(steps.pr-forbidden.*.result), 'failure') }}"

determine-complexity:
needs: check-if-pr-is-approved
outputs:
level: ${{ steps.complexity.outputs.level }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1
- name: Determine complexity
uses: ./.github/actions/determine-complexity
with:
file-changed-limit: 10
lines-changed-limit: 400

verify-downstream:
needs: determine-complexity
if: ${{ needs.determine-complexity.outputs.level == 'major' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1
- uses: Alfresco/alfresco-build-tools/.github/actions/get-branch-name@a288b9efdaa50413573b2e130896d906478b8e50 # v5.31.0
- name: Tests - HxP Frontend
uses: the-actions-org/workflow-dispatch@3133c5d135c7dbe4be4f9793872b6ef331b53bc7 # v4.0.0
with:
repo: Alfresco/hxp-frontend-apps
ref: fix/AAE-24001-check-adf
workflow: acceptance-tests.yml
inputs: >
{
"environment": "apaRc",
"use-local-adf": "${{ env.BRANCH_NAME }}",
"notify-on-failure": true,
"rp-trigger": "adf-to-hxp-test",
"slack-channel-id": "C016SMNNL8L",
"slack-message-title": "ADF => HxP check\n🔴 Frontend e2e test failed on branch ${{ env.BRANCH_NAME }}"
}
token: ${{ secrets.ALFRESCO_BUILD_GH_TOKEN }}
wait-for-completion: true
finalize:
if: ${{ always() }}
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@
"@cspell/eslint-plugin": "^7.3.6",
"@mat-datetimepicker/core": "11.0.3",
"@ngx-translate/core": "^14.0.0",
"@storybook/core-server": "^8.1.10",
"@storybook/theming": "^8.1.10",
"@storybook/core-server": "^7.6.5",
"angular-oauth2-oidc": "^13.0.1",
"angular-oauth2-oidc-jwks": "^17.0.2",
"apollo-angular": "^5.0.2",
Expand Down
Loading