Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 5 additions & 15 deletions .github/workflows/check-locks-on-owners-submission.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ jobs:
console.log(`setting output: net-new-owners-file=${ownersFile.status == 'added'}`);
core.setOutput('net-new-owners-file', ownersFile.status == 'added');

- name: Add category/organization/chart-name from modified file to GITHUB_OUTPUT
id: gather-metadata
env:
API_URL: ${{ github.event.pull_request._links.self.href }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
./ve1/bin/extract-metadata-from-pr \
--emit-to-github-output \
"${API_URL}"

# Only used to assert content of the OWNERS file.
- name: Checkout Pull Request
uses: actions/checkout@v4
Expand All @@ -94,8 +84,8 @@ jobs:
id: fact-check
env:
PR_FILES: ${{ steps.check_for_owners.outputs.pr_files }}
CHART_NAME: ${{ steps.gather-metadata.outputs.chart-name }}
ORGANIZATION: ${{ steps.gather-metadata.outputs.organization }}
CHART_NAME: ${{ steps.check_for_owners.outputs.chart-name }}
ORGANIZATION: ${{ steps.check_for_owners.outputs.organization }}
run: |
file=$(yq .0 <<< ${PR_FILES})
owner_contents_chart_name=$(yq '.chart.name' ${file})
Expand Down Expand Up @@ -125,7 +115,7 @@ jobs:
id: determine-lock-status
uses: ./.github/actions/check-chart-locks
with:
chart-name: ${{ steps.gather-metadata.outputs.chart-name }}
chart-name: ${{ steps.check_for_owners.outputs.chart-name }}
fail-workflow-if-locked: 'false'

- name: Comment on PR if chart is locked
Expand All @@ -143,7 +133,7 @@ jobs:

| chart name | lock path |
| - | - |
| ${{ steps.gather-metadata.outputs.chart-name }} | ${{ steps.determine-lock-status.outputs.locked-to-path }} |
| ${{ steps.check_for_owners.outputs.chart-name }} | ${{ steps.determine-lock-status.outputs.locked-to-path }} |

This OWNERS file is being ${{ steps.populate-file-mod-type.outputs.net-new-owners-file == 'true' && '**created**' || '**modified**'}} in this pull request.

Expand All @@ -162,7 +152,7 @@ jobs:

The OWNERS file contributed here has a chart name that is **AVAILABLE**!

The chart name '${{ steps.gather-metadata.outputs.chart-name }}' does not appear in our lockfile.
The chart name '${{ steps.check_for_owners.outputs.chart-name }}' does not appear in our lockfile.

After reviewing this pull request, please re-run this workflow once more before merging.

Expand Down
16 changes: 3 additions & 13 deletions .github/workflows/mercury_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ jobs:
console.log(`setting output: net-new-owners-file=${ownersFile.status == 'added'}`);
core.setOutput('net-new-owners-file', ownersFile.status == 'added');

- name: Add category/organization/chart-name from modified file to GITHUB_OUTPUT
id: gather-metadata
env:
API_URL: ${{ github.event.pull_request._links.self.href }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
./ve1/bin/extract-metadata-from-pr \
--emit-to-github-output \
"${API_URL}"

# Only used to assert content of the OWNERS file.
- name: Checkout Pull Request
uses: actions/checkout@v4
Expand All @@ -91,8 +81,8 @@ jobs:
id: fact-check
env:
PR_FILES: ${{ steps.check_for_owners.outputs.pr_files }}
CHART_NAME: ${{ steps.gather-metadata.outputs.chart-name }}
ORGANIZATION: ${{ steps.gather-metadata.outputs.organization }}
CHART_NAME: ${{ steps.check_for_owners.outputs.chart-name }}
ORGANIZATION: ${{ steps.check_for_owners.outputs.organization }}
run: |
file=$(yq .0 <<< ${PR_FILES})
owner_contents_chart_name=$(yq '.chart.name' ${file})
Expand Down Expand Up @@ -122,7 +112,7 @@ jobs:
id: determine-lock-status
uses: ./.github/actions/check-chart-locks
with:
chart-name: ${{ steps.gather-metadata.outputs.chart-name }}
chart-name: ${{ steps.check_for_owners.outputs.chart-name }}
fail-workflow-if-locked: 'false'

# Do not merge net-new OWNERS files for locked chart names. Allow a
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/owners-redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
working-directory: scripts
run: |
make venv.tools

- name: Gather Metadata
id: gather-metadata
env:
Expand Down
1 change: 0 additions & 1 deletion scripts/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ console_scripts =
chart-repo-manager = chartrepomanager.chartrepomanager:main
chart-pr-review = chartprreview.chartprreview:main
validate-submission = submission.validate:main
pr-artifact = pullrequest.prartifact:main
pr-comment = pullrequest.prepare_pr_comment:main
sa-for-chart-testing = saforcharttesting.saforcharttesting:main
check-auto-merge = checkautomerge.checkautomerge:main
Expand Down
4 changes: 4 additions & 0 deletions scripts/src/pullrequest/check_for_owners.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def main():
)
sys.exit(30)

gitutils.add_output("category", s.chart.category)
gitutils.add_output("organization", s.chart.organization)
gitutils.add_output("chart-name", s.chart.name)


if __name__ == "__main__":
main()
60 changes: 0 additions & 60 deletions scripts/src/pullrequest/prartifact.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
import argparse
import os
import sys

import requests

sys.path.append("../")
from reporegex import matchers
from tools import gitutils

pr_files = []
pr_labels = []
xRateLimit = "X-RateLimit-Limit"
xRateRemain = "X-RateLimit-Remaining"


# TODO(baijum): Move this code under chartsubmission.chart module
def get_modified_charts(api_url):
files = get_modified_files(api_url)
pattern, _, _ = matchers.get_file_match_compiled_patterns()
for file in files:
match = pattern.match(file)
if match:
category, organization, chart, version = match.groups()
return category, organization, chart, version

return "", "", "", ""


def get_modified_files(api_url):
"""Populates and returns the list of files modified by this the PR

Expand Down Expand Up @@ -91,44 +72,3 @@ def get_labels(api_url):
pr_labels.append(label["name"])

return pr_labels


def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"-d",
"--directory",
dest="directory",
type=str,
required=False,
help="artifact directory for archival",
)
parser.add_argument(
"-n",
"--pr-number",
dest="number",
type=str,
required=False,
help="current pull request number",
)
parser.add_argument(
"-u",
"--api-url",
dest="api_url",
type=str,
required=True,
help="API URL for the pull request",
)
parser.add_argument(
"-f", "--get-files", dest="get_files", default=False, action="store_true"
)

args = parser.parse_args()
if args.get_files:
pr_files = get_modified_files(args.api_url)
print(f"[INFO] files in pr: {pr_files}")
gitutils.add_output("pr_files", pr_files)


if __name__ == "__main__":
main()