add git and github support in treescript
Categories
(Release Engineering :: Release Automation: Other, task)
Tracking
(Not tracked)
People
(Reporter: mtabara, Assigned: jlorenzo)
References
()
Details
Attachments
(16 files)
2.39 KB,
patch
|
Details | Diff | Splinter Review | |
1.45 KB,
patch
|
Details | Diff | Splinter Review | |
63 bytes,
text/x-github-pull-request
|
Details | Review | |
63 bytes,
text/x-github-pull-request
|
Details | Review | |
63 bytes,
text/x-github-pull-request
|
Details | Review | |
56 bytes,
text/x-github-pull-request
|
Details | |
56 bytes,
text/x-github-pull-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
63 bytes,
text/x-github-pull-request
|
Details | Review | |
50 bytes,
text/x-github-pull-request
|
Details | Review | |
63 bytes,
text/x-github-pull-request
|
Details | Review | |
63 bytes,
text/x-github-pull-request
|
Details | Review | |
63 bytes,
text/x-github-pull-request
|
Details | Review | |
63 bytes,
text/x-github-pull-request
|
Details | Review | |
63 bytes,
text/x-github-pull-request
|
Details | Review |
The goal here is to get Fenix on ship-it. For that to happen, there are two things that need to happen:
- Fenix to be able to schedule an action task that generates a graph, which creates a Github release. Other sanity checks around version found in-tree and bump the version once the release is done.
Expected Github operations:
- github push (to master if there is no branch-protection) or pull-request (if there is)
- github create release
- Bumping the version number in-tree requires manuevring git repos. For this we need to extend treescript to understand git as well.
Expected supported git operations:
- pull
- push
- tag
- count commits (used for sanity checks to compare local git commits to expected ones to be pushed in a release)
- (optional) sign commit
For git operations, we're leaning towards using subprocesses and call the underlying git
modules directly for a handful of reasons:
a) easier to update the git within the Docker images should we want to
b) more maintenance expertise within RelEng when it comes to vanilla git commands, rather than any of the APIs (https://gitpython.readthedocs.io/en/stable/)
c) (speculation) speed - using native tools is likely faster than using the Python wrapper around them, since Python runs in a single process.
Comment 1•5 years ago
|
||
https://pygithub.readthedocs.io/en/latest/index.html may be worth investigating, too. Example:
>>> repo = g.get_repo("PyGithub/PyGithub")
>>> contents = repo.get_contents("test.txt", ref="test")
>>> repo.update_file(contents.path, "more tests", "more tests", contents.sha, branch="test")
{'commit': Commit(sha="b06e05400afd6baee13fff74e38553d135dca7dc"), 'content': ContentFile(path="test.txt")}
Reporter | ||
Comment 2•5 years ago
|
||
Coordinated with Johan again on this topic to align our strategy, dropping some thoughts.
-
In the glorious future, Ship-it will replace Github releases so we won't have to rely on them anymore. That said, we can solely rely on the https://github.com/mozilla-mobile/fenix/blob/master/version.txt, similarly to what we do on gecko trees. That file shall be read by the Ship-it frontend and updated via treescript for the future Fenix releases.
-
For a while, we'll have both Github releases and Ship-it at the same time, which will probably be a bit confusing since we'll have to keep that file manually at sync. But once the migration is over, we should be good to go.
-
RelMan/Mobile go on Ship-it, they choose the revision and the version number for the Fenix release and trigger the release. Under the hood, an action task is being scheduled which schedules the release graph. Alongside them, there will be a treescript task too. Given that at the time of action-task creation we already have the version, we can already bake the
version
andnextVersion
within the version-bump's task payload.
Version bump treescript task will look something like:
task.payload: version, nextVersion
logic under the hood in treescript:
a) pull https://github.com/mozilla-mobile/fenix/,
b) adjust the version value from version
to nextVersion
c) add the files
d) commit
e) push to Github (push if ssh key, pull-request if branch protection, etc)
These is the basic backbone to begin with. We could inject some sanity checks along the way including but not limited to:
i) between a) and b) ensure the version in the payload corresponds to the one in the actual version.txt
file in the repo
ii) between d) and e) to ensure git out
(or wathever the equivalent is for hg out
) pushes only one commit and nothing more
iii) import/export the commit and inject an Autograph signing task in between
iv) etc
Reporter | ||
Comment 3•5 years ago
|
||
Note to self:
- confirmed with :hwine that we can use a bot, within a more restrictive group, that can automatically push to master. That entails:
a) generate the ssh key for that bot and keep that in SOPS
b) carefully restrict the actions possible via the Github configs and have SecOps sign-off that
Reporter | ||
Comment 4•4 years ago
|
||
Callek and myself pair-programmed on this today, with some great results:
- we have a proof-of-concept (version bump, sanity checks, github interactions, sanity checks, possible extensions) for both https://gitpython.readthedocs.io/en/stable/ and https://pygithub.readthedocs.io/en/latest/index.html
- pasting in a bit the results for both
- decision going forward is to use https://gitpython.readthedocs.io/en/stable/ for the reasons that are following in the comments
Reporter | ||
Comment 5•4 years ago
•
|
||
Pros
- straightforward to implement, we already have MVP
- can check against race-conditions because of avoiding force-pushing
- tags are easy - https://gitpython.readthedocs.io/en/stable/reference.html?highlight=push#git.repo.base.Repo.create_tag
- more clarity in operations
- possibility of adding more sanity checks because of the verbose nature of the code
- able to push via ssh-key
Cons
- PRs difficult to implement as they are not natively supported
- we need to implement sanity checks to ensure things are as expected, as opposed
to having them already there via the Github API wrapper - less guarantees for idempotency - doable but needs extra work
Reporter | ||
Comment 6•4 years ago
•
|
||
Pros
- easy to implement, we already have MVP
- can check against race-conditions because of the sha
- PRs are easy to add if we need this - https://pygithub.readthedocs.io/en/latest/examples/PullRequest.html#create-a-new-pull-request
- tags are easy - https://pygithub.readthedocs.io/en/latest/github_objects/Tag.html?highlight=tag#github.Tag.Tag
Cons
- confusing non-granular write access for the Github token or Github user
- possible rate-limit future concern https://developer.github.com/v3/#rate-limiting
- side-effects of functions are not aparent at callsite
- possible deprecation of the Github APIs in the future versions
- only one file per changeset/commit via
update_file
- harder to extend for future requests
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Comment 7•4 years ago
|
||
Un-assigning this since it's a TEAM effort.
Reporter | ||
Comment 8•4 years ago
|
||
- same treescript, but a different COT product for safety of COT
- we need to guard with scopes per branch/project since in the mobile world we can have more projects using this task, unlike gecko where we have per-level scopes
We can carve out two pieces of work here:
- treescript backbone to make room for git world
- the actual git module with operations for all of these (basically an extension of https://bugzilla.mozilla.org/attachment.cgi?id=9150567&action=edit )
Reporter | ||
Comment 9•4 years ago
|
||
Note to self: Johan pointed out that we need to bump https://github.com/mozilla-mobile/fenix/pull/12907/files#diff-e5307118f57349f9bf5d4be8b0d92aef as well when we do the version bump.
Reporter | ||
Comment 10•4 years ago
|
||
Had a chat with Johan on this today.
Places we need to touch:
- taskgraph - Fenix standalone version bump tasks + git tags since we're here
- instances - all the SOPS, cloudops-infra
- treescript git work + docker configuration + worker.yml
- ciadmin - scopes administration
Assignee | ||
Comment 11•4 years ago
|
||
Tracked in JIRA as https://jira.mozilla.com/browse/RELENG-89. Chatted with :mtabara, I'm going to handle this bug.
Assignee | ||
Comment 12•4 years ago
|
||
Assignee | ||
Comment 13•4 years ago
|
||
Assignee | ||
Comment 14•4 years ago
|
||
Reporter | ||
Comment 15•4 years ago
|
||
Assignee | ||
Comment 16•4 years ago
|
||
Assignee | ||
Comment 17•4 years ago
|
||
Comment 18•4 years ago
|
||
Assignee | ||
Comment 19•4 years ago
|
||
mozilla-version requires attrs>=19.2.0 https://github.com/mozilla-releng/mozilla-version/pull/73
Comment 20•4 years ago
|
||
Assignee | ||
Comment 21•4 years ago
|
||
Assignee | ||
Comment 22•4 years ago
|
||
Assignee | ||
Comment 23•4 years ago
|
||
Assignee | ||
Comment 24•4 years ago
|
||
Assignee | ||
Comment 25•4 years ago
|
||
Assignee | ||
Comment 26•4 years ago
|
||
Assignee | ||
Comment 27•4 years ago
|
||
Assignee | ||
Comment 28•4 years ago
|
||
This is now fixed and has been deployed to production.
2020-12-01 11:02:21,379 - git.cmd - DEBUG - Popen(['git', 'push', '--porcelain', '--set-upstream', '--verbose', 'origin', 'relbot/AC-67.0.6'], cwd=/app/workdir/src, universal_newlines=True, shell=None, istream=None)
2020-12-01 11:02:25,596 - treescript.git - INFO - Push done succesfully!
2020-12-01 11:02:25,598 - treescript.git - INFO - Resetting repo state to match upstream's...
2020-12-01 11:02:25,598 - git.cmd - DEBUG - Popen(['git', 'reset', '--hard', 'origin/relbot/AC-67.0.6', '--'], cwd=/app/workdir/src, universal_newlines=False, shell=None, istream=None)
2020-12-01 11:02:25,623 - git.cmd - DEBUG - Popen(['git', 'clean', '-fdx'], cwd=/app/workdir/src, universal_newlines=False, shell=None, istream=None)
2020-12-01 11:02:25,637 - treescript.git - INFO - Repo state reset.
2020-12-01 11:02:25,637 - treescript.script - INFO - Done!
exit code: 0
The branch was wrong, but it's because of shipit. I'm going to work on this in another bug. This means this bug is now done \o/
Comment hidden (collapsed) |
Description
•