Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Princeprince559 authored Dec 2, 2024
0 parents commit f728931
Show file tree
Hide file tree
Showing 588 changed files with 255,922 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/target
target
!target/release/aleph-node
!target/production/aleph-node
!bin/cliain/target/release/cliain

22 changes: 22 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

## Type of change

Please delete options that are not relevant.

- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing functionality to not work as expected)

# Checklist:

<!-- delete when not applicable to your PR -->

- I have added tests
- I have made neccessary updates to the Infrastructure
- I have made corresponding changes to the existing documentation
- I have created new documentation
- I have bumped `spec_version` and `transaction_version`
- I have bumped aleph-client version if relevant
16 changes: 16 additions & 0 deletions .github/actions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
This directory gathers useful actions for Github pipelines.

---

## `run-e2e-test`
This action runs a single test from the e2e test suite. It requires a test case, which is the name of the test.
It optionally runs the finalization e2e testcase, which is helpful after some e2e tests to double-check nothing is broken.

### Usage
Sample usage:
```yaml
steps:
- uses: ./.github/actions/run-e2e-test
with:
test-case: finalization
```
47 changes: 47 additions & 0 deletions .github/actions/build-and-push-dockerhub-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Build and push Docker Hub image
description:
Builds and pushes (optionally) docker image to Docker Hub, which does not have bash script as
entrypoint, just aleph-node.

inputs:
source-image:
description: Source aleph-node image
required: true
target-image:
description: Image to build
required: true
additional-image:
description: Additional image to tag
required: false
dockerhub-username:
description: Docker Hub username
required: true
dockerhub-password:
description: Docker Hub password
required: true

runs:
using: composite
steps:
- name: Build Docker Hub image
shell: bash
run: |
echo 'FROM ${{ inputs.source-image }}' > Dockerfile.dockerhub
echo 'ENTRYPOINT ["/usr/local/bin/aleph-node"]' >> Dockerfile.dockerhub
docker build -t '${{ inputs.target-image }}' -f Dockerfile.dockerhub .
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ inputs.dockerhub-username }}
password: ${{ inputs.dockerhub-password }}

- name: Push image to Docker Hub
shell: bash
run: |
docker push '${{ inputs.target-image }}'
if [[ -n '${{ inputs.additional-image }}' ]]; then
docker tag '${{ inputs.target-image }}' '${{ inputs.additional-image }}'
docker push '${{ inputs.additional-image }}'
fi
15 changes: 15 additions & 0 deletions .github/actions/cleanup-workspace/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Clean runner workspace
description: Removes all the files from the runner working directory

runs:
using: composite
steps:
- name: Remove files and directories from working directory
shell: bash
run: |
rm -rf *
rm -rf ~/.cargo
rm -rf ~/.cache
echo "Running 'ls -al' on $(pwd)"
ls -al
71 changes: 71 additions & 0 deletions .github/actions/get-docker-image-names/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: Get docker image names
description:
Returns
1) public ECR image names for release candidate image and deploy image
2) public DockerHub image names for Testnet and Mainnet
based on the current git HEAD. This action is intended to run only when tag was source of
trigger (ie tag push)
inputs:
ecr-repo:
required: true
description: URL to public aleph-node repo in ECR
dockerhub-repo:
required: true
description: URL to public aleph-node repo in DockerHub
outputs:
ecr-rc-image:
description: ECR release candidate image name
value: ${{ steps.get-docker-image-names.outputs.ecr-rc-image }}
ecr-deploy-image:
description: ECR deploy image name
value: ${{ steps.get-docker-image-names.outputs.ecr-deploy-image }}
dockerhub-testnet-image:
description: DockerHub Testnet docker image name
value: ${{ steps.get-docker-image-names.outputs.dockerhub-testnet-image }}
dockerhub-mainnet-image:
description: DockerHub Mainnet docker image name
value: ${{ steps.get-docker-image-names.outputs.dockerhub-mainnet-image }}
dockerhub-testnet-latest-image:
description: DockerHub Testnet docker image name
value: ${{ steps.get-docker-image-names.outputs.dockerhub-testnet-latest-image }}
dockerhub-mainnet-latest-image:
description: DockerHub Mainnet docker image name
value: ${{ steps.get-docker-image-names.outputs.dockerhub-mainnet-latest-image }}

runs:
using: composite
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Call action get-ref-properties
id: get-ref-properties
# yamllint disable-line rule:line-length
uses: Cardinal-Cryptography/github-actions/get-ref-properties@v1

- name: Check if tag push was a trigger
shell: bash
run: |
if [[ -z '${{ steps.get-ref-properties.outputs.tag }}' ]]; then
echo 'Error: did you forgot to run this workflow from tag?'
echo 'Instead, it was run from branch ${{ steps.get-ref-properties.outputs.branch }}'
exit 1
fi
- name: Get node image names
id: get-docker-image-names
shell: bash
env:
COMMIT_SHA: ${{ steps.get-ref-properties.outputs.sha }}
COMMIT_TAG: ${{ steps.get-ref-properties.outputs.tag }}
ECR: ${{ inputs.ecr-repo }}
DOCKERHUB: ${{ inputs.dockerhub-repo }}
# yamllint disable rule:line-length
run: |
echo 'ecr-rc-image=${{ env.ECR }}:${{ env.COMMIT_SHA }}' >> $GITHUB_OUTPUT
echo 'ecr-deploy-image=${{ env.ECR }}:${{ env.COMMIT_TAG }}' >> $GITHUB_OUTPUT
echo 'dockerhub-testnet-image=${{ env.DOCKERHUB }}:testnet-${{ env.COMMIT_TAG }}' >> $GITHUB_OUTPUT
echo 'dockerhub-mainnet-image=${{ env.DOCKERHUB }}:mainnet-${{ env.COMMIT_TAG }}' >> $GITHUB_OUTPUT
echo 'dockerhub-testnet-latest-image=${{ env.DOCKERHUB }}:testnet-latest' >> $GITHUB_OUTPUT
echo 'dockerhub-mainnet-latest-image=${{ env.DOCKERHUB }}:mainnet-latest' >> $GITHUB_OUTPUT
156 changes: 156 additions & 0 deletions .github/actions/run-e2e-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
name: 'Run e2e test'
description: 'Run single e2e test.'

inputs:
node-count:
description: 'Number of nodes to run.'
required: false
default: '5'
test-case:
description: 'Name of test to run.'
required: false
reserved-seats:
description: 'Number of reserved seats available to validators.'
required: false
non-reserved-seats:
description: 'Number of non-reserved seats available to validators.'
required: false
follow-up-finalization-check:
description: 'Whether to run a follow-up finalization check.'
required: false
deploy-adder:
description: 'Whether to deploy the adder sample contract to the node.'
required: false
default: 'false'
clean-button:
description: 'Whether to remove the button game contracts after running test suite.'
required: false
default: 'false'
deploy-button:
description: 'Whether to deploy the button game contracts to the node.'
required: false
default: 'false'
image-path:
description: 'Custom path to docker image for aleph-node'
required: false
default: aleph-test-docker
node-image:
description: 'Custom name of aleph-node image'
required: false
default: aleph-node:latest
compose-file:
description: 'Custom docker-compose configuration'
required: false
default: ''

runs:
using: 'composite'
steps:

- name: Download artifact with docker image
uses: actions/download-artifact@v2
with:
name: ${{ inputs.image-path }}

- name: Load node docker image
shell: bash
run: docker load -i aleph-node.tar

- name: Run consensus party
shell: bash
run: |
NODE_IMAGE='${{ inputs.node-image }}' \
DOCKER_COMPOSE='${{ inputs.compose-file }}' \
./.github/scripts/run_consensus.sh -n '${{ inputs.node-count }}'
- name: Sleep
shell: bash
run: sleep 60

- name: Download artifact with the test suite image
if: inputs.test-case != ''
uses: actions/download-artifact@v3
with:
name: aleph-e2e-client

- name: Load test suite docker image
if: inputs.test-case != ''
shell: bash
run: docker load -i aleph-e2e-client.tar

- name: Run single e2e test
id: run-single-e2e-test
if: inputs.test-case != ''
shell: bash
run: |
ARGS=(
-t '${{ inputs.test-case }}'
)
RESERVED_SEATS='${{ inputs.reserved-seats }}'
NON_RESERVED_SEATS='${{ inputs.non-reserved-seats }}'
if [[ -n "${RESERVED_SEATS}" && -n "${NON_RESERVED_SEATS}" ]]; then
ARGS+=(
-f "${RESERVED_SEATS}"
-n "${NON_RESERVED_SEATS}"
)
fi
DEPLOY_ADDER='${{ inputs.deploy-adder }}'
if [[ "${DEPLOY_ADDER}" = "true" ]]; then
pushd contracts/adder
export ADDER=$(./deploy.sh)
popd
fi
DEPLOY_BUTTON='${{ inputs.deploy-button }}'
if [[ "${DEPLOY_BUTTON}" = "true" ]]; then
source contracts/env/dev
export LIFETIME=20
contracts/scripts/deploy.sh
source contracts/scripts/test_env
fi
./.github/scripts/run_e2e_test.sh "${ARGS[@]}"
CLEAN_BUTTON='${{ inputs.clean-button }}'
if [[ "${CLEAN_BUTTON}" = "true" ]]; then
source contracts/env/dev
contracts/scripts/clean.sh
fi
- name: Get log tarball file name
if: ${{ failure() }}
id: get-log-tarball-file-name
shell: bash
run: |
test_case_escaped=$(echo ${{ inputs.test-case }} | sed 's/::/-/g')
echo "name=${test_case_escaped}" >> $GITHUB_OUTPUT
- name: Archive logs from failed e2e test
if: ${{ failure() }}
shell: bash
run: |
./.github/scripts/run_consensus.sh -n '${{ inputs.node-count }}' \
--archive-logs \
"aleph-node-${{ steps.get-log-tarball-file-name.outputs.name }}-e2e-failure.tgz"
- name: Upload logs from failed e2e test
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
path: aleph-node-${{ steps.get-log-tarball-file-name.outputs.name }}-e2e-failure.tgz
name: aleph-node-${{ steps.get-log-tarball-file-name.outputs.name }}-e2e-failure.tgz
if-no-files-found: error
retention-days: 7

- name: Run finalization e2e test
if: inputs.follow-up-finalization-check == 'true'
shell: bash
run: |
./.github/scripts/run_e2e_test.sh -t finalization::finalization
51 changes: 51 additions & 0 deletions .github/actions/slack-notification/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: 'Send Slack notifiction'
description: |
Action used to send Slack notifications about workflow status in channel specified in
SLACK_WEBHOOK
inputs:
notify-on:
description: "Choose when Slack messages should be sent"
type: choice
options:
- always
- success
- failure
- neutral
- skipped
- cancelled
- timed_out
- action_required
required: true

runs:
using: 'composite'
steps:
- name: Get workflow conclusion
uses: technote-space/workflow-conclusion-action@v3

- name: Export envs
shell: bash
run: |
#!/bin/bash
if [[ "$WORKFLOW_CONCLUSION" == "success" ]]; then \
echo SLACK_COLOR="#57d115" >> $GITHUB_ENV; else \
echo SLACK_COLOR="#ff0000" >> $GITHUB_ENV; fi
echo WORKFLOW_NAME="$(echo "$GITHUB_WORKFLOW" | rev | cut -f1 -d"/" | rev)" >> $GITHUB_ENV
echo STATUS="$(echo "$WORKFLOW_CONCLUSION")" >> $GITHUB_ENV
if [[ "$NOTIFY_ON" == "always" ]]; then \
echo WORKFLOW_CONCLUSION="always" >> $GITHUB_ENV; fi
echo NOTIFY_ON="$(echo "$NOTIFY_ON")" >> $GITHUB_ENV
env:
NOTIFY_ON: ${{ inputs.notify-on }}

- name: Send Slack message
uses: rtCamp/action-slack-notify@v2
if: env.WORKFLOW_CONCLUSION == env.NOTIFY_ON || env.WORKFLOW_CONCLUSION == 'always'
env:
SLACK_TITLE: "*Status: ${{ env.STATUS }}*"
SLACK_USERNAME: GithubActions
SLACK_ICON_EMOJI: ":aleph:"
MSG_MINIMAL: "actions url,commit"
SLACK_MESSAGE: "---------------------------------------"
SLACK_FOOTER: ""
Loading

0 comments on commit f728931

Please sign in to comment.