The migratestatus tool is a maintenance utility used to safely switch a repo from one status context to another.
For example if there is a context named "CI tests" that needs to be moved by "CI tests v2" this tool can be used to copy every "CI tests" status into a "CI tests v2" status context and then mark every "CI tests" context as passing and retired. This ensures that no PRs are ever passing when they shouldn't be and doesn't block PRs that should be passing. The copy and retire phases can be run seperately or together at once in move mode.
Usage
Modes
This tool runs in one of three modes. Each mode is defined as a set of conditions on the statuses and an action to take if the conditions are met.
copy mode conditions on PRs that have the context to copy, but not the destination context. For each of these PRs, the 'copy' context's status is copied to the destination context.
retire mode can be used to retire an old context with or without replacement. By setting the context's state to "success" the retired context can be ignored.
With a replacement specified, the mode conditions on PRs that have the context to retire and the context that replaced the retired context. For each of these PRs, the context to retire has its state set to "success" and its description set to a message of the form "Context retired. Status moved to 'CI tests v2'.".
Without a replacement specified, the mode conditions on PRs that have the context to retire. For each of these PRs, the context has its state set to "success" and its description set to "Context retired without replacement."
move mode conditions on PRs that have the context to move, but not the destination context. For each of these PRs, a copy and retire action are performed. In other words, the status of the context to move is copied to the 'dest' context and then retired with 'dest' as the replacement.
The migratestatus binary is run locally and can be built by running go build from this directory. The binary accepts the following parameters:
--tokenfile The file containing the github authentication token to use.
--org The organization that owns the repository to migrate contexts in. (Kubernetes)
--repo The repository to migrate contexts in.
Exactly one of the following flags must appear. Each indicates a mode and specifies a context:
--copy The context to copy.
--retire The context to retire.
--move The context to move (copy and retire).
--dest The destination context. This is the context that is copied to and/or the context that replaces the retired context. This flag may only be omitted if retire mode is specified and the old context is being retired without a replacement.
The binary also accepts the following optional parameters:
--dry-run A bool indicating whether or not modifying actions should be disabled. Defaults to true.
--continue-on-error A bool indicating whether or not the migration should continue if context migration fails for an individual PR. Defaults to false.
--alsologtostderr A flag that sends logs to stderr in addition to temporary log files.