Skip to content

Commit

Permalink
rename pre-check to submission-validate
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Sep 19, 2024
1 parent b710b29 commit 366451a
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 39 deletions.
50 changes: 25 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ jobs:
fi
echo "insecure_skip_tls_verify=true" >> $GITHUB_OUTPUT
pre-check:
validate-submission:
name: Extract and validate PR content
runs-on: ubuntu-22.04
needs: [setup]

outputs:
pr-content-error-message: ${{ steps.pre-check.outputs.pr-content-error-message }}
owners-error-message: ${{ steps.pre-check.outputs.owners-error-message }}
pre-check-outcome: ${{ steps.pre-check.outcome }}
chart_entry_name: ${{ steps.pre-check.outputs.chart_entry_name }}
release_tag: ${{ steps.pre-check.outputs.release_tag }}
web_catalog_only: ${{ steps.pre-check.outputs.web_catalog_only }}
category: ${{ steps.pre-check.outputs.category }}
pr-content-error-message: ${{ steps.validate-submission.outputs.pr-content-error-message }}
owners-error-message: ${{ steps.validate-submission.outputs.owners-error-message }}
validate-submission-outcome: ${{ steps.validate-submission.outcome }}
chart_entry_name: ${{ steps.validate-submission.outputs.chart_entry_name }}
release_tag: ${{ steps.validate-submission.outputs.release_tag }}
web_catalog_only: ${{ steps.validate-submission.outputs.web_catalog_only }}
category: ${{ steps.validate-submission.outputs.category }}

steps:
- name: Checkout
Expand Down Expand Up @@ -143,11 +143,11 @@ jobs:
cd ..
- name: Extract PR information
id: pre-check
id: validate-submission
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
./ve1/bin/pre-check \
./ve1/bin/validate-submission \
--api_url "${{ github.event.pull_request._links.self.href }}" \
--output "$SUBMISSION_PATH" \
--repository ${{ github.repository }} \
Expand Down Expand Up @@ -188,7 +188,7 @@ jobs:
chart-verifier:
name: Run chart-verifier
runs-on: ubuntu-22.04
needs: [setup, pre-check]
needs: [setup, validate-submission]

if: ${{ always() }}

Expand Down Expand Up @@ -258,7 +258,7 @@ jobs:
skip_cache: true
chart-verifier: "${{ needs.setup.outputs.verifier-action-image }}"

# TODO: check what needs to stay here vs what could go to pre-check
# TODO: check what needs to stay here vs what could go to validate-submission
- name: determine verify requirements
if: ${{ needs.setup.outputs.run_build == 'true' && ! contains(join(needs.*.result, ','), 'failure') }}
id: verify_requires
Expand Down Expand Up @@ -352,8 +352,8 @@ jobs:
if: ${{ needs.setup.outputs.run_build == 'true' && ! contains(join(needs.*.result, ','), 'failure') }}
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
VENDOR_TYPE: ${{ needs.pre-check.outputs.category }}
WEB_CATALOG_ONLY: ${{ needs.pre-check.outputs.web_catalog_only }}
VENDOR_TYPE: ${{ needs.validate-submission.outputs.category }}
WEB_CATALOG_ONLY: ${{ needs.validate-submission.outputs.web_catalog_only }}
REPORT_GENERATED: ${{ steps.verify_requires.outputs.report_needed }}
GENERATED_REPORT_PATH: ${{ steps.run-verifier.outputs.report_file }}
REPORT_SUMMARY_PATH: ${{ steps.run-verifier.outputs.report_info_file }}
Expand Down Expand Up @@ -389,7 +389,7 @@ jobs:
# manage-gh-pr:
# name: Comment and merge PR
# runs-on: ubuntu-22.04
# needs: [setup, pre-check, chart-verifier]
# needs: [setup, validate-submission, chart-verifier]

# # outputs:
# # if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
Expand All @@ -400,13 +400,13 @@ jobs:
if: ${{ always() && needs.setup.outputs.run_build == 'true' }}
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
PR_CONTENT_ERROR_MESSAGE: ${{ needs.pre-check.outputs.pr-content-error-message }}
OWNERS_ERROR_MESSAGE: ${{ needs.pre-check.outputs.owners-error-message }}
PR_CONTENT_ERROR_MESSAGE: ${{ needs.validate-submission.outputs.pr-content-error-message }}
OWNERS_ERROR_MESSAGE: ${{ needs.validate-submission.outputs.owners-error-message }}
COMMUNITY_MANUAL_REVIEW: ${{ steps.check_report.outputs.community_manual_review_required }}
OC_INSTALL_RESULT: ${{ steps.install-oc.outcome }}
VERIFIER_ERROR_MESSAGE: ${{ steps.check-verifier-result.outputs.verifier_error_message }}
run: |
ve1/bin/pr-comment ${{ needs.pre-check.outputs.pre-check-outcome }} ${{ steps.run-verifier.outcome }} ${{ steps.check_report.conclusion }}
ve1/bin/pr-comment ${{ needs.validate-submission.outputs.validate-submission-outcome }} ${{ steps.run-verifier.outcome }} ${{ steps.check_report.conclusion }}
# Note(komish): This step is a temporary fix for the metrics step in the next job
# which expects the PR comment to exist at the specified filesystem location.
Expand Down Expand Up @@ -434,7 +434,7 @@ jobs:
});
- name: Add 'authorized-request' label to PR
if: ${{ always() && needs.pre-check.outputs.pre-check-outcome == 'success' && steps.run-verifier.outcome != 'failure' && needs.setup.outputs.run_build == 'true' }}
if: ${{ always() && needs.validate-submission.outputs.validate-submission-outcome == 'success' && steps.run-verifier.outcome != 'failure' && needs.setup.outputs.run_build == 'true' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -481,7 +481,7 @@ jobs:
release:
name: Release Chart
runs-on: ubuntu-22.04
needs: [setup, pre-check, chart-verifier]
needs: [setup, validate-submission, chart-verifier]

steps:
- name: Checkout
Expand Down Expand Up @@ -534,7 +534,7 @@ jobs:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
REPORT_CONTENT: ${{ needs.chart-verifier.outputs.report_content }}
REDHAT_TO_COMMUNITY: ${{ needs.chart-verifier.outputs.redhat_to_community }}
WEB_CATALOG_ONLY: ${{ needs.pre-check.outputs.web_catalog_only }}
WEB_CATALOG_ONLY: ${{ needs.validate-submission.outputs.web_catalog_only }}
OCP_VERSION_RANGE: ${{ steps.get-ocp-range.outputs.ocp-version-range }}
id: prepare-chart-release
run: |
Expand All @@ -549,10 +549,10 @@ jobs:
# Only the report file is always included.
# The release tag format is <organization_name>-<chart_name>-<chart_version>
- name: Create GitHub release
if: ${{ needs.pre-check.outputs.web_catalog_only == 'False' }}
if: ${{ needs.validate-submission.outputs.web_catalog_only == 'False' }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.pre-check.outputs.release_tag }}
tag_name: ${{ needs.validate-submission.outputs.release_tag }}
files: |
${{ steps.prepare-chart-release.outputs.report_file }}
${{ steps.prepare-chart-release.outputs.public_key_file }}
Expand All @@ -565,8 +565,8 @@ jobs:
- name: Update Helm repository index
if: ${{ needs.setup.outputs.run_build == 'true' }}
env:
CHART_ENTRY_NAME: ${{ needs.pre-check.outputs.chart_entry_name }}
WEB_CATALOG_ONLY: ${{ needs.pre-check.outputs.web_catalog_only }}
CHART_ENTRY_NAME: ${{ needs.validate-submission.outputs.chart_entry_name }}
WEB_CATALOG_ONLY: ${{ needs.validate-submission.outputs.web_catalog_only }}
run: |
# export WEB_CATALOG_ONLY=`jq .is_web_catalog_only ${{ github.env.SUBMISSION_PATH }}`
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Python Test
on:
pull_request:
paths:
# Only the precheck module currently provides unit tests
- 'scripts/src/precheck/*'
# Only the submission module currently provides unit tests
- 'scripts/src/submission/*'

jobs:
enforce:
Expand All @@ -26,4 +26,4 @@ jobs:
cd ..
- name: Run pytest
run: |
./ve1/bin/pytest scripts/src/precheck/
./ve1/bin/pytest scripts/src/submission/
2 changes: 1 addition & 1 deletion scripts/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ console_scripts =
chart-repo-manager = chartrepomanager.chartrepomanager:main
chart-pr-review = chartprreview.chartprreview:main
check-pr-content = checkprcontent.checkpr:main
pre-check = precheck.precheck: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
Expand Down
2 changes: 1 addition & 1 deletion scripts/src/metrics/pushowners.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def getFileContent(changed_file):
try:
owner_data = owners_file.get_owner_data_from_file(changed_file)
except owners_file.OwnersFileError as e:
print("Exception loading OWNERS file: {e}")
print(f"Exception loading OWNERS file: {e}")
return "", "", "", "", ""

users_included = owners_file.get_users_included(owner_data)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import copy
import json

from precheck import submission
from submission import submission


class SubmissionEncoder(json.JSONEncoder):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json

from precheck import serializer
from precheck import submission
from submission import serializer, submission

submission_json = """
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,13 @@ def parse_web_catalog_only(self, repo_path=""):

if not owners_web_catalog_only == report_web_catalog_only:
if owners_web_catalog_only:
raise WebCatalogOnlyError("[ERROR] The web catalog distribution method is set for the chart but is not set in the report.")
raise WebCatalogOnlyError(
"[ERROR] The web catalog distribution method is set for the chart but is not set in the report."
)
if report_web_catalog_only:
raise WebCatalogOnlyError("[ERROR] Report indicates web catalog only but the distribution method set for the chart is not web catalog only.")
raise WebCatalogOnlyError(
"[ERROR] Report indicates web catalog only but the distribution method set for the chart is not web catalog only."
)

self.is_web_catalog_only = owners_web_catalog_only

Expand Down Expand Up @@ -527,7 +531,10 @@ def is_valid_web_catalog_only(self, repo_path=""):
raise WebCatalogOnlyError(f"Failed to get report data at {report_path}")

if verifier_report.get_package_digest(report_data) is None:
return False, "[ERROR] The web catalog distribution method requires a package digest in the report."
return (
False,
"[ERROR] The web catalog distribution method requires a package digest in the report.",
)

return True, ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from dataclasses import dataclass, field

from precheck import submission
from submission import submission

# Define assets that are being reused accross tests
expected_category = "partners"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
"""
1. Pull all information related to the submitted chart from GitHub. That "comprend" the files that are added/modified by the PR, and information already present in the repo such as the ones present in the OWNERS file
2. Validate the Submission: Check that the chart/version is not already present in the helm index, validate the web_catalog_only information are correct, validate that the version is semver compatible, validate that the required files are present, ...
3. Save the submission object to a file.
"""

import argparse
import json
import sys

from precheck import submission, serializer
from submission import submission, serializer
from tools import gitutils


Expand Down Expand Up @@ -109,7 +116,7 @@ def main():
gitutils.add_output("owners-error-message", owners_error_msg)

pr_content_error_msg = ""
if args.check_chart_submission: #TODO: why ?
if args.check_chart_submission: # TODO: why ?
pr_content_error_msg = craft_pr_content_error_msg(s, args.repository)
if pr_content_error_msg:
print(pr_content_error_msg)
Expand Down

0 comments on commit 366451a

Please sign in to comment.