Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
hitchhooker committed Feb 26, 2024
1 parent 3623163 commit 1eea278
Show file tree
Hide file tree
Showing 14 changed files with 316 additions and 54 deletions.
103 changes: 56 additions & 47 deletions .github/workflows/polkadot_version.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,65 @@
---
name: Check Polkadot and Cumulus Update

on:
schedule:
- cron: '0 0 * * *' # Runs at midnight UTC every day
- cron: '0 0 * * *' # Runs at midnight UTC every day

jobs:
update-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pyyaml requests
- name: Check for updates in Polkadot and replace version if needed
id: check-update-polkadot
run: python scripts/extract_version.py group_vars/polkadot.yaml default_client_version paritytech polkadot true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check for updates in Cumulus and replace version if needed
id: check-update-cumulus
run: python scripts/extract_version.py group_vars/cumulus.yaml default_client_version paritytech cumulus true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Git config
if: steps.check-update-polkadot.outputs.current_version != steps.check-update-polkadot.outputs.latest_release || steps.check-update-cumulus.outputs.current_version != steps.check-update-cumulus.outputs.latest_release
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Commit updated YAML files
if: steps.check-update-polkadot.outputs.current_version != steps.check-update-polkadot.outputs.latest_release || steps.check-update-cumulus.outputs.current_version != steps.check-update-cumulus.outputs.latest_release
run: |
git add group_vars/polkadot.yaml group_vars/cumulus.yaml
git commit -m "Update Polkadot and Cumulus versions"
git push
- name: Create Pull Request for Polkadot and Cumulus Update
if: steps.check-update-polkadot.outputs.current_version != steps.check-update-polkadot.outputs.latest_release || steps.check-update-cumulus.outputs.current_version != steps.check-update-cumulus.outputs.latest_release
uses: repo-sync/pull-request@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "Update Polkadot and Cumulus versions"
pr_body: "Automatically updated by GitHub Actions."
pr_label: "automated-pr"
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pyyaml requests
- name: Check for updates in Polkadot and replace version if needed
id: check-update-polkadot
run: >
python scripts/extract_version.py
group_vars/polkadot.yaml
default_client_version
paritytech polkadot-sdk true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check for updates in Cumulus and replace version if needed
id: check-update-cumulus
run: >
python scripts/extract_version.py
group_vars/cumulus.yaml
default_client_version
paritytech polkadot-sdk true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Git config
if: steps.check-update-polkadot.outputs.current_version != steps.check-update-polkadot.outputs.latest_release || steps.check-update-cumulus.outputs.current_version != steps.check-update-cumulus.outputs.latest_release
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Commit updated YAML files
if: steps.check-update-polkadot.outputs.current_version != steps.check-update-polkadot.outputs.latest_release || steps.check-update-cumulus.outputs.current_version != steps.check-update-cumulus.outputs.latest_release
run: |
git add group_vars/polkadot.yaml group_vars/cumulus.yaml
git commit -m "Update Polkadot and Cumulus versions"
git push
- name: Create Pull Request for Polkadot and Cumulus Update
if: steps.check-update-polkadot.outputs.current_version != steps.check-update-polkadot.outputs.latest_release || steps.check-update-cumulus.outputs.current_version != steps.check-update-cumulus.outputs.latest_release
uses: repo-sync/pull-request@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "Update Polkadot and Cumulus versions"
pr_body: "Automatically updated by GitHub Actions."
pr_label: "automated-pr"
3 changes: 2 additions & 1 deletion .later.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ rules:
- "ANSIBLE0026"
- "LINT0007"
- "LINT0008"
- YML108
- "YML108"
- "ANS126"

# All dotfiles (including hidden folders) are excluded by default.
# You can disable this setting and handle dotfiles by yourself with `exclude_files`.
Expand Down
1 change: 0 additions & 1 deletion group_vars/reth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ reth_eth_bt_port: 42069
reth_eth_sentry_port: 4000
reth_eth_sentry2_port: 4001
reth_eth_http_api: "engine,eth,reth,ots,web3,net,debug,trace,txpool,shh"
...
1 change: 0 additions & 1 deletion host_vars/eth01.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ role: "reth"
erigon_eth: True
pruned: False
pinned_service: True
...
1 change: 0 additions & 1 deletion playbooks/reth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
roles:
- setup_add_node_role
- setup_install_reth
...
44 changes: 44 additions & 0 deletions roles/setup_install_hyperbridge/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
- name: Symlink Cumulus release
ansible.builtin.file:
src: "{{ default_base_path }}/cumulus-v{{ default_client_version }}"
dest: "{{ default_base_path }}/cumulus"
force: True
state: link
owner: "{{ default_user }}"
group: "{{ default_user }}"

- name: Symlink binary executable
ansible.builtin.file:
src: "{{ default_base_path }}/cumulus-v{{ default_client_version }}"
dest: "/usr/local/bin/cumulus"
force: True
state: link
owner: "{{ default_user }}"
group: "{{ default_user }}"

- name: Symlink Cumulus service to systemd
ansible.builtin.file:
src: "{{ default_base_path }}/cumulus.service"
dest: "/etc/systemd/system/cumulus.service"
state: link
force: True
owner: "root"
group: "root"
mode: '0644'

- name: Stop Cumulus
ansible.builtin.systemd:
name: cumulus
state: stopped
enabled: True

- name: Systemd daemon-reload
ansible.builtin.systemd:
daemon_reload: True

- name: Start Cumulus
ansible.builtin.systemd:
name: cumulus
state: started
enabled: True
14 changes: 14 additions & 0 deletions roles/setup_install_hyperbridge/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Standards: 0.2
---
galaxy_info:
author: Rotko Networks <[email protected]>
description: Install or upgrade Collator
min_ansible_version: 3.0
platforms:
- name: Debian
versions:
- bullseye
- bookworm
dependencies:
- setup_add_node_role
- setup_install_rust
86 changes: 86 additions & 0 deletions roles/setup_install_hyperbridge/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
- name: Ensure group {{ default_user }} exists
ansible.builtin.group:
name: "{{ default_user }}"
state: present
system: True

- name: Ensure user {{ default_user }} exists without unnecessary privileges
ansible.builtin.user:
append: True
comment: hyperbridge service user
create_home: False
group: "{{ default_user }}"
groups: []
home: "{{ default_base_path }}"
name: "{{ default_user }}"
shell: "/sbin/nologin"
state: present
system: True

- name: Ensure user {{ default_user }} owns directories
ansible.builtin.file:
path: "{{ item }}"
owner: "{{ default_user }}"
group: "{{ default_user }}"
mode: '0750'
state: directory
loop:
- "{{ default_base_path }}"
- "{{ default_database_path }}"

- name: Gather facts
ansible.builtin.setup:

- name: Copy Hyperbridge systemd service for specific node type
ansible.builtin.template:
src: "{{ 'hyperbridge_' + default_node_type + '.service.j2' }}"
dest: "{{ default_base_path }}/hyperbridge.service"
owner: "{{ default_user }}"
group: "{{ default_user }}"
mode: '0640'
when: default_node_type in ["node", "validator", "full-node"]
notify:
- Symlink Hyperbridge service to systemd
- Stop Hyperbridge
- Systemd daemon-reload
- Start Hyperbridge
- Add type of service fact

- name: Flush handlers after Hyperbridge service copy
ansible.builtin.meta: flush_handlers

- name: Install Hyperbridge v{{ default_client_version }}
ansible.builtin.get_url:
url: "{{ default_download_url }}"
dest: "{{ default_base_path }}/hyperbridge-v{{ default_client_version }}"
mode: "u+r+x"
owner: "{{ default_user }}"
group: "{{ default_user }}"
register: download_result
notify:
- Add Service Pinned Status
- Add Hyperbridge service version
- Symlink Hyperbridge service to systemd
- Symlink Hyperbridge release
- Symlink binary executable
- Stop Hyperbridge
- Systemd daemon-reload
- Start Hyperbridge
when:
- ansible_local['noderole']['node']['pinned'] != "True"
- ansible_local['noderole']['node']['version'] != default_client_version

- name: Flush handlers after Hyperbridge install
ansible.builtin.meta: flush_handlers

- name: Verify Hyperbridge version
ansible.builtin.command: "{{ default_base_path }}/hyperbridge --version"
register: default_client_version_result
changed_when: False
failed_when: "default_client_version not in default_client_version_result.stdout"

- name: Ensure Hyperbridge service is running
ansible.builtin.systemd:
name: hyperbridge
state: started
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[Unit]
Description="{{ host_name.split('.')[0] }} bootnode - Cumulus service"
After=network-online.target
Wants=network-online.target

[Service]
User={{ default_user }}
Group={{ default_group }}
ExecStart={{ default_base_path }}/cumulus \
--name "{{ default_telemetry_name }}" \
--chain {{ default_network }} \
--base-path {{ default_base_path }} \
--database {{ default_database }} \
--state-pruning 256 \
--log sync=warn,afg=warn,babe=warn \
--telemetry-url 'wss://telemetry-backend.w3f.community/submit 1' \
--telemetry-url 'wss://telemetry.polkadot.io/submit/ 1' \
--listen-addr /ip4/0.0.0.0/tcp/{{ default_p2p_port }} \
--listen-addr /ip4/0.0.0.0/tcp/{{ default_p2p_port_ws }}/ws \
--public-addr /ip4/{{ ansible_host }}/tcp/{{ default_p2p_port }} \
--public-addr /ip4/{{ ansible_host }}/tcp/{{ default_p2p_port_ws }}/ws \
--public-addr /dns/{{ default_public_dns }}/tcp/{{ default_p2p_port }} \
--public-addr /dns/{{ default_public_dns }}/tcp/{{ default_p2p_port_ws }}/ws \
--public-addr /dns/{{ default_public_dns }}/tcp/{{ default_p2p_port_wss }}/wss \
--rpc-port {{ default_rpc_port }} \
--prometheus-port {{ default_prom_port }} \
--prometheus-external \
--relay-chain-rpc-urls {{ default_relay_rpc }} {{ default_relay_rpc_fallback }} \
--wasm-execution Compiled \
--sync {{ default_syncmode | default('warp') }} \
--no-hardware-benchmarks \
--rpc-external \
--rpc-methods safe \
--rpc-cors all \
--allow-private-ipv4

Restart=always
RestartSec=120

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[Unit]
Description="{{ host_name.split('.')[0] }} Collator - Cumulus service"
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=on-failure
RestartSec=10
User={{ default_user }}
Group={{ default_group }}
SyslogIdentifier={{ default_service }}
LimitNOFILE={{ default_max_open_files_in_service }}
SyslogFacility=local7
KillSignal=SIGHUP
ExecStart={{ default_base_path }}/cumulus \
--base-path {{ default_base_path }} \
--chain {{ default_network }} \
--database {{ default_database }} \
--sync {{ default_syncmode }} \
--name "{{ hostvars[inventory_hostname]['default_telemetry_name'] | default(host_name) }}" \
--telemetry-url 'wss://telemetry-backend.w3f.community/submit 1' \
--port {{ default_p2p_port }} \
--rpc-port {{ default_rpc_port }} \
--prometheus-port {{ default_prom_port }} \
--prometheus-external \
--public-addr /ip4/{{ ansible_host }}/tcp/{{ default_p2p_port }} \
--public-addr /ip4/{{ ansible_host }}/tcp/{{ default_p2p_port_ws }}/ws \
--relay-chain-rpc-urls {{ default_relay_rpc }} {{ default_relay_rpc_fallback }} \
--wasm-execution compiled \
--pruning 1000 \
--db-cache {{ ansible_memtotal_mb // 2 }}

[Install]
WantedBy=multi-user.target
Loading

0 comments on commit 1eea278

Please sign in to comment.