Skip to content

Commit

Permalink
ci: add deployment workflows for eigen environment eployments MGX-878 (
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszaaa authored Feb 7, 2024
2 parents 0d8587a + 133f406 commit 01f6e9c
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 18 deletions.
137 changes: 137 additions & 0 deletions .github/workflows/branch-eth-rollup-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: eth-rollup-develop branch workflow

on:
push:
branches: [eth-rollup-develop]
pull_request:
types: [ labeled, opened, synchronize, unlabeled, closed ]
branches: [eth-rollup-develop]

workflow_dispatch:
# For manually trigger
inputs:
e2eBranch:
description: "Name of the e2e target branch"
required: false
default: "main"
parachainDocker:
description: "Name of the parachain docker reference"
required: false
default: "mangatasolutions/mangata-node:latest"

permissions:
contents: write
id-token: write
deployments: write
checks: write

# The following concurrency group cancels in-progress jobs or runs on pull_request events only
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
init:
name: Global init
runs-on: ubuntu-latest
if: github.event.action != 'unlabeled' && github.event.action != 'closed'
outputs:
GLOBAL_VERSION: ${{ steps.set_vars.outputs.GLOBAL_VERSION }}
GIT_BRANCH: ${{ steps.set_vars.outputs.GIT_BRANCH }}
GIT_BRANCH_UNFORMATTED: ${{ steps.branch-name.outputs.current_branch }}
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6
- name: Set global version
id: set_vars
run: |
echo "GLOBAL_VERSION=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "GIT_BRANCH=${{ steps.branch-name.outputs.current_branch }}" | sed "s@/@-@g" >> $GITHUB_OUTPUT
build-and-test:
needs: [init]
name: Build
uses: ./.github/workflows/reusable-build-and-test.yml
secrets: inherit
with:
version: ${{ needs.init.outputs.GLOBAL_VERSION }}
branch: ${{ needs.init.outputs.GIT_BRANCH }}

deploy-fungible:
name: Deploy fungible environment
needs: [init, build-and-test]
if: |
(github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == ':rocket: deploy') ||
(github.event_name == 'pull_request' && github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, ':rocket: deploy'))
uses: ./.github/workflows/reusable-deploy.yml
secrets: inherit
with:
env: fungible
version: ${{ needs.init.outputs.GLOBAL_VERSION }}
cluster_name: mangata-dev-alpha

clean-up-fungible:
name: Delete fungible environment
if: |
(github.event_name == 'pull_request' && github.event.action == 'unlabeled' && github.event.label.name == ':rocket: deploy') ||
(github.event_name == 'pull_request' && github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, ':rocket: deploy'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v1
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up GKE credentials
uses: google-github-actions/[email protected]
with:
cluster_name: mangata-dev-alpha
location: europe-west1

- name: Delete Kubernetes namespace with resources for fungible environment
run: kubectl delete namespace pr-${{ github.event.number }}

- name: Delete GitHub Deployment environment
if: always()
uses: bobheadxi/[email protected]
with:
step: delete-env
token: ${{ secrets.GITHUB_TOKEN }}
env: pr-${{ github.event.number }}

generate-types:
name: Generate types
needs: [ init, build-and-test ]
uses: ./.github/workflows/reusable-generate-types.yml
secrets: inherit
with:
branch: ${{ needs.init.outputs.GIT_BRANCH_UNFORMATTED }}
parachainDocker: ${{ github.event.inputs.parachainDocker }}
globalVersion: ${{ needs.init.outputs.GLOBAL_VERSION }}

run-e2e-test:
name: Run e2e tests
needs: [init, build-and-test, generate-types]
uses: ./.github/workflows/reusable-e2e-tests.yml
secrets: inherit
permissions:
contents: write
id-token: write
deployments: write
checks: write
with:
e2eBranch: ${{ github.event.inputs.e2eBranch }}
parachainDocker: ${{ github.event.inputs.parachainDocker }}
skipBuild: 'false'
globalVersion: ${{ needs.init.outputs.GLOBAL_VERSION }}

deploy-eigen-mococo:
name: Deploy to eigen-mococo on merge to `eth-rollup-develop` branch
needs: [init, build-and-test]
if: startsWith(github.head_ref, 'eth-rollup-develop')
uses: ./.github/workflows/reusable-deploy-eigen-mococo.yml
secrets: inherit
with:
version: ${{ needs.init.outputs.GLOBAL_VERSION }}
20 changes: 10 additions & 10 deletions .github/workflows/reusable-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ permissions:
jobs:
build-node-image:
name: Build Docker image
runs-on: [compile]
runs-on: [compile-gke]
container:
image: ${{ inputs.builder_image }}
# env:
# DOCKER_HOST: "unix:///run/docker/docker.sock"
# volumes:
# - /run/docker:/run/docker
env:
DOCKER_HOST: "unix:///run/docker/docker.sock"
volumes:
- /run/docker:/run/docker
steps:
- uses: actions/checkout@v3
- name: Authenticate to Google Cloud
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:

unit-test:
name: Unit tests
runs-on: [compile]
runs-on: [compile-gke]
container:
image: ${{ inputs.builder_image }}
steps:
Expand Down Expand Up @@ -178,7 +178,7 @@ jobs:

coverage-report:
name: Coverage report
runs-on: [compile]
runs-on: [compile-gke]
container:
image: ${{ inputs.builder_image }}
options: --security-opt seccomp=unconfined
Expand Down Expand Up @@ -243,7 +243,7 @@ jobs:

build-and-run-try-runtime:
name: Run try-runtime checks
runs-on: [compile]
runs-on: [compile-gke]
container:
image: ${{ inputs.builder_image }}
steps:
Expand Down Expand Up @@ -280,7 +280,7 @@ jobs:
run-benchmarks:
name: Run runtime benchmarks
# `performance` self-hosted runners have 8 cores and 16GB of RAM
runs-on: [compile]
runs-on: [performance-gke]
env:
STEPS: 2
REPEATS: 1
Expand Down Expand Up @@ -346,7 +346,7 @@ jobs:

build-wasms:
name: Export wasm artifacts
runs-on: [compile]
runs-on: [compile-gke]
env:
STEPS: 2
REPEATS: 1
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/reusable-deploy-eigen-mococo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Deploy mangata-node to `eigen-mococo`

on:
workflow_dispatch:
inputs:
version:
description: "Version to be used for deployment"
required: true
type: string
workflow_call:
inputs:
version:
description: "Version to be used for deployment"
required: true
type: string

concurrency: eigen-mococo-environment

jobs:
deploy-eigen-mococo:
runs-on: ubuntu-latest
environment: eigen-mococo
env:
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
steps:
- name: Verify specified version exists
run: docker pull mangatasolutions/mangata-node:${{ inputs.version }}

- name: Checkout `mangata-finance/gitops` repository
uses: actions/checkout@v4
with:
repository: mangata-finance/gitops
# TODO: Has to be changed to main once everything will be checked
ref: feat/deploy-eigen-layer-collators-env-MGX-878
# ref: main
token: ${{ secrets.BOT_GITHUB_TOKEN }}

- name: Push updated version to `gitops` repository
id: version
run: |
echo -n '${{ inputs.version }}' > helmfiles/eigen-mococo/.version
git config user.name mangatafinance
git config user.email [email protected]
git add .
git commit -m 'chore: deploy ${{ inputs.version }} to eigen-mococo environment' || \
echo "changed=false" >> $GITHUB_OUTPUT
git push
- name: Watch deployment workflow run
run: |
# Rerun previous workflow if version didn't change
[ -n '${{ steps.version.outputs.changed }}' ] && gh run rerun $(gh run list -w deploy-eigen-mococo.yml -L1 --json databaseId --jq '.[].databaseId')
sleep 5 && gh run list -L10 -w deploy-eigen-mococo.yml
export RUN_ID=$(gh run list -w deploy-eigen-mococo.yml -L1 --json databaseId --jq '.[].databaseId')
if [[ ($(gh run view "$RUN_ID" --json headSha --jq '.headSha') != $(git rev-parse HEAD)) && -z '${{ steps.version.outputs.changed }}' ]]; then
echo "Commited git SHA doesn't match with the SHA of the retrieved Run ID"
exit 1
fi
echo "Deployed version: ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "Deployment workflow URL: $(gh run view "$RUN_ID" --json url --jq '.url')" >> $GITHUB_STEP_SUMMARY
gh run watch "$RUN_ID" --exit-status
6 changes: 1 addition & 5 deletions .github/workflows/reusable-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
- command: "yarn test-parallel-3rdPartyRewards"
fast: true

runs-on: [compile]
runs-on: [e2e-gke]
timeout-minutes: 180
env:
API_URL: "ws://127.0.0.1:9946"
Expand Down Expand Up @@ -288,10 +288,6 @@ jobs:
run: |
docker kill $(docker ps -q) 2>/dev/null && echo $?
docker-compose down -v
- name: Fix permissions on self-hosted runner
if: always()
run: chown -R 1100:1100 $GITHUB_WORKSPACE
test-complete:
needs: [setup-report, e2e-test-matrix]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-perfomance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
performance-tests:
# Allows to keep e2e tests jobs running even if performance-tests fail
continue-on-error: true
runs-on: [compile]
runs-on: [compile-gke]
timeout-minutes: 180
env:
ENV_REF: ${{ inputs.targetEnv || format('pr-{0}', github.event.number) }}
Expand Down
5 changes: 3 additions & 2 deletions pallets/sequencer-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ impl<T: Config> EnsureOrigin<<T as frame_system::Config>::RuntimeOrigin>

#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<T::RuntimeOrigin, ()> {
let founder = Founder::<T>::get().ok_or(())?;
Ok(T::RuntimeOrigin::from(frame_system::RawOrigin::Signed(founder)))
unimplemented!();
// let founder = Founder::<T>::get().ok_or(())?;
// Ok(T::RuntimeOrigin::from(frame_system::RawOrigin::Signed(founder)))
}
}

0 comments on commit 01f6e9c

Please sign in to comment.