-
Notifications
You must be signed in to change notification settings - Fork 20
Feature/ndev 698/move workflow from bildkite #990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
s-medvedev
merged 45 commits into
develop
from
feature/NDEV-698/move-workflow-from-bildkite
Oct 28, 2022
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
ba779d8
init git hub action
kristinaNikolaevaa 2c9af3f
fix
kristinaNikolaevaa e870057
Update deploy.yml
kristinaNikolaevaa be46e9c
Update deploy.yml
kristinaNikolaevaa 93cedc5
fixed
kristinaNikolaevaa c06f0da
Update deploy.py
kristinaNikolaevaa 7648f9b
logs
kristinaNikolaevaa f787398
logs
kristinaNikolaevaa e80741e
Update deploy.yml
kristinaNikolaevaa 19df223
test
kristinaNikolaevaa 84daa23
fix
kristinaNikolaevaa 0280dcb
fix
kristinaNikolaevaa ba0d41c
try
kristinaNikolaevaa f4372cb
test
kristinaNikolaevaa 65d82b1
fix
kristinaNikolaevaa 19c9b27
Update deploy.py
kristinaNikolaevaa 22830ed
fix
kristinaNikolaevaa 5b77b0f
try fix uniswap tests
kristinaNikolaevaa 77e7f80
Update deploy.py
kristinaNikolaevaa 001eef0
added logs
kristinaNikolaevaa 93d2a0c
added logs
kristinaNikolaevaa 92dd0f0
Update deploy.py
kristinaNikolaevaa eb73e98
Update deploy.py
kristinaNikolaevaa 69c6635
test
kristinaNikolaevaa bd300fb
init git hub action
kristinaNikolaevaa e3752ad
Update deploy.py
kristinaNikolaevaa 81a70f8
Merge branch 'feature/NDEV-698/move-workflow-from-bildkite' of https:…
kristinaNikolaevaa 6eceec6
fix
kristinaNikolaevaa 5d903f7
Merge branch 'develop' into feature/NDEV-698/move-workflow-from-bildkite
kristinaNikolaevaa 68f74ab
Update pipeline.yml
kristinaNikolaevaa c41e070
Merge branch 'develop' into feature/NDEV-698/move-workflow-from-bildkite
kristinaNikolaevaa 77253b5
new runners
kristinaNikolaevaa a7a21ea
python -> python3
kristinaNikolaevaa a55dbe8
Update pipeline.yml
kristinaNikolaevaa 3ecdbfc
Update pipeline.yml
kristinaNikolaevaa fe4dfe3
Update pipeline.yml
kristinaNikolaevaa 0133625
Update pipeline.yml
kristinaNikolaevaa 687eb3a
Update pipeline.yml
kristinaNikolaevaa 4701b73
Update pipeline.yml
kristinaNikolaevaa 6c9faec
Update pipeline.yml
kristinaNikolaevaa f5bd056
fixed after review
kristinaNikolaevaa 867ee45
Update pipeline.yml
kristinaNikolaevaa 4d6be6c
Merge branch 'develop' into feature/NDEV-698/move-workflow-from-bildkite
kristinaNikolaevaa 3a2182a
Merge branch 'feature/NDEV-698/move-workflow-from-bildkite' of https:…
kristinaNikolaevaa 34e0c07
fixed after review
kristinaNikolaevaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
init git hub action
- Loading branch information
commit ba779d8c8a76535fb7f7a19286ab704a6ae3a51b
There are no files selected for viewing
This file contains hidden or 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,179 @@ | ||
| import os | ||
| import time | ||
| import sys | ||
| import docker | ||
| import subprocess | ||
| from python_terraform import Terraform | ||
| try: | ||
| import click | ||
| except ImportError: | ||
| print("Please install click library: pip install click==8.0.3") | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| @click.group() | ||
| def cli(): | ||
| pass | ||
|
|
||
|
|
||
| githab_sha = "247f98b26f325530623ece2a749ffd1787ded7" | ||
| githab_build_id = 1 | ||
| TFSTATE_BUCKET = "nl-ci-stands" | ||
| TFSTATE_KEY = f"tests/test-{githab_sha}-{githab_build_id}" | ||
| TFSTATE_REGION = "us-east-2" | ||
| IMAGE_NAME = "neonlabsorg/proxy" | ||
| DOCKER_USER = os.environ.get("DHUBU") | ||
| DOCKER_PASSWORD = os.environ.get("DHUBP") | ||
|
|
||
| UNISWAP_V2_CORE_COMMIT = 'stable' | ||
| UNISWAP_V2_CORE_IMAGE = f'neonlabsorg/uniswap-v2-core:{UNISWAP_V2_CORE_COMMIT}' | ||
| UNISWAP_TESTNAME = "test_UNISWAP.py" | ||
|
|
||
| docker_client = docker.APIClient() | ||
|
|
||
|
|
||
| @cli.command(name="build_docker_image") | ||
| @click.option('--neon_evm_commit') | ||
| @click.option('--github_sha') | ||
| def build_docker_image(neon_evm_commit, github_sha): | ||
| neon_evm_image = f'neonlabsorg/evm_loader:{neon_evm_commit}' | ||
| docker_client.pull(neon_evm_image) | ||
|
|
||
| buildargs = {"NEON_EVM_COMMIT": neon_evm_commit, | ||
| "PROXY_REVISION": github_sha, | ||
| "PROXY_LOG_CFG": "log_cfg.json"} | ||
|
|
||
| tag = f"{IMAGE_NAME}:{github_sha}" | ||
| click.echo("start build") | ||
| output = docker_client.build(tag=tag, buildargs=buildargs, path="./") | ||
| for line in output: | ||
| if 'stream' in str(line): | ||
| click.echo(str(line).strip('\n')) | ||
|
|
||
|
|
||
| @cli.command(name="publish_image") | ||
| @click.option('--branch') | ||
| @click.option('--github_sha') | ||
| def publish_image(branch, github_sha): | ||
| if branch == 'master': | ||
| tag = 'stable' | ||
| elif branch == 'develop': | ||
| tag = 'latest' | ||
| else: | ||
| tag = branch.split('/')[-1] | ||
|
|
||
| docker_client.login(username=DOCKER_USER, password=DOCKER_PASSWORD) | ||
|
|
||
| docker_client.tag(f"{IMAGE_NAME}:{github_sha}", tag) | ||
| docker_client.push(f"{IMAGE_NAME}:{tag}") | ||
|
|
||
| docker_client.tag(f"{IMAGE_NAME}:{github_sha}", github_sha) | ||
| docker_client.push(f"{IMAGE_NAME}:{github_sha}") | ||
|
|
||
|
|
||
| @cli.command(name="terraform") | ||
| def terraform_build_infrastructure(): | ||
| # app = cdktf.App() | ||
|
|
||
| # a = cdktf.S3BackendProps( | ||
| # bucket=TFSTATE_BUCKET, | ||
| # key=TFSTATE_KEY, | ||
| # region=TFSTATE_REGION | ||
| # ) | ||
|
|
||
| # app.synth() | ||
| # print(app) | ||
| t = Terraform() | ||
|
|
||
| backend_config = {"bucket": TFSTATE_BUCKET, | ||
| "key": TFSTATE_KEY, "region": TFSTATE_REGION} | ||
| return_code, stdout, stderr = t.init(backend_config=backend_config) | ||
|
|
||
| print(return_code) | ||
| print(stdout) | ||
| print(stderr) | ||
| t.destroy() | ||
|
|
||
|
|
||
| @click.option('--neon_evm_commit') | ||
| @click.option('--github_sha') | ||
| @cli.command(name="deploy_check") | ||
| def deploy_check(neon_evm_commit, github_sha): | ||
| os.environ["REVISION"] = neon_evm_commit | ||
| os.environ["NEON_EVM_COMMIT"] = github_sha | ||
| os.environ["FAUCET_COMMIT"] = 'latest' | ||
|
|
||
| containers = ['proxy', 'solana', 'proxy_program_loader', | ||
| 'dbcreation', 'faucet', 'airdropper', 'indexer'] | ||
| for container in containers: | ||
| dump_docker_logs(container) | ||
| cleanup_docker() | ||
|
|
||
| try: | ||
| command = 'docker-compose -f proxy/docker-compose-test.yml up -d' | ||
| subprocess.run(command, shell=True) | ||
| except: | ||
| raise "Docker-compose failed to start" | ||
|
|
||
| wait_for_faucet() | ||
| run_uniswap_test() | ||
|
|
||
|
|
||
| def dump_docker_logs(container): | ||
| logs = docker_client.logs(container).decode("utf-8") | ||
| with open(f"{container}.log", "w") as file: | ||
| file.write(logs) | ||
|
|
||
|
|
||
| def cleanup_docker(): | ||
| click.echo(f"Cleanup docker-compose...") | ||
| command = "docker-compose -f proxy/docker-compose-test.yml down -t 1" | ||
| subprocess.run(command, shell=True) | ||
| click.echo(f"Cleanup docker-compose done.") | ||
| click.echo(f"Removing temporary data volumes...") | ||
| command = "docker volume prune -f" | ||
| subprocess.run(command, shell=True) | ||
| click.echo(f"Removing temporary data done.") | ||
|
|
||
|
|
||
| def get_fauset_url(): | ||
| command = 'docker exec proxy bash -c "echo ${FAUCET_URL}"' | ||
| faucet_url = subprocess.run( | ||
| command, shell=True, capture_output=True, text=True).stdout.strip() | ||
| return faucet_url | ||
|
|
||
|
|
||
| @cli.command(name="test1") | ||
| def wait_for_faucet(): | ||
| faucet_url = get_fauset_url() | ||
| faucet_ip, faucet_port = faucet_url.replace("http://", "").split(':') | ||
|
|
||
| command = f'docker exec proxy nc -zvw1 {faucet_ip} {faucet_port}' | ||
| timeout_sec = 120 | ||
| start_time = time.time() | ||
| while True: | ||
| if time.time() - start_time > timeout_sec: | ||
| raise f'Faucet {faucet_url} is unavailable - time is over' | ||
| try: | ||
| if subprocess.run( | ||
| command, shell=True, capture_output=True, text=True).returncode == 0: | ||
| click.echo(f"Faucet {faucet_url} is available") | ||
| break | ||
| else: | ||
| click.echo(f"Faucet {faucet_url} is unavailable - sleeping") | ||
| except: | ||
| raise f"Error during run command {command}" | ||
| time.sleep(1) | ||
|
|
||
|
|
||
| def run_uniswap_test(): | ||
| fauset_url = get_fauset_url() | ||
| os.environ["FAUCET_URL"] = fauset_url | ||
|
|
||
| docker_client.pull(UNISWAP_V2_CORE_IMAGE) | ||
| command = f'docker run --rm --network=container:proxy -e FAUCET_URL --entrypoint ./deploy-test.sh {UNISWAP_V2_CORE_IMAGE} all' | ||
| out = subprocess.run(command, shell=True) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| cli() | ||
This file contains hidden or 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,34 @@ | ||
| name: Build proxy docker image | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| full_test_suite: | ||
| required: true | ||
| neon_evm_commit: | ||
| required: true | ||
| neon_evm_branch: | ||
| required: true | ||
| pull_request: | ||
| types: [opened, reopened, synchronize] | ||
| push: | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| submodules: "true" | ||
| # - name: TEST | ||
| # run: echo ${{ github.event.inputs.full_test_suite }} | ||
|
|
||
| - name: install python libs | ||
| run: pip install docker | ||
|
|
||
| - name: build docker image | ||
| run: python ./.github/workflows/deploy.py build_docker_image --github_sha=${GITHUB_SHA} | ||
|
|
||
| - name: publish image | ||
| run: python ./.github/workflows/deploy.py publish_image --branch=${GITHUB_REF} --github_sha=${GITHUB_SHA} | ||
|
|
||
| - name: deploy_check | ||
| run: python ./.github/workflows/deploy.py publish_image --neon_evm_commit='latest' --github_sha=${GITHUB_SHA} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.