From 7945bc334c421f2a2c13f3862ff31ff47bb1d02e Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Wed, 1 May 2019 16:40:35 -0700 Subject: [PATCH 1/2] remove html coverage report from the pipeline, devops automatically generates this content --- .azure-pipelines/client.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.azure-pipelines/client.yml b/.azure-pipelines/client.yml index 141ce45022ef..3fd24a5fa3b9 100644 --- a/.azure-pipelines/client.yml +++ b/.azure-pipelines/client.yml @@ -160,7 +160,6 @@ jobs: - script: | coverage xml - coverage html displayName: 'Generate Coverage XML' - script: | @@ -168,17 +167,11 @@ jobs: displayName: 'Publish Code Cov' condition: ne(variables['codecov-python-repository-token'], '') - - task: PythonScript@0 - displayName: 'Inline CSS for Cobertura' - inputs: - scriptPath: 'scripts/devops_tasks/inline_css_for_cobertura.py' - - task: PublishCodeCoverageResults@1 displayName: 'Publish Code Coverage to DevOps' inputs: codeCoverageTool: Cobertura summaryFileLocation: '$(Build.SourcesDirectory)/coverage.xml' - reportDirectory: '$(Build.SourcesDirectory)/htmlcov' - job: Test_Alpha_Python From d3233abf41a9ca6dba4cca2ed19775459e8fc6ba Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Fri, 3 May 2019 15:05:11 -0700 Subject: [PATCH 2/2] remove inline_css_for_cobertura.py --- .../devops_tasks/inline_css_for_cobertura.py | 77 ------------------- 1 file changed, 77 deletions(-) delete mode 100644 scripts/devops_tasks/inline_css_for_cobertura.py diff --git a/scripts/devops_tasks/inline_css_for_cobertura.py b/scripts/devops_tasks/inline_css_for_cobertura.py deleted file mode 100644 index 2bb8537ba404..000000000000 --- a/scripts/devops_tasks/inline_css_for_cobertura.py +++ /dev/null @@ -1,77 +0,0 @@ -from __future__ import print_function -import os -import bs4 -import io -import sys -import shutil - -COVERAGE_REPORT_DIR = 'htmlcov/' -COVERAGE_REPORT = os.path.join(COVERAGE_REPORT_DIR, 'index.html') - -def __str_version_handler(string): - if sys.version_info >= (3, 0): - return str(string) - else: - return unicode(string) - -def embed_css_in_html_file(html_file, css_dir): - with io.open(html_file, 'r', encoding='utf-8') as f: - soup = bs4.BeautifulSoup(f.read(), "html.parser") - - stylesheets = soup.findAll("link", {"rel": "stylesheet"}) - for sheet in stylesheets: - - # insert a new style tag where the old linkrel tag was - tag = soup.new_tag('style') - tag['type'] = 'text/css' - - # grab the href to the CSS file and read it all - css_file = sheet["href"] - with open(os.path.join(css_dir, css_file), 'r') as f: - c = bs4.element.NavigableString(f.read()) - - # insert the contents of the stylesheet into the style tag we just created - tag.insert(0, c) - - # then replace the sheet tag with the data from the stylesheet - sheet.replaceWith(tag) - - with io.open(html_file, 'w', encoding='utf-8') as f: - f.write(__str_version_handler(soup)) - -def clean_index(html_file): - with io.open(html_file, 'r', encoding='utf-8') as f: - soup = bs4.BeautifulSoup(f.read(), "html.parser") - - # remove all links to the files that don't exist anymore - for a in soup.findAll('a'): - a.replaceWithChildren() - - # embedded CSS corrupts the sort indicator image. Javascript doesn't work in the devops display anyway. Removing the class - module_title = soup.find('th', class_='headerSortDown')["class"].remove('headerSortDown') - - # remove input filter - input_filter = soup.find(id= 'filter') - input_filter.decompose() - - # remove keyboard icon - keyboard_icon = soup.find(id='keyboard_icon') - keyboard_icon.decompose() - - # write final results - with io.open(html_file, 'w', encoding='utf-8') as f: - f.write(__str_version_handler(soup)) - -if __name__ == '__main__': - for file in os.listdir(COVERAGE_REPORT_DIR): - name, ext = os.path.splitext(os.path.basename(file.lower())) - if ext == ".html": - if name == "index": - print("Cleaning index in {}".format(file)) - clean_index(os.path.join(COVERAGE_REPORT_DIR, file)) - print("Embedding CSS in {}".format(file)) - embed_css_in_html_file(os.path.join(COVERAGE_REPORT_DIR, file), COVERAGE_REPORT_DIR) - else: - os.remove(os.path.join(COVERAGE_REPORT_DIR, file)) - -