From 19e2a6ac256a3597ed23914cb6f5aaa284651624 Mon Sep 17 00:00:00 2001 From: Michalina Date: Tue, 27 Jun 2023 11:07:41 +0200 Subject: [PATCH] Avoid executing `contracts-docs-publish` parallelly 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. --- .github/workflows/contracts-ecdsa-docs.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/contracts-ecdsa-docs.yml b/.github/workflows/contracts-ecdsa-docs.yml index ce2ed8c7bd..7a57721733 100644 --- a/.github/workflows/contracts-ecdsa-docs.yml +++ b/.github/workflows/contracts-ecdsa-docs.yml @@ -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 @@ -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