-
Notifications
You must be signed in to change notification settings - Fork 2
130 lines (119 loc) · 4.89 KB
/
pre-merge.yml
File metadata and controls
130 lines (119 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
---
# SPDX-FileCopyrightText: (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
name: Pre-Merge CI Pipeline
on:
pull_request:
branches:
- main
- release-*
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: {}
jobs:
pre-checks:
permissions:
contents: read
runs-on: ubuntu-latest
outputs:
filtered_projects: ${{ steps.filter-changes.outputs.filtered_projects }}
other_changed_projects: ${{ steps.filter-changes.outputs.other_changed_projects }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: "Verify Branch Name"
uses: open-edge-platform/orch-ci/verify-branch-name@628dd6e7fd94a3e765e389b5bb43d90fbe3de421 # 0.1.32
- name: "Discover Changed Subfolders"
id: discover-changes
uses: open-edge-platform/orch-ci/discover-changed-subfolders@628dd6e7fd94a3e765e389b5bb43d90fbe3de421 # 0.1.32
- name: "Filter Out Unwanted Changed Subfolders"
id: filter-changes
env:
changed_projects: ${{ steps.discover-changes.outputs.changed_projects }}
run: |
folders_to_remove='[".github",".reuse","LICENSES",".git", "tests", "samples"]'
filtered_projects=$(echo "$changed_projects" | jq -cr --argjson folders_to_remove "$folders_to_remove" 'map(select(. as $item | $folders_to_remove | index($item) | not))')
other_changed_projects=$(echo "$changed_projects" | jq -cr --argjson filtered_projects "$filtered_projects" 'map(select(. as $item | $filtered_projects | index($item) | not))')
echo "filtered_projects=$filtered_projects" >> $GITHUB_OUTPUT
echo "other_changed_projects=$other_changed_projects" >> $GITHUB_OUTPUT
pre-merge-root:
permissions:
contents: read
needs: pre-checks
if: ${{ contains(needs.pre-checks.outputs.other_changed_projects, '.github') || contains(needs.pre-checks.outputs.other_changed_projects, 'LICENSES') || contains(needs.pre-checks.outputs.other_changed_projects, '""')}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '18'
- run: |
npm install -g \
"markdownlint-cli@${{ env.MARKDOWNLINT_CLI_VER }}"
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
id: setup_python
with:
python-version: '3.13'
- name: Restore cached virtualenv
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}
path: venv_infra
- name: Run mdlint
run: make mdlint
- name: Run license check
run: make license
pre-merge-pipeline:
permissions:
contents: read
needs: pre-checks
if: ${{ needs.pre-checks.outputs.filtered_projects != '[]' }}
strategy:
fail-fast: false
matrix:
project_folder: ${{ fromJson(needs.pre-checks.outputs.filtered_projects) }}
uses: open-edge-platform/orch-ci/.github/workflows/pre-merge.yml@628dd6e7fd94a3e765e389b5bb43d90fbe3de421 # 0.1.32
with:
run_security_scans: true
run_version_check: false
run_build: true
run_lint: true
run_test: true
run_docker_build: true
run_docker_push: true
run_helm_build: true
run_helm_push: true
run_artifact: false
project_folder: ${{ matrix.project_folder }}
version_suffix: "-pr-${{ github.event.number }}"
secrets: inherit
final-check:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [pre-merge-root, pre-merge-pipeline]
steps:
- name: Final Status Check
env:
pre_merge_pipeline: ${{ needs.pre-merge-pipeline.result }}
pre_merge_root_pipeline: ${{ needs.pre-merge-root.result }}
run: |
results=("pre_merge_root_pipeline" "pre_merge_pipeline")
status="OK"
for result in "${results[@]}"; do
pipeline_result=$(eval echo \$$result)
echo "${result} result: $pipeline_result"
if [[ "$pipeline_result" != "success" && "$pipeline_result" != "skipped" ]]; then
status="KO"
fi
done
if [[ "$status" == "OK" ]]; then
echo "Pre-merge check passed successfully."
else
echo "All pre-merge checks failed or were skipped. PR can't get merged"
exit 1
fi