Trying other way

This commit is contained in:
alesapin 2021-09-15 12:02:38 +03:00
parent 2e3fad449a
commit ebdd63aeca
2 changed files with 23 additions and 19 deletions

View File

@ -7,7 +7,7 @@ on:
branches: branches:
- master - master
jobs: jobs:
Explore-GitHub-Actions: Style Check:
runs-on: [self-hosted] runs-on: [self-hosted]
steps: steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
@ -18,26 +18,15 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner." - run: echo "🖥️ The workflow is now ready to test your code on the runner."
#- name: Style Check - name: Style Check
# env: env:
# YANDEX_S3_ACCESS_KEY_ID: ${{ secrets.YANDEX_S3_ACCESS_KEY_ID }} YANDEX_S3_ACCESS_KEY_ID: ${{ secrets.YANDEX_S3_ACCESS_KEY_ID }}
# YANDEX_S3_ACCESS_SECRET_KEY: ${{ secrets.YANDEX_S3_ACCESS_SECRET_KEY }} YANDEX_S3_ACCESS_SECRET_KEY: ${{ secrets.YANDEX_S3_ACCESS_SECRET_KEY }}
# run: cd $GITHUB_WORKSPACE/tests/ci && python3 style_check.py GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cd $GITHUB_WORKSPACE/tests/ci && python3 style_check.py
- name: List files in the repository - name: List files in the repository
run: | run: |
ls ${{ github.workspace }} ls ${{ github.workspace }}
ls $RUNNER_TEMP ls $RUNNER_TEMP
- run: ls -la $RUNNER_TEMP - run: ls -la $RUNNER_TEMP
- run: echo "🍏 This job's status is ${{ job.status }}." - run: echo "🍏 This job's status is ${{ job.status }}."
- name: "Trying to update check link"
run: |
curl --request PATCH --url https://api.github.com/repos/${{ github.repository }}/check-runs/${{ github.job }} \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
-d '{"name" : "hello-world-name"}'
- name: "Trying to update check link"
run: |
curl --request PATCH --url https://api.github.com/repos/${{ github.repository }}/check-runs/${{ github.action }} \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
-d '{"name" : "hello-world-name"}'

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from github import Github
from report import create_test_html_report from report import create_test_html_report
import shutil import shutil
import logging import logging
@ -7,6 +8,8 @@ import os
import csv import csv
from s3_helper import S3Helper from s3_helper import S3Helper
NAME = "Style Check"
def process_logs(s3_client, additional_logs, s3_path_prefix): def process_logs(s3_client, additional_logs, s3_path_prefix):
additional_urls = [] additional_urls = []
@ -71,6 +74,7 @@ def upload_results(s3_client, pr_number, commit_sha, state, description, test_re
url = s3_client.upload_test_report_to_s3('report.html', s3_path_prefix + ".html") url = s3_client.upload_test_report_to_s3('report.html', s3_path_prefix + ".html")
logging.info("Search result in url %s", url) logging.info("Search result in url %s", url)
return url
def get_pr_url_from_ref(ref): def get_pr_url_from_ref(ref):
@ -79,6 +83,12 @@ def get_pr_url_from_ref(ref):
except: except:
return "master" return "master"
def get_check(gh, commit_sha):
repo = gh.get_repo(os.getenv("GITHUB_REPOSITORY", "ClickHouse/ClickHouse"))
commit = repo.get_commit(commit_sha)
check = list(commit.get_check_runs(NAME))[0]
return check
if __name__ == "__main__": if __name__ == "__main__":
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
repo_path = os.getenv("GITHUB_WORKSPACE", os.path.abspath("../../")) repo_path = os.getenv("GITHUB_WORKSPACE", os.path.abspath("../../"))
@ -89,6 +99,10 @@ if __name__ == "__main__":
aws_secret_key_id = os.getenv("YANDEX_S3_ACCESS_KEY_ID", "") aws_secret_key_id = os.getenv("YANDEX_S3_ACCESS_KEY_ID", "")
aws_secret_key = os.getenv("YANDEX_S3_ACCESS_SECRET_KEY", "") aws_secret_key = os.getenv("YANDEX_S3_ACCESS_SECRET_KEY", "")
gh = Github(os.getenv("GITHUB_TOKEN"))
check = get_check(gh, commit_sha)
check.edit(name="Test style check")
docker_image_version = os.getenv("DOCKER_IMAGE_VERSION", "latest") docker_image_version = os.getenv("DOCKER_IMAGE_VERSION", "latest")
if not aws_secret_key_id or not aws_secret_key: if not aws_secret_key_id or not aws_secret_key:
logging.info("No secrets, will not upload anything to S3") logging.info("No secrets, will not upload anything to S3")
@ -104,4 +118,5 @@ if __name__ == "__main__":
subprocess.check_output(f"docker run --cap-add=SYS_PTRACE --volume={repo_path}:/ClickHouse --volume={temp_path}:/test_output clickhouse/style-test:{docker_image_version}", shell=True) subprocess.check_output(f"docker run --cap-add=SYS_PTRACE --volume={repo_path}:/ClickHouse --volume={temp_path}:/test_output clickhouse/style-test:{docker_image_version}", shell=True)
state, description, test_results, additional_files = process_result(temp_path) state, description, test_results, additional_files = process_result(temp_path)
upload_results(s3_helper, get_pr_url_from_ref(ref), commit_sha, state, description, test_results, additional_files) report_url = upload_results(s3_helper, get_pr_url_from_ref(ref), commit_sha, state, description, test_results, additional_files)
check.edit(details_url=report_url)