Skip to content

Add a script to upload reports to GitHub#124

Open
rhcu wants to merge 5 commits intomozilla:masterfrom
rhcu:github_script
Open

Add a script to upload reports to GitHub#124
rhcu wants to merge 5 commits intomozilla:masterfrom
rhcu:github_script

Conversation

@rhcu
Copy link
Copy Markdown
Collaborator

@rhcu rhcu commented Aug 3, 2018

Fixes #122
Need to add Taskcluster secrets and to clean up the code. WIll add this later.

@marco-c
Copy link
Copy Markdown
Collaborator

marco-c commented Aug 3, 2018

The Taskcluster secrets part should be in mozilla-releng/services, as we have code there to load the secrets.
The module here could have parameters git_user_name and git_password that we pass from the caller.

@rhcu rhcu changed the title WIP: Add a script to upload reports to GitHub Add a script to upload reports to GitHub Aug 3, 2018
subprocess.run(['git', 'clone', 'https://github.com/coverage-crawler-updater/coverage-crawler-reports'])
os.chdir('coverage-crawler-reports')

# Remove the content of repository except of README
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the README too, the repository will only be accessed from https://rhcu.github.io/coverage-crawler-reports/, so the README is unneeded.

def upload_to_github(report_path, git_user_name, git_password):
# Clone the repository if doesn't exist
if not os.path.isdir('coverage-crawler-reports'):
subprocess.run(['git', 'clone', 'https://github.com/coverage-crawler-updater/coverage-crawler-reports'])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can clone the rhcu repository directly.

@rhcu rhcu changed the title Add a script to upload reports to GitHub WIP: Add a script to upload reports to GitHub Aug 6, 2018
@rhcu
Copy link
Copy Markdown
Collaborator Author

rhcu commented Aug 7, 2018

https://rhcu.github.io/coverage-crawler-reports/ The index.html will look like this.

@rhcu rhcu changed the title WIP: Add a script to upload reports to GitHub Add a script to upload reports to GitHub Aug 7, 2018
@marco-c
Copy link
Copy Markdown
Collaborator

marco-c commented Aug 20, 2018

https://rhcu.github.io/coverage-crawler-reports/ The index.html will look like this.

Looks great!

shutil.rmtree(f)
elif f.startswith('.') is False:
os.remove(f)
subprocess.run(['git', 'pull', 'https://github.com/rhcu/coverage-crawler-reports', 'master'])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of cloning and pulling, we can do like we do here: https://github.com/mozilla/release-services/blob/master/src/shipit_code_coverage/shipit_code_coverage/github.py#L74 and just always overwrite the contents of the repository.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So basically:

  1. create a coverage-crawler-reports directory;
  2. chdir to ^;
  3. run the crawler;
  4. create the index file;
  5. your current code from git init to the end.

You won't even need to move the reports this way, as they are created directly in the right directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants