Skip to content

Commit

Permalink
feat: PAN-1832 transfer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jpantos committed Aug 16, 2024
1 parent 066ae5e commit d01d4e2
Show file tree
Hide file tree
Showing 21 changed files with 4,730 additions and 1 deletion.
1 change: 1 addition & 0 deletions .bandit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests:
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
branch = True
relative_files = True
126 changes: 126 additions & 0 deletions .github/actions/run-tests/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Run E2E Tests
description: Run end-to-end tests for Pantos
inputs:
ethereum-contracts-version:
description: 'The version of the ethereum-contracts repository to use'
required: false
default: ''
servicenode-version:
description: 'The version of the servicenode images to use. Use local if you want to use locally built images'
required: false
default: ''
validatornode-version:
description: 'The version of the validatornode repository to use'
required: false
default: ''
ethereum-contracts-path:
description: 'The path to the ethereum-contracts repository'
required: false
default: ${{ github.workspace }}/ethereum-contracts
servicenode-path:
description: 'The path to the servicenode repository'
required: false
default: ${{ github.workspace }}/servicenode
validatornode-path:
description: 'The path to the validatornode repository'
required: false
default: ${{ github.workspace }}/validatornode

runs:
using: 'composite'

steps:
- name: Set environment variables
shell: bash
run: |
echo "PANTOS_ETHEREUM_CONTRACTS=${{ inputs.ethereum-contracts-path }}" >> $GITHUB_ENV
echo "PANTOS_SERVICE_NODE=${{ inputs.servicenode-path }}" >> $GITHUB_ENV
echo "PANTOS_VALIDATOR_NODE=${{ inputs.validatornode-path }}" >> $GITHUB_ENV
echo "PANTOS_E2E_TESTS=${{ github.workspace }}/e2e-tests" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
path: ${{ env.PANTOS_E2E_TESTS }}

- uses: pantos-io/ci-workflows/.github/actions/install-python-deps@v1
with:
working-directory: ${{ env.PANTOS_E2E_TESTS }}

- name: Check for folder existence
shell: bash
id: check-folder
run: |
echo "PANTOS_ETHEREUM_CONTRACTS_EXISTS=$(test -d ${{ env.PANTOS_ETHEREUM_CONTRACTS }} && echo true || echo false)" >> $GITHUB_OUTPUT
echo "PANTOS_SERVICE_NODE_EXISTS=$(test -d ${{ env.PANTOS_SERVICE_NODE }} && echo true || echo false)" >> $GITHUB_OUTPUT
echo "PANTOS_VALIDATOR_NODE_EXISTS=$(test -d ${{ env.PANTOS_VALIDATOR_NODE }} && echo true || echo false)" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
if: steps.check-folder.outputs.PANTOS_ETHEREUM_CONTRACTS_EXISTS == 'false'
with:
repository: pantos-io/ethereum-contracts
path: ${{ env.PANTOS_ETHEREUM_CONTRACTS }}
sparse-checkout: |
docker-compose.yml
Makefile
- uses: actions/checkout@v4
if: steps.check-folder.outputs.PANTOS_SERVICE_NODE_EXISTS == 'false'
with:
repository: pantos-io/servicenode
path: ${{ env.PANTOS_SERVICE_NODE }}
sparse-checkout: |
docker-compose.yml
docker-compose.override.yml
Makefile
- uses: actions/checkout@v4
if: steps.check-folder.outputs.PANTOS_VALIDATOR_NODE_EXISTS == 'false'
with:
repository: pantos-io/validatornode
path: ${{ env.PANTOS_VALIDATOR_NODE }}
sparse-checkout: |
docker-compose.yml
docker-compose.override.yml
Makefile
- name: Create local signer_key
shell: bash
run: |
ssh-keygen -t ed25519 -f signer_key.pem -N ''
chmod 777 signer_key.pem
working-directory: ${{ env.PANTOS_SERVICE_NODE }}

- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
id: buildx

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-v1.0-e2e-test-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-buildx-v1.0-test-
- name: Check docker config and disable live reload
shell: bash
run: |
cat /etc/docker/daemon.json
echo '{ "live-restore": false }' | sudo tee /etc/docker/daemon.json
sudo systemctl reload docker
make check-swarm-init
working-directory: ${{ env.PANTOS_E2E_TESTS }}

- name: Run Tests
shell: bash
run: |
make test
working-directory: ${{ env.PANTOS_E2E_TESTS }}
env:
PANTOS_ETHEREUM_CONTRACTS_VERSION: ${{ inputs.ethereum-contracts-version }}
PANTOS_SERVICE_NODE_VERSION: ${{ inputs.servicenode-version }}
PANTOS_VALIDATOR_NODE_VERSION: ${{ inputs.validatornode-version }}

17 changes: 17 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CI
on:
push:
branches:
- main
pull_request:
workflow_call:

jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Run Tests
uses: jenseng/dynamic-uses@v1
with:
uses: ${{ github.repository }}/.github/actions/run-tests@${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || 'main' }}
12 changes: 12 additions & 0 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Sonar

on:
workflow_run:
workflows: [CI]
types: [completed]

jobs:
shared:
uses: pantos-io/ci-workflows/.github/workflows/sonar.yml@v1
secrets: inherit

6 changes: 6 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[mypy]
namespace_packages = True
explicit_package_bases = True

[mypy-pantos.common.*]
ignore_missing_imports = True
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: no-commit-to-branch
name: Check that branch name follows our standard
description: Checks that a branch has a proper name
args: ['--branch', 'main','--pattern', '^(?![a-zA-Z0-9._-]+)']
stages: [ commit-msg ]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
files: ^pantos/client/library
stages: [ commit ]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.1
hooks:
- id: mypy
files: ^pantos/client/library
additional_dependencies: ['types-requests', 'types-PyYAML']
stages: [ commit ]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
alias: format
args: ['--force-single-line-imports' ]
stages: [ commit ]
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
alias: lint
args:
- --quiet
- --format=custom
- --configfile=.bandit
stages: [ commit ]
9 changes: 9 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[style]
based_on_style = pep8
spaces_before_comment = 2
split_before_logical_operator = true
column_limit = 79
allow_split_before_dict_value = false
blank_lines_between_top_level_imports_and_variables = 1
blank_line_before_nested_class_or_def = false
split_before_named_assigns = false
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"editor.formatOnSave": true,
"files.autoSave": "onFocusChange",
"python.testing.pytestArgs": [],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.cwd": "${workspaceFolder}/tests",
"python.testing.autoTestDiscoverOnSaveEnabled": true,
"prettier.requireConfig": true,
"prettier.yamlSpacing": true,
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
Loading

0 comments on commit d01d4e2

Please sign in to comment.