Skip to content

Commit

Permalink
A0-3467: Unify featurenet creation (#1520)
Browse files Browse the repository at this point in the history
# Description

This PR introduced completely new refactored featurenets which has the
following important changes:
* merged two separate `create-from-branch` and `create-from-net`
workflows into one
* simplified inputs where you can enter either 'mainnet', 'testnet' or
any git reference (such as tag, commit hash or branch)
* simplified logic - the image is always built, no more nasty 'if'
conditions everywhere
* reduced code, and more of the steps pushed further to actions in
`github-actions` (and these guys got refactored and simplified as well)

## Type of change

- Breaking change to featurenets, however, nothing worrying as of this
moment there are no important featurenets running

# Checklist:

- I have added tests
- I have marked the documentation as out-of-date - we'll deal with it
ASAP after the merge

---------

Co-authored-by: Marcin <[email protected]>
  • Loading branch information
mikogs and Marcin-Radecki authored Dec 4, 2023
1 parent 2386c00 commit 9940089
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@
name: Build and push PR image to featurenets
on:
workflow_call:

inputs:
ref:
description: "git ref: hash, branch, tag or 'mainnet' or 'testnet'"
type: string
required: true
outputs:
image-tag:
description: Tag of pushed docker image
value: ${{ jobs.main.outputs.image-tag }}
jobs:
main:
name: Build and push image
runs-on: ubuntu-20.04
outputs:
image-tag: ${{ steps.push-image.outputs.image-tag }}
steps:
- name: Checkout aleph-node
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
fetch-depth: 0

- name: Call action get-ref-properties
id: get-ref-properties
Expand Down Expand Up @@ -43,8 +56,10 @@ jobs:
password: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }}

- name: Push image to the featurenet registry
id: push-image
env:
# yamllint disable-line rule:line-length
IMAGE_TAG: fe-${{ steps.get-ref-properties.outputs.branch-name-for-argo-with-sha }}
run: |
docker push '${{ vars.ECR_PUBLIC_REGISTRY }}feature-env-aleph-node:${{ env.IMAGE_TAG }}'
echo 'image-tag=${{ env.IMAGE_TAG }}' >> $GITHUB_OUTPUT
13 changes: 8 additions & 5 deletions .github/workflows/_build-test-node-and-runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
name: Build test node and runtime
on:
workflow_call:
inputs:
ref:
description: "git ref: hash, branch, tag or 'mainnet' or 'testnet'"
type: string
required: true

jobs:
main:
Expand All @@ -15,11 +20,9 @@ jobs:
steps:
- name: Checkout aleph-node source code
uses: actions/checkout@v4

- name: Call action get-ref-properties
id: get-ref-properties
# yamllint disable-line rule:line-length
uses: Cardinal-Cryptography/github-actions/get-ref-properties@v4
with:
ref: ${{ inputs.ref }}
fetch-depth: 0

- name: Install Rust toolchain
uses: Cardinal-Cryptography/github-actions/install-rust-toolchain@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_check-vars-and-secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
-z '${{ secrets.AUTOCOMMIT_EMAIL }}' || \
-z '${{ secrets.CI_DEVNET_S3BUCKET_NAME }}' || \
-z '${{ secrets.CI_MAINNET_S3BUCKET_NAME }}' || \
-z '${{ secrets.CI_GH_USER }}' || \
-z '${{ secrets.CI_GH_TOKEN }}' || \
-z '${{ secrets.CI_S3BUCKET_NAME }}' || \
-z '${{ secrets.DEVNET_KEYS_S3BUCKET_NAME }}' || \
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/_run-button-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
needs: [check-vars-and-secrets]
name: Build test node and runtime
uses: ./.github/workflows/_build-test-node-and-runtime.yml
with:
ref: ${{ github.ref }}

store-test-node-and-runtime:
name: Store test node and runtime in Devnet bucket
Expand Down
84 changes: 0 additions & 84 deletions .github/workflows/featurenet-create-from-net.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: FE - Create from branch
name: FE - Create

on:
workflow_dispatch:
Expand All @@ -8,6 +8,10 @@ on:
description: 'Name of featurenet'
type: string
required: true
ref:
description: "git ref: hash, branch, tag - or 'mainnet' or 'testnet'"
type: string
required: true
expiration:
description: 'Time after which featurenet will be removed'
required: true
Expand Down Expand Up @@ -36,6 +40,10 @@ on:
description: 'Name of featurenet'
type: string
required: true
ref:
description: "git ref: hash, branch, tag - or 'mainnet' or 'testnet'"
type: string
required: true
expiration:
description: 'Time after which featurenet will be removed'
required: false
Expand All @@ -61,13 +69,14 @@ jobs:
shell: bash
# yamllint disable rule:line-length
run: |
if [[
! '${{ inputs.featurenet-name }}' =~ ^[a-z0-9][a-z0-9\-]{4,48}$
]]
then
if [[ ! '${{ inputs.featurenet-name }}' =~ ^[a-z0-9][a-z0-9\-]{4,48}$ ]]; then
echo '!!! Invalid featurenet name'
exit 1
fi
if [[ ! '${{ inputs.ref }}' =~ ^[a-zA-Z0-9][a-zA-Z0-9\._\-]{1,48}$ ]]; then
echo "!!! Invalid ref"
exit 1
fi
# yamllint enable rule:line-length

check-vars-and-secrets:
Expand All @@ -77,41 +86,51 @@ jobs:
secrets: inherit

build-test-node-and-runtime:
if: ${{ inputs.ref != 'mainnet' && inputs.ref != 'testnet' }}
name: Build test node and runtime
needs: [check-vars-and-secrets]
uses: ./.github/workflows/_build-test-node-and-runtime.yml
with:
ref: ${{ inputs.ref }}
secrets: inherit

store-test-node-and-runtime:
name: Store test node and runtime in Devnet bucket
runs-on: ubuntu-20.04
push-featurenet-test-node-image-to-ecr:
if: ${{ inputs.ref != 'mainnet' && inputs.ref != 'testnet' }}
needs: [build-test-node-and-runtime]
steps:
- name: Checkout aleph-node source code
uses: actions/checkout@v4

- name: Store test node and runtime
uses: ./.github/actions/store-node-and-runtime
with:
profile: test
aws-access-key-id: ${{ secrets.AWS_DEVNET_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_DEVNET_SECRET_ACCESS_KEY }}
aws-bucket: ${{ secrets.CI_DEVNET_S3BUCKET_NAME }}
name: Build and push PR test docker image to ECR
uses: ./.github/workflows/_build-and-push-test-image-to-featurenets.yml
with:
ref: ${{ inputs.ref }}
secrets: inherit

push-featurnet-node-image-to-ecr:
needs: [store-test-node-and-runtime]
name: Build and push PR tesdocker image to ECR
uses: ./.github/workflows/_build-and-push-pull-request-image-to-featurenets.yml
create-featurenet-from-branch:
if: ${{ inputs.ref != 'mainnet' && inputs.ref != 'testnet' }}
needs: [push-featurenet-test-node-image-to-ecr]
name: Create featurenet from branch
# yamllint disable-line rule:line-length
uses: Cardinal-Cryptography/github-actions/.github/workflows/_featurenet-create.yml@v5
secrets: inherit
with:
expiration: ${{ inputs.expiration }}
replicas: ${{ inputs.replicas }}
internal: ${{ inputs.internal && true || false }}
featurenet-name: ${{ inputs.featurenet-name }}
aleph-node-image: ${{ needs.push-featurenet-test-node-image-to-ecr.outputs.image-tag }}
featurenet-ecr-repo: true
delete-first: true

create-featurenet:
needs: [push-featurnet-node-image-to-ecr]
name: Create featurenet based on the PR
create-featurenet-from-net:
if: ${{ inputs.ref == 'mainnet' || inputs.ref == 'testnet' }}
needs: [check-vars-and-secrets]
name: Create featurenet from net
# yamllint disable-line rule:line-length
uses: Cardinal-Cryptography/github-actions/.github/workflows/_featurenet-create-from-branch.yml@v4
uses: Cardinal-Cryptography/github-actions/.github/workflows/_featurenet-create.yml@v5
secrets: inherit
with:
expiration: ${{ inputs.expiration }}
replicas: ${{ inputs.replicas }}
internal: ${{ inputs.internal && true || false }}
featurenet-name: ${{ inputs.featurenet-name }}
aleph-node-image: ${{ inputs.ref }}
featurenet-ecr-repo: false
delete-first: true
2 changes: 1 addition & 1 deletion .github/workflows/featurenet-delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
needs: [check-vars-and-secrets]
name: Delete featurenet
# yamllint disable-line rule:line-length
uses: Cardinal-Cryptography/github-actions/.github/workflows/_featurenet-delete.yml@v4
uses: Cardinal-Cryptography/github-actions/.github/workflows/_featurenet-delete.yml@v5
secrets: inherit
with:
featurenet-name: ${{ inputs.featurenet-name }}
Loading

0 comments on commit 9940089

Please sign in to comment.