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

feat: Trigger warning job on pr test #2223

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e84d05f
Add GH workflow for detecting changes under config directory
medmes Jan 30, 2025
38d368a
Enhance the workflow for checking manifests changes as well.
medmes Jan 30, 2025
fe9a0bc
Test the workflow
medmes Jan 30, 2025
4bab3ad
Test the workflow- pull request target
medmes Jan 30, 2025
974263a
Add permission token.
medmes Jan 30, 2025
c124fd3
Change to pull_request_target
medmes Jan 30, 2025
ec56411
remove pull_request_target types
medmes Jan 30, 2025
57b6fa3
changed to PR to test on upstream
medmes Jan 30, 2025
fc47bf8
remove envs after testing
medmes Jan 30, 2025
baa1e06
Rename Job name
medmes Jan 30, 2025
c25021a
Changes on the CRD part.
medmes Jan 30, 2025
6d15458
Fail and comment
medmes Jan 30, 2025
3d01f0c
Revert "Fail and comment"
medmes Jan 30, 2025
1608059
Add fail condition on PR comment
medmes Jan 30, 2025
9742436
Add fail condition on PR comment
medmes Jan 30, 2025
d3c0d9e
Add fail condition on PR comment
medmes Jan 30, 2025
e1b8293
revert back and keep only Github Actions Workflow yaml file.
medmes Jan 30, 2025
45a38c8
revert back and keep only Github Actions Workflow yaml file.
medmes Jan 30, 2025
e60f1d9
Merge branch 'main' into trigger_warning_job_on_pr
medmes Jan 31, 2025
a836812
Draft Commit
medmes Jan 31, 2025
b0e45ae
Merge remote-tracking branch 'origin/trigger_warning_job_on_pr' into …
medmes Jan 31, 2025
a00d234
Merge branch 'main' into trigger_warning_job_on_pr
medmes Jan 31, 2025
dd2146d
Splitted jobs and added the possibility to remove label if the manife…
medmes Feb 3, 2025
f77d9ce
Merge branch 'main' into trigger_warning_job_on_pr
medmes Feb 3, 2025
6dc46d6
Merge branch 'main' of github.com:medmes/lifecycle-manager into trigg…
medmes Feb 3, 2025
4adb7df
Merge remote-tracking branch 'origin/trigger_warning_job_on_pr' into …
medmes Feb 3, 2025
4120aac
rename workflow name
medmes Feb 3, 2025
033c5af
changed into $GITHUB_OUTPUT instead of using env vars: $GITHUB_ENV
medmes Feb 3, 2025
e19d8bc
Refactoring
medmes Feb 3, 2025
d981bc5
Refactoring
medmes Feb 3, 2025
acf9f86
Refactoring
medmes Feb 3, 2025
6f621d3
Merge branch 'main' into trigger_warning_job_on_pr
medmes Feb 10, 2025
706b5f2
chenged Implementation
medmes Feb 11, 2025
49c7164
Merge branch 'main' into trigger_warning_job_on_pr
medmes Feb 11, 2025
1ea5123
Include others in .github/
medmes Feb 11, 2025
16bfbbb
-
medmes Feb 11, 2025
306739d
Cosmetic changes
medmes Feb 12, 2025
2dedfce
Merge branch 'main' into trigger_warning_job_on_pr
medmes Feb 12, 2025
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
123 changes: 123 additions & 0 deletions .github/workflows/check-manifests-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: "Check If Manifests Change"

env:
PR_CACHE_KEY: pr-manifests-${{ github.run_id }}-${{ github.run_attempt }}
MAIN_CACHE_KEY: main-manifests-${{ github.run_id }}-${{ github.run_attempt }}

on:
pull_request:

jobs:
create-pr-manifests:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v4

- name: Create manifests on PR branch
run: |
make dry-run-control-plane
mkdir -p ./cache/pr
mv ./dry-run/manifests.yaml ./cache/pr/manifests.yaml

- name: Save PR manifests in cache
uses: actions/cache@v3
with:
path: ./cache/pr/
key: ${{ env.PR_CACHE_KEY }}

create-main-manifests:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main

- name: Create manifests on main branch
run: |
make dry-run-control-plane
mkdir -p ./cache/main
mv ./dry-run/manifests.yaml ./cache/main/manifests.yaml

- name: Save main manifests in cache
uses: actions/cache@v3
with:
path: ./cache/main/
key: ${{ env.MAIN_CACHE_KEY }}

diff-manifests:
needs:
- create-pr-manifests
- create-main-manifests
runs-on: ubuntu-latest
steps:
- name: Restore PR manifests from cache
uses: actions/cache@v3
with:
path: ./cache/pr/
key: ${{ env.PR_CACHE_KEY }}

- name: Restore main manifests from cache
uses: actions/cache@v3
with:
path: ./cache/main/
key: ${{ env.MAIN_CACHE_KEY }}

- name: Compare Manifests
id: compare-manifests
run: |
set +e
DIFF_OUTPUT=$(diff ./cache/pr/manifests.yaml ./cache/main/manifests.yaml)
EXIT_CODE=$?
if [[ $EXIT_CODE != 0 ]]; then
echo "❌ Detected differences in manifest outputs!"
echo "$DIFF_OUTPUT"
echo "manifests_diff_detected=true" >> $GITHUB_OUTPUT
else
echo "✅ No differences in manifest outputs detected."
echo "manifests_diff_detected=false" >> $GITHUB_OUTPUT
fi
exit 0

- name: Add PR Comment if Manifest Differences Detected
if: steps.compare-manifests.outputs.manifests_diff_detected == 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: "❌ **Manifests created with 'make dry-run-control-plane' changed!** Please make sure to check if changes are needed in related repositories like management-plane-charts, runtime-watchter, etc.."
});
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ["manifests-diff"]
});

- name: Remove 'manifests-diff' Label if No Differences
if: steps.compare-manifests.outputs.manifests_diff_detected == 'false'
uses: actions/github-script@v7
with:
script: |
const labelName = 'manifests-diff';
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});
if (labels.some(label => label.name === labelName)) {
console.log(`Label "${labelName}" found, removing it.`);
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
name: labelName,
});
} else {
console.log(`Label "${labelName}" not found, skipping removal.`);
}

86 changes: 86 additions & 0 deletions .github/workflows/check-pipeline-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: "Check Pipeline Changes"

on:
pull_request:

jobs:
check-pipeline-changes:
runs-on: ubuntu-latest
steps:
- name: Get list of changed files
id: changed-files
uses: actions/github-script@v7
with:
script: |
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
// Define the pipeline-related paths to watch
const pathsToCheck = [
".github/workflows/test-e2e.yml",
".github/workflows/test-e2e-with-modulereleasemeta.yml",
".github/scripts",
"scripts/tests",
"versions.yaml",
];

const pipelineFiles = files.filter(file =>
pathsToCheck.some(path => file.filename === path || file.filename.startsWith(path + '/'))
);
core.setOutput('pipelineFiles', pipelineFiles.map(file => file.filename).join(','));

- name: Evaluate Pipeline Changes
id: eval-changes
run: |
echo "Changed pipeline-related files:"
echo "${{ steps.changed-files.outputs.pipelineFiles }}" | tr ',' '\n'
if [ -n "${{ steps.changed-files.outputs.pipelineFiles }}" ]; then
echo "⚠️ Pipeline-related changes detected!"
echo "pipeline_changed=true" >> $GITHUB_OUTPUT
else
echo "✅ No pipeline-related changes detected."
echo "pipeline_changed=false" >> $GITHUB_OUTPUT
fi

- name: Add PR Comment & Label if Pipeline Changes Detected
if: steps.eval-changes.outputs.pipeline_changed == 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: "⚠️ **Pipeline-related file changes detected!** Please review if related updates (e.g. manifest generation or workflow adjustments) are required."
});
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ["pipeline-changed"]
});

- name: Remove 'pipeline-changed' Label if No Changes Detected
if: steps.eval-changes.outputs.pipeline_changed == 'false'
uses: actions/github-script@v7
with:
script: |
const labelName = 'pipeline-changed';
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});
if (labels.some(label => label.name === labelName)) {
console.log(`Label "${labelName}" found, removing it.`);
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
name: labelName,
});
} else {
console.log(`Label "${labelName}" not found, skipping removal.`);
}
Loading