Skip to content

Commit

Permalink
Avoid executing contracts-docs-publish parallelly
Browse files Browse the repository at this point in the history
As triggers for the `Publish contracts documentation` jobs in the workflows
generating Random Beacon and ECDSA API docs are the same (and also the
previously executed steps are very similar, it's likely that the both jobs will
start and the same or very similar time.
When that happens it's very likely that the both jobs will pull the
`auto-update-solidity-api-docs` branch at the same state and one of the jobs
will push a commit with updated docs, while the other won't be able to do that,
as the state of the branch will be different than when the pull happened.
The error we see in that case is following:
```
error: failed to push some refs to 'https://github.com/threshold-network/threshold.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
```
To avoid such situations we add a 4 minutes wait before we execute the 'Publish
contracts documentation' job in ECDSA workflow. This should be more than
enught for the Random Beacon's `Publish contracts documentation` to finish.

There is still a small change that both `Publish contracts documentation` jobs
will run at similar time (if something slows down the execution of the Random
Beacon workflow) and cause a failure of one of them, but in that unlikely
scenario, we can always rerun the failing job and it should pass on that second
run.
  • Loading branch information
michalinacienciala committed Jun 27, 2023
1 parent c7f233c commit 19e2a6a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/contracts-ecdsa-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ jobs:
commentPR: true
exportAsGHArtifacts: true

# This job is needed to avoid a clash of `contracts-docs-publish` jobs for
# `random-beacon` and `ecdsa` projects (if both are run and pull the code at
# the same time and try to push to the same branch, one of them will fail).
contracts-docs-prepublish-wait:
name: Wait for contracts docs to be published
needs: docs-detect-changes
# TODO: remove last OR
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/solidity/')) || github.ref == 'refs/pull/3534/merge'
runs-on: ubuntu-latest
steps:
- name: Wait 4 minutes
run: sleep 240

# This job will be triggered for releases which name starts with
# `refs/tags/solidity/`. It will generate contracts documentation in
# Markdown and sync it with a specific path of
Expand All @@ -57,9 +70,7 @@ jobs:
# commit pushing the changes will be verified using GPG key.
contracts-docs-publish:
name: Publish contracts documentation
needs: docs-detect-changes
# TODO: remove last OR
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/solidity/')) || github.ref == 'refs/pull/3534/merge'
needs: contracts-docs-prepublish-wait
uses: keep-network/ci/.github/workflows/reusable-solidity-docs.yml@main
with:
projectDir: /solidity/ecdsa
Expand Down

0 comments on commit 19e2a6a

Please sign in to comment.