-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract updating featurenet to separate action and workflow
- Loading branch information
Showing
4 changed files
with
231 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
--- | ||
name: FE - Create | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
featurenet-name: | ||
description: 'Name of the featurenet' | ||
required: true | ||
type: string | ||
aleph-node-image: | ||
description: "FQDN of aleph-node image" | ||
required: true | ||
type: string | ||
rolling-update-partition: | ||
description: | | ||
Number from 0 to N-1, where N is size of am existing featurenet. | ||
All aleph-node-validator-N with an ordinal N that is great than or equal to the partition | ||
will be updated. If not specified, all nodes will be updated. | ||
required: false | ||
default: '0' | ||
type: string | ||
outputs: | ||
ws-hostname: | ||
description: Hostname of the WS endpoint | ||
value: ${{ jobs.create-featurenet.outputs.ws-hostname }} | ||
|
||
jobs: | ||
validate-inputs: | ||
name: Validate inputs | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Validate inputs | ||
shell: bash | ||
# yamllint disable rule:line-length | ||
run: | | ||
if [[ ! '${{ inputs.featurenet-name }}' =~ ^[a-z0-9][a-z0-9\-]{4,48}$ ]] | ||
then | ||
echo '!!! Invalid featurenet name' | ||
exit 1 | ||
fi | ||
if [[ ! '${{ inputs.aleph-node-image }}' =~ ^[a-z0-9][a-z0-9\._:/\-]{1,52}$ ]]; then | ||
echo "!!! Invalid aleph-node image" | ||
exit 1 | ||
fi | ||
# yamllint enable rule:line-length | ||
|
||
check-vars-and-secrets: | ||
needs: [validate-inputs] | ||
name: Check vars and secrets | ||
uses: ./.github/workflows/_check-vars-and-secrets.yml | ||
secrets: inherit | ||
|
||
create-featurenet: | ||
needs: [check-vars-and-secrets] | ||
name: Create featurenet | ||
runs-on: [self-hosted, Linux, X64, small] | ||
outputs: | ||
deployment-id: ${{ steps.deployment.outputs.deployment_id }} | ||
ws-hostname: ${{ steps.create-featurenet.outputs.ws-hostname }} | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Start featurenet Deployment | ||
uses: bobheadxi/[email protected] | ||
id: deployment | ||
with: | ||
step: start | ||
token: ${{ secrets.CI_GH_TOKEN }} | ||
env: ${{ inputs.featurenet-name }} | ||
override: true | ||
debug: true | ||
|
||
- name: Update featurenet with image tag | ||
uses: Cardinal-Cryptography/github-actions/update-featurenet@A0-3761-tweak-naming-for-more-clarity | ||
id: create-featurenet | ||
with: | ||
gh-ci-user: ${{ secrets.CI_GH_USER }} | ||
gh-ci-token: ${{ secrets.CI_GH_TOKEN }} | ||
argo-sync-user-token: ${{ secrets.ARGO_SYNC_USER_TOKEN }} | ||
repo-featurenet-template-name: ${{ secrets.REPO_FEATURENET_TEMPLATE_NAME }} | ||
featurenet-name: ${{ inputs.featurenet-name }} | ||
featurenet-aleph-node-image: ${{ inputs.aleph-node-image }} | ||
rolling-update-partition: ${{ inputs.rolling-update-partition }} | ||
git-commit-author: ${{ secrets.AUTOCOMMIT_AUTHOR }} | ||
git-commit-email: ${{ secrets.AUTOCOMMIT_EMAIL }} | ||
wait-for-finalized-heads: "true" | ||
|
||
- name: Finish featurenet Deployment | ||
uses: bobheadxi/deployments@v1 | ||
if: always() | ||
with: | ||
step: finish | ||
token: ${{ secrets.CI_GH_TOKEN }} | ||
status: ${{ job.status }} | ||
env: ${{ inputs.featurenet-name }} | ||
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | ||
# yamllint disable-line rule:line-length | ||
env_url: https://dev.azero.dev/?rpc=wss%3A%2F%2F${{ steps.create-featurenet.outputs.ws-hostname }}#/explorer | ||
debug: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
--- | ||
name: Create featurenet | ||
description: | | ||
This action is used in several dev flows to | ||
* spawn new featurenet from any aleph node git ref, | ||
* update binary in the existing featurenet, | ||
* update rolling partition in the existing featurenet, | ||
inputs: | ||
gh-ci-user: | ||
description: 'GH user to be used in the action' | ||
required: true | ||
gh-ci-token: | ||
description: 'GH token to be used in the action' | ||
required: true | ||
repo-featurenet-template-name: | ||
description: 'Name of the repository containing featurenet template' | ||
required: true | ||
argo-sync-user-token: | ||
description: 'ArgoCD user token to be used in the action' | ||
required: true | ||
featurenet-name: | ||
description: 'Name of featurenet' | ||
required: true | ||
git-commit-author: | ||
description: 'Git commit author when pushing to featurenets repository' | ||
required: true | ||
git-commit-email: | ||
description: 'Git commit email when pushing to featurenets repository' | ||
required: true | ||
featurenet-aleph-node-image: | ||
description: 'aleph-node docker image tag' | ||
required: true | ||
default: '' | ||
rolling-update-partition: | ||
description: | | ||
Number from 0 to N-1, where N is size of am existing featurenet. | ||
All aleph-node-validator-N with an ordinal N that is great than or equal to the partition | ||
will be updated. If not specified, all nodes will be updated. | ||
required: false | ||
default: "0" | ||
wait-for-finalized-heads: | ||
description: 'Wait for heads finalization' | ||
required: false | ||
default: "false" | ||
outputs: | ||
ws-hostname: | ||
description: Hostname of the WS endpoint | ||
value: ${{ steps.start-featurenet.outputs.ws-hostname }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Validate inputs | ||
shell: bash | ||
run: | | ||
if [[ | ||
! '${{ inputs.featurenet-name }}' =~ ^[a-z0-9][a-z0-9\-]{4,48}$ | ||
]] | ||
then | ||
echo "!!! Invalid featurenet name" | ||
exit 1 | ||
fi | ||
if [[ | ||
! '${{ inputs.featurenet-aleph-node-image }}' =~ ^[a-z0-9][a-z0-9\._/:\-]{1,52}$ | ||
]] | ||
then | ||
echo "!!! Invalid featurenet node image tag" | ||
exit 1 | ||
fi | ||
if [[ | ||
'${{ inputs.rolling-update-partition }}' != "" && \ | ||
! '${{ inputs.rolling-update-partition }}' =~ ^[0-9]$ | ||
]] | ||
then | ||
echo "!!! Expected rolling update partition to be a cardinal value from 0 to 9" | ||
exit 1 | ||
fi | ||
- name: Checkout featurenet template repo | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: Cardinal-Cryptography/${{ inputs.repo-featurenet-template-name }} | ||
token: ${{ inputs.gh-ci-token }} | ||
path: "${{ inputs.repo-featurenet-template-name }}" | ||
ref: A0-3761-tweak-naming-for-more-clarity | ||
|
||
- name: Start featurenet | ||
id: start-featurenet | ||
shell: bash | ||
env: | ||
GITHUB_USERNAME: ${{ inputs.gh-ci-user }} | ||
GITHUB_TOKEN: ${{ inputs.gh-ci-token }} | ||
GIT_COMMIT_USER_NAME: ${{ inputs.git-commit-author }} | ||
GIT_COMMIT_USER_EMAIL: ${{ inputs.git-commit-email }} | ||
# yamllint disable rule:line-length | ||
run: | | ||
cd '${{ inputs.repo-featurenet-template-name }}' | ||
./upsert-featurenet.sh \ | ||
'${{ inputs.featurenet-name }}' \ | ||
'${{ inputs.featurenet-aleph-node-image }}' \ | ||
'not-used-because-update' \ | ||
'${{ inputs.rolling-update-partition }}' \ | ||
'not-used-because-update' \ | ||
'not-used-because-update' \ | ||
-u \ | ||
-c -g | tee -a tmp-opssh-updatefeaturenet-output.txt | ||
ws_hostname=$(cat tmp-opssh-updatefeaturenet-output.txt | grep '^__output:ws-hostname:' | cut -d: -f3) | ||
echo "ws-hostname=${ws_hostname}" >> $GITHUB_OUTPUT | ||
# yamllint enable rule:line-length | ||
|
||
- name: Refresh Argo and wait for the creation to be finished | ||
shell: bash | ||
run: | | ||
cd '${{ inputs.repo-featurenet-template-name }}' | ||
./refresh-featurenets.sh '${{ inputs.argo-sync-user-token }}' '${{ inputs.featurenet-name }}' | ||
- name: Wait for the unique consecutive finalized heads | ||
if: inputs.wait-for-finalized-heads == 'true' | ||
shell: bash | ||
run: | | ||
cd '${{ inputs.repo-featurenet-template-name }}' | ||
./wait-for-featurenet-finalized-heads.sh '${{ inputs.featurenet-name }}' |