diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 497d27755..07b5a84c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,218 +1,218 @@ -name: ci - -on: - push: - branches: - - main - pull_request: - branches: - - main - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} - -jobs: - commitlint: - name: Check Commit Message - runs-on: ubuntu-22.04 - timeout-minutes: 30 - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install Required Dependencies - run: | - sudo apt-get update - sudo apt-get install -y git curl - curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - - sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs - - npm install conventional-changelog-conventionalcommits - npm install --save-dev @commitlint/config-conventional - npm install commitlint@latest - - - name: Print Versions - run: | - git --version - node --version - npm --version - npx commitlint --version - - - name: Validate Current (Last) Commit Message - if: github.event_name == 'push' - run: npx commitlint --last --verbose - - - name: Validate PR Commit Messages - if: github.event_name == 'pull_request' - run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose - - go-modules: - name: Test and Build Go Modules - runs-on: ubuntu-22.04 - timeout-minutes: 60 - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: recursive - - - name: Setup Cache - uses: actions/cache@v4 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ hashFiles('**/go.work.sum') }} - restore-keys: ${{ runner.os }}-go- - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: 1.22 - check-latest: true - cache-dependency-path: go.work.sum - - - name: Determine Workspace Modules - run: | - echo $(go list -f '{{.Dir}}' -m) - echo "GO_LINT_DIRS=$(go list -f '{{.Dir}}/...' -m | grep -v '/external/geth' | tr '\n' ' ')" >> ${GITHUB_ENV} - - - name: Run Gofmt - run: go list -f '{{.Dir}}' -m | xargs gofmt -d -e -l - - - name: Run Tidy & Workspace Sync - run: | - go list -f '{{.Dir}}' -m | xargs -L1 go mod tidy -C - go work sync - git checkout ${{ github.event.pull_request.head.ref }} - git diff --name-only --exit-code . || (echo "Golang modules/workspace not in sync with go.mod/go.sum/go.work/go.work.sum files" && exit 1) - git reset --hard HEAD - - - name: Run Lint - uses: golangci/golangci-lint-action@v4 - with: - version: v1.57.2 - args: --timeout 15m --verbose ${{ env.GO_LINT_DIRS }} - skip-cache: true # TODO(mrekucci): remove when the following issue is solved https://github.com/golangci/golangci-lint-action/issues/135#issuecomment-2039548548 - - - name: Run Build - run: go list -f '{{.Dir}}/...' -m | xargs go build - - # TODO(mrekucci): Re-enable /external/geth module when tests are passing. - - name: Run Test - run: go list -f '{{.Dir}}/...' -m | grep -v '/external/geth' | xargs go test -short -race - - - name: Setup Protobuf - uses: bufbuild/buf-setup-action@v1.31.0 - - - name: Protobuf Version - run: buf --version - - - name: Check Protobuf Parity - run: | - make bufgen - git checkout ${{ github.event.pull_request.head.ref }} - git diff --name-only --exit-code . || (echo "Generated files not in parity with the source files." && exit 1) - git reset --hard HEAD - working-directory: p2p - - foundry: - name: Foundry Checks and Reports - runs-on: ubuntu-22.04 - timeout-minutes: 30 - defaults: - run: - working-directory: contracts - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - - - name: Print Versions - run: | - git --version - node --version - npm --version - forge --version - - - name: Run Tests - run: forge clean && forge test -vvv --via-ir - - - name: Run Snapshot - run: forge snapshot --via-ir - - - name: Run Coverage - run: forge coverage --ir-minimum - - contracts: - name: Test and Build Contracts Scripts - runs-on: ubuntu-22.04 - timeout-minutes: 30 - defaults: - run: - working-directory: contracts - - strategy: - matrix: - node-version: [ 18.x, 20.x ] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - cache-dependency-path: ./contracts/package-lock.json - cache: npm - - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - - - name: Install Hardhat - run: npm install -g hardhat - - - name: Install Dependencies - run: npm install - - - name: Print Versions - run: | - git --version - node --version - npm --version - forge --version - - - name: Build - run: npm run build --if-present - - - name: Install abigen - run: | - sudo add-apt-repository -y ppa:ethereum/ethereum - sudo apt-get update - sudo apt-get install -y ethereum - abigen --version - - - name: Check ABI Parity - run: | - bash script.sh - git checkout ${{ github.event.pull_request.head.ref }} - git diff --name-only --exit-code . || (echo "Generated files not in parity with the source files." && exit 1) - git reset --hard HEAD - working-directory: contracts-abi +#name: ci +# +#on: +# push: +# branches: +# - main +# pull_request: +# branches: +# - main +# +#permissions: +# contents: read +# +#concurrency: +# group: ${{ github.workflow }}-${{ github.ref }} +# cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} +# +#jobs: +# commitlint: +# name: Check Commit Message +# runs-on: ubuntu-22.04 +# timeout-minutes: 30 +# +# steps: +# - name: Checkout Code +# uses: actions/checkout@v4 +# with: +# fetch-depth: 0 +# +# - name: Install Required Dependencies +# run: | +# sudo apt-get update +# sudo apt-get install -y git curl +# curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - +# sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs +# +# npm install conventional-changelog-conventionalcommits +# npm install --save-dev @commitlint/config-conventional +# npm install commitlint@latest +# +# - name: Print Versions +# run: | +# git --version +# node --version +# npm --version +# npx commitlint --version +# +# - name: Validate Current (Last) Commit Message +# if: github.event_name == 'push' +# run: npx commitlint --last --verbose +# +# - name: Validate PR Commit Messages +# if: github.event_name == 'pull_request' +# run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose +# +# go-modules: +# name: Test and Build Go Modules +# runs-on: ubuntu-22.04 +# timeout-minutes: 60 +# +# steps: +# - name: Checkout Code +# uses: actions/checkout@v4 +# with: +# fetch-depth: 0 +# submodules: recursive +# +# - name: Setup Cache +# uses: actions/cache@v4 +# with: +# path: | +# ~/go/pkg/mod +# ~/.cache/go-build +# key: ${{ runner.os }}-go-${{ hashFiles('**/go.work.sum') }} +# restore-keys: ${{ runner.os }}-go- +# +# - name: Setup Go +# uses: actions/setup-go@v5 +# with: +# go-version: 1.22 +# check-latest: true +# cache-dependency-path: go.work.sum +# +# - name: Determine Workspace Modules +# run: | +# echo $(go list -f '{{.Dir}}' -m) +# echo "GO_LINT_DIRS=$(go list -f '{{.Dir}}/...' -m | grep -v '/external/geth' | tr '\n' ' ')" >> ${GITHUB_ENV} +# +# - name: Run Gofmt +# run: go list -f '{{.Dir}}' -m | xargs gofmt -d -e -l +# +# - name: Run Tidy & Workspace Sync +# run: | +# go list -f '{{.Dir}}' -m | xargs -L1 go mod tidy -C +# go work sync +# git checkout ${{ github.event.pull_request.head.ref }} +# git diff --name-only --exit-code . || (echo "Golang modules/workspace not in sync with go.mod/go.sum/go.work/go.work.sum files" && exit 1) +# git reset --hard HEAD +# +# - name: Run Lint +# uses: golangci/golangci-lint-action@v4 +# with: +# version: v1.57.2 +# args: --timeout 15m --verbose ${{ env.GO_LINT_DIRS }} +# skip-cache: true # TODO(mrekucci): remove when the following issue is solved https://github.com/golangci/golangci-lint-action/issues/135#issuecomment-2039548548 +# +# - name: Run Build +# run: go list -f '{{.Dir}}/...' -m | xargs go build +# +# # TODO(mrekucci): Re-enable /external/geth module when tests are passing. +# - name: Run Test +# run: go list -f '{{.Dir}}/...' -m | grep -v '/external/geth' | xargs go test -short -race +# +# - name: Setup Protobuf +# uses: bufbuild/buf-setup-action@v1.31.0 +# +# - name: Protobuf Version +# run: buf --version +# +# - name: Check Protobuf Parity +# run: | +# make bufgen +# git checkout ${{ github.event.pull_request.head.ref }} +# git diff --name-only --exit-code . || (echo "Generated files not in parity with the source files." && exit 1) +# git reset --hard HEAD +# working-directory: p2p +# +# foundry: +# name: Foundry Checks and Reports +# runs-on: ubuntu-22.04 +# timeout-minutes: 30 +# defaults: +# run: +# working-directory: contracts +# +# steps: +# - name: Checkout Code +# uses: actions/checkout@v4 +# with: +# submodules: recursive +# +# - name: Install Foundry +# uses: foundry-rs/foundry-toolchain@v1 +# +# - name: Print Versions +# run: | +# git --version +# node --version +# npm --version +# forge --version +# +# - name: Run Tests +# run: forge clean && forge test -vvv --via-ir +# +# - name: Run Snapshot +# run: forge snapshot --via-ir +# +# - name: Run Coverage +# run: forge coverage --ir-minimum +# +# contracts: +# name: Test and Build Contracts Scripts +# runs-on: ubuntu-22.04 +# timeout-minutes: 30 +# defaults: +# run: +# working-directory: contracts +# +# strategy: +# matrix: +# node-version: [ 18.x, 20.x ] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ +# +# steps: +# - name: Checkout Code +# uses: actions/checkout@v4 +# with: +# fetch-depth: 0 +# +# - name: Use Node.js ${{ matrix.node-version }} +# uses: actions/setup-node@v4 +# with: +# node-version: ${{ matrix.node-version }} +# cache-dependency-path: ./contracts/package-lock.json +# cache: npm +# +# - name: Install Foundry +# uses: foundry-rs/foundry-toolchain@v1 +# +# - name: Install Hardhat +# run: npm install -g hardhat +# +# - name: Install Dependencies +# run: npm install +# +# - name: Print Versions +# run: | +# git --version +# node --version +# npm --version +# forge --version +# +# - name: Build +# run: npm run build --if-present +# +# - name: Install abigen +# run: | +# sudo add-apt-repository -y ppa:ethereum/ethereum +# sudo apt-get update +# sudo apt-get install -y ethereum +# abigen --version +# +# - name: Check ABI Parity +# run: | +# bash script.sh +# git checkout ${{ github.event.pull_request.head.ref }} +# git diff --name-only --exit-code . || (echo "Generated files not in parity with the source files." && exit 1) +# git reset --hard HEAD +# working-directory: contracts-abi diff --git a/.github/workflows/infrstructure.yml b/.github/workflows/infrstructure.yml index 00ea09fba..78e8bf1d4 100644 --- a/.github/workflows/infrstructure.yml +++ b/.github/workflows/infrstructure.yml @@ -1,38 +1,46 @@ name: infrastructure on: - workflow_run: - workflows: - - ci - types: - - completed - workflow_dispatch: - inputs: - profile: - description: 'Profile' - type: choice - options: - - devnet - - testnet - - stressnet - default: 'devnet' - logs: - description: 'Collect Logs' - type: boolean - default: false - debug: - description: 'Debug Deployment' - type: boolean - default: false - target: - description: 'Target Machine' - type: choice - options: - - lax1 - - nyc1 - - nyc2 - - mia2 - default: 'lax' + push: + branches: + - main + pull_request: + branches: + - main + +#on: +# workflow_run: +# workflows: +# - ci +# types: +# - completed +# workflow_dispatch: +# inputs: +# profile: +# description: 'Profile' +# type: choice +# options: +# - devnet +# - testnet +# - stressnet +# default: 'devnet' +# logs: +# description: 'Collect Logs' +# type: boolean +# default: false +# debug: +# description: 'Debug Deployment' +# type: boolean +# default: false +# target: +# description: 'Target Machine' +# type: choice +# options: +# - lax1 +# - nyc1 +# - nyc2 +# - mia2 +# default: 'lax' permissions: contents: read @@ -46,7 +54,7 @@ jobs: name: Setup and Test Nomad Cluster runs-on: ubuntu-22.04 timeout-minutes: 180 - if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} +# if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} steps: - name: Setup Environment @@ -132,8 +140,6 @@ jobs: - name: Configure Control Machine run: | - sudo useradd --create-home ubuntu && sudo usermod --append --groups sudo ubuntu - ANSIBLE_CONNECTION="ansible_connection=local" if [ "${IS_MANUAL_DEPLOYMENT}" == "true" ]; then ANSIBLE_CONNECTION="" @@ -153,9 +159,9 @@ jobs: cat <<-EOH > infrastructure/nomad/hosts.ini [nomad_servers] - ${TARGET_MACHINE_IP} ${ANSIBLE_CONNECTION} ansible_user=ubuntu + ${TARGET_MACHINE_IP} ${ANSIBLE_CONNECTION} ansible_user=${USER} [nomad_clients] - ${TARGET_MACHINE_IP} ${ANSIBLE_CONNECTION} ansible_user=ubuntu + ${TARGET_MACHINE_IP} ${ANSIBLE_CONNECTION} ansible_user=${USER} EOH ansible all --inventory infrastructure/nomad/hosts.ini --module-name ping diff --git a/infrastructure/nomad/playbooks/deploy.yml b/infrastructure/nomad/playbooks/deploy.yml index 27906aff0..8a1cecd12 100644 --- a/infrastructure/nomad/playbooks/deploy.yml +++ b/infrastructure/nomad/playbooks/deploy.yml @@ -50,7 +50,7 @@ src: "{{ vault_init_file }}" register: vault_init become: true - become_user: "{{ hostvars[inventory_hostname].ansible_user }}" + become_user: "{{ ansible_user }}" no_log: true - name: Parse Vault Initialization File diff --git a/infrastructure/nomad/playbooks/init.yml b/infrastructure/nomad/playbooks/init.yml index 28ad38a5d..1ae80bd24 100644 --- a/infrastructure/nomad/playbooks/init.yml +++ b/infrastructure/nomad/playbooks/init.yml @@ -1,11 +1,11 @@ - name: Initialize and Configure Cluster hosts: all become: yes - remote_user: "{{ hostvars[inventory_hostname].ansible_user }}" gather_facts: yes vars: version: "unknown" + ansible_user_home: "/home/{{ hostvars[inventory_hostname].ansible_user }}" nomad_server_ip: "{{ (hostvars[groups['nomad_servers'][0]]['ansible_default_ipv4']['address'] if groups['nomad_servers'] | default([]) | length > 0 else '127.0.0.1') }}" nomad_clients_defined: "{{ groups['nomad_clients'] | length > 0 }}" nomad_servers_defined: "{{ groups['nomad_servers'] | length > 0 }}" @@ -113,14 +113,14 @@ fail_msg: "The profile name is not set correctly." success_msg: "The profile name is set to: {{ profile }}." - - name: Ensure "{{ env }}" Directory Structure Exists + - name: Ensure "{{ ansible_user_home }}/{{ env }}" Directory Exists ansible.builtin.file: - path: "~{{ hostvars[inventory_hostname].ansible_user }}/{{ env }}/artifacts" + path: "{{ ansible_user_home }}/{{ env }}/artifacts" state: directory mode: "0744" recurse: yes become: true - become_user: "{{ hostvars[inventory_hostname].ansible_user }}" + become_user: "{{ ansible_user }}" tasks: - name: Add DataDog Repository Key @@ -150,7 +150,7 @@ - name: Add PostgreSQL Repository ansible.builtin.apt_repository: - repo: "deb http://apt.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg main" + repo: "deb https://apt.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg main" state: present filename: pgdg.list @@ -240,7 +240,7 @@ mode: "0400" when: vault_status.json.initialized == false become: true - become_user: "{{ hostvars[inventory_hostname].ansible_user }}" + become_user: "{{ ansible_user }}" no_log: true - name: Determine Vault Seal Status @@ -259,7 +259,7 @@ - vault_status.json.initialized == true - vault_seal_status.json.sealed == true become: true - become_user: "{{ hostvars[inventory_hostname].ansible_user }}" + become_user: "{{ ansible_user }}" no_log: true - name: Parse Vault Initialization File diff --git a/infrastructure/nomad/playbooks/templates/services/nomad.hcl.j2 b/infrastructure/nomad/playbooks/templates/services/nomad.hcl.j2 index b39d408ff..648d7292c 100644 --- a/infrastructure/nomad/playbooks/templates/services/nomad.hcl.j2 +++ b/infrastructure/nomad/playbooks/templates/services/nomad.hcl.j2 @@ -27,7 +27,7 @@ client { } {% if env == "devenv" %} host_volume "artifacts-volume" { - path = "/home/{{ hostvars[inventory_hostname].ansible_user }}/{{ env }}/artifacts" + path = "{{ ansible_user_home }}/{{ env }}/artifacts" } {% endif %} }