Skip to content

Commit

Permalink
merge 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
falcucci committed Feb 12, 2024
2 parents 0b1f4da + 36c0e5f commit dd8c25b
Show file tree
Hide file tree
Showing 139 changed files with 31,138 additions and 15,513 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
cardano_node_version:
description: Cardano node version.
required: true
cardano_node_docker_registry:
description: Cardano node Docker image registry.
required: false
default: "ghcr.io/intersectmbo/cardano-node"
google_region:
description: Google Cloud region name.
required: true
Expand Down Expand Up @@ -60,6 +64,10 @@ inputs:
mithril_genesis_verification_key_url:
description: Mithril genesis verification key location.
required: true
mithril_era_reader_adapter_type:
description: Mithril era reader adapter type.
required: false
default: "cardano-chain"
mithril_era_reader_address_url:
description: Mithril era reader address location.
required: true
Expand Down Expand Up @@ -145,6 +153,7 @@ runs:
environment_prefix = "${{ inputs.environment_prefix }}"
cardano_network = "${{ inputs.cardano_network }}"
cardano_image_id = "${{ inputs.cardano_node_version }}"
cardano_image_registry = "${{ inputs.cardano_node_docker_registry }}"
google_region = "${{ inputs.google_region }}"
google_zone = "${{ inputs.google_zone }}"
google_machine_type = "${{ inputs.google_machine_type }}"
Expand All @@ -158,7 +167,7 @@ runs:
mithril_genesis_secret_key = "${{ inputs.mithril_genesis_secret_key }}"
mithril_protocol_parameters = ${{ fromJSON(inputs.mithril_protocol_parameters) }}
mithril_signers = ${{ fromJSON(inputs.mithril_signers) }}
mithril_era_reader_adapter_type = "cardano-chain"
mithril_era_reader_adapter_type = "${{ inputs.mithril_era_reader_adapter_type }}"
mithril_era_reader_address_url = "${{ inputs.mithril_era_reader_address_url }}"
mithril_era_reader_verification_key_url = "${{ inputs.mithril_era_reader_verification_key_url }}"
mithril_era_reader_secret_key = "${{ inputs.mithril_era_reader_secret_key }}"
Expand Down
61 changes: 45 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
uses: ./.github/workflows/actions/build-upload-mithril-artifact
with:
binaries-build-args: --bin mithril-aggregator --bin mithril-signer --bin mithril-client --bin mithril-relay --features bundle_openssl,full
libraries-build-args: --package mithril-stm --package mithril-client --features full
libraries-build-args: --package mithril-stm --package mithril-client --features full,unstable

- name: Build Debian packages
shell: bash
Expand Down Expand Up @@ -83,12 +83,12 @@ jobs:
# Only build client on windows & mac
- os: macos-12
binaries-build-args: --bin mithril-client --features bundle_openssl
libraries-build-args: --package mithril-stm --package mithril-client --features full
libraries-build-args: --package mithril-stm --package mithril-client --features full,unstable
- os: windows-latest
# Use `--bins --package <package>` instead of `--bin <package>`, otherwise the 'windows' compatibility
# hack in mithril common cargo.toml doesn't apply (we have no idea why).
binaries-build-args: --bins --package mithril-client-cli --features bundle_openssl
libraries-build-args: --package mithril-stm --package mithril-client --no-default-features --features num-integer-backend,full
libraries-build-args: --package mithril-stm --package mithril-client --no-default-features --features num-integer-backend,full,unstable
runs-on: ${{ matrix.os }}

steps:
Expand Down Expand Up @@ -169,12 +169,12 @@ jobs:

include:
- os: ubuntu-22.04
test-args: --features portable,full --workspace
test-args: --features portable,full,unstable --workspace
# Only test client on windows & mac (since its the only binaries supported for those os for now)
- os: macos-12
test-args: --package mithril-client --package mithril-client-cli --features full
test-args: --package mithril-client --package mithril-client-cli --features full,unstable
- os: windows-latest
test-args: --package mithril-client --package mithril-client-cli --features full
test-args: --package mithril-client --package mithril-client-cli --features full,unstable

runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -328,7 +328,7 @@ jobs:
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: mithril-e2e-tests-artifacts-run_${{ github.run_number }}-attempt_${{ github.run_attempt }}-era_${{ matrix.era }}-run_id_${{ matrix.run_id }}
name: mithril-e2e-tests-artifacts-run_${{ github.run_number }}-attempt_${{ github.run_attempt }}-mode_${{ matrix.mode }}-era_${{ matrix.era }}-cardano-${{ matrix.cardano_node_version }}-fork-${{ matrix.hard_fork_latest_era_at_epoch }}-run_id_${{ matrix.run_id }}
path: |
./artifacts/*
# including node.sock makes the upload fails so exclude them:
Expand Down Expand Up @@ -567,7 +567,7 @@ jobs:
strategy:
fail-fast: false
matrix:
environment: [ testing-preview ]
environment: [ testing-preview, testing-sanchonet ]
include:
- environment: testing-preview
environment_prefix: testing
Expand Down Expand Up @@ -601,6 +601,30 @@ jobs:
google_machine_type: e2-standard-8
google_compute_instance_boot_disk_size: 200
google_compute_instance_data_disk_size: 250
- environment: testing-sanchonet
environment_prefix: testing
cardano_network: sanchonet
mithril_use_p2p_network: false
mithril_api_domain: api.mithril.network
mithril_protocol_parameters: |
{
k = 5
m = 100
phi_f = 0.65
}
mithril_signers: |
{
"1" = {
type = "verified",
pool_id = "",
},
}
terraform_backend_bucket: hydra-terraform-admin
google_region: europe-west1
google_zone: europe-west1-b
google_machine_type: e2-highmem-4
google_compute_instance_boot_disk_size: 200
google_compute_instance_data_disk_size: 250
environment: ${{ matrix.environment }}
runs-on: ubuntu-22.04
needs:
Expand All @@ -626,6 +650,7 @@ jobs:
environment: ${{ matrix.environment }}
cardano_network: ${{ matrix.cardano_network }}
cardano_node_version: ${{ vars.CARDANO_NODE_VERSION }}
cardano_node_docker_registry: ${{ vars.CARDANO_NODE_DOCKER_REGISTRY }}
google_region: ${{ matrix.google_region }}
google_zone: ${{ matrix.google_zone }}
google_machine_type: ${{ matrix.google_machine_type }}
Expand Down Expand Up @@ -717,14 +742,18 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
cache-dependency-path: docs/website/yarn.lock
node-version: 20
cache: 'npm'
cache-dependency-path: docs/website/package-lock.json

- name: Install dependencies
working-directory: docs/website
run: npm ci

- name: Build Docusaurus site
working-directory: docs/website
run: |
yarn && yarn build
npm run build
- name: Publish Docusaurus build
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -755,13 +784,13 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
cache-dependency-path: mithril-explorer/yarn.lock
node-version: 20
cache: 'npm'
cache-dependency-path: mithril-explorer/package-lock.json

- name: Install dependencies
working-directory: mithril-explorer
run: yarn install --frozen-lockfile
run: npm ci

- name: Test explorer
working-directory: mithril-explorer
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ jobs:
environment: ${{ matrix.environment }}
cardano_network: ${{ matrix.cardano_network }}
cardano_node_version: ${{ vars.CARDANO_NODE_VERSION }}
cardano_node_docker_registry: ${{ vars.CARDANO_NODE_DOCKER_REGISTRY }}
google_region: ${{ matrix.google_region }}
google_zone: ${{ matrix.google_zone }}
google_machine_type: ${{ matrix.google_machine_type }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ jobs:
environment: ${{ matrix.environment }}
cardano_network: ${{ matrix.cardano_network }}
cardano_node_version: ${{ vars.CARDANO_NODE_VERSION }}
cardano_node_docker_registry: ${{ vars.CARDANO_NODE_DOCKER_REGISTRY }}
google_region: ${{ matrix.google_region }}
google_zone: ${{ matrix.google_zone }}
google_machine_type: ${{ matrix.google_machine_type }}
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/scripts/parse-wasm-headless-tests-results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FILENAME=$1

if [ ! -e "$FILENAME" ]; then
echo "Error: File '$FILENAME' not found."
exit 1
fi

echo "Parse headless test results from file: '$FILENAME'"
if grep -q 'title="FAILED"' "$FILENAME"; then
FAILED_INFO=$(grep -oE '<div id="[^"]+" title="FAILED">([^<]+)' "$FILENAME" | awk 'NR==1 {print substr($0, index($0,$4))}')
echo "$FAILED_INFO"
exit 1
elif grep -q 'title="OK"' "$FILENAME"; then
grep -oE '<div id="[^"]+" title="OK">([^<]+)' "$FILENAME" | awk '{print substr($0, index($0,$4))}'
echo "Success: all tests passed."
else
cat "$FILENAME"
echo "No test results found. Check '$FILENAME' output."
exit 1
fi
44 changes: 44 additions & 0 deletions .github/workflows/scripts/run-wasm-tests-browser-headless.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import logging
import argparse
import sys
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

def run_headless_test():
parser = argparse.ArgumentParser(description='Run headless browser test.')
parser.add_argument('browser_type', choices=['chrome', 'firefox'], help='Browser type (chrome or firefox)')
args = parser.parse_args()

if args.browser_type.lower() == 'chrome':
options = webdriver.ChromeOptions()
options.add_argument("--headless=new")
driver = webdriver.Chrome(options=options)
elif args.browser_type.lower() == 'firefox':
options = webdriver.FirefoxOptions()
options.add_argument("--headless")
driver = webdriver.Firefox(options=options)
else:
logging.error("Invalid browser type. Supported types are 'chrome' and 'firefox'.")
return

try:
driver.get('http://localhost:8080/')

# Adjust the timeout to 3 minutes
wait = WebDriverWait(driver, 180)

# Wait until the div with id "tests_finished" is displayed
tests_finished_element = wait.until(EC.presence_of_element_located((By.ID, "tests_finished")))

html = driver.page_source
result_file = f"{args.browser_type.lower()}-results.html"
with open(result_file, "w", encoding="utf-8") as file:
file.write(html)

finally:
driver.quit()

if __name__ == "__main__":
run_headless_test()
74 changes: 74 additions & 0 deletions .github/workflows/test-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,77 @@ jobs:
- name: Mithril Stake Distribution / download & restore latest
shell: bash
run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} mithril-stake-distribution download $MITHRIL_STAKE_DISTRIBUTION_HASH --download-dir /app

test-mithril-client-wasm:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-22.04 ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Download built artifacts
uses: dawidd6/action-download-artifact@v2
with:
name: mithril-distribution-wasm
path: ./mithril-client-wasm
commit: ${{ steps.prepare.outputs.sha }}
branch: ${{ steps.prepare.outputs.branch }}
workflow: ci.yml
workflow_conclusion: success

- name: Unpack 'mithril-client-wasm' package
working-directory: mithril-client-wasm
run: tar -xvzf pkg/*.tgz -C pkg/ && mv pkg/package/* pkg/

- name: Install dependencies
working-directory: mithril-client-wasm
run: make www-test-install

- name: Create .env file
working-directory: mithril-client-wasm
run: |
echo "AGGREGATOR_ENDPOINT=${{ inputs.aggregator_endpoint }}" > ./www-test/.env
echo "GENESIS_VERIFICATION_KEY=$(curl -s ${{ inputs.genesis_verification_key }})" >> ./www-test/.env
- name: Start the server
working-directory: mithril-client-wasm
shell: bash
run: make www-test-serve &

- name: Wait for the server to be ready
shell: bash
run: |
MAX_ATTEMPTS=30
CURRENT_ATTEMPT=0
while true
do
sleep 1
CURRENT_ATTEMPT=$(( ${CURRENT_ATTEMPT} + 1 ))
if nc -z localhost 8080; then
echo "Server is ready."
break
fi
if [ "$CURRENT_ATTEMPT" -ge "$MAX_ATTEMPTS" ]; then
echo "Error: Server not ready after $MAX_ATTEMPTS attempts."
exit 1
fi
done
- name: Install selenium
shell: bash
run: pip install selenium

- name: Run Chrome headless
shell: bash
run: |
python3 ./.github/workflows/scripts/run-wasm-tests-browser-headless.py chrome
./.github/workflows/scripts/parse-wasm-headless-tests-results.sh chrome-results.html
- name: Run Firefox headless
shell: bash
run: |
python3 ./.github/workflows/scripts/run-wasm-tests-browser-headless.py firefox
./.github/workflows/scripts/parse-wasm-headless-tests-results.sh firefox-results.html
3 changes: 3 additions & 0 deletions .github/workflows/test-deploy-network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
cardano_network: preview
mithril_use_p2p_network: true
mithril_api_domain: api.mithril.network
mithril_era_reader_adapter_type: cardano-chain
mithril_protocol_parameters: |
{
k = 5
Expand Down Expand Up @@ -81,6 +82,7 @@ jobs:
environment: ${{ matrix.environment }}
cardano_network: ${{ matrix.cardano_network }}
cardano_node_version: ${{ vars.CARDANO_NODE_VERSION }}
cardano_node_docker_registry: ${{ vars.CARDANO_NODE_DOCKER_REGISTRY }}
google_region: ${{ matrix.google_region }}
google_zone: ${{ matrix.google_zone }}
google_machine_type: ${{ matrix.google_machine_type }}
Expand All @@ -94,6 +96,7 @@ jobs:
mithril_signers: ${{ toJSON(matrix.mithril_signers) }}
mithril_genesis_secret_key: ${{ secrets.GENESIS_SECRET_KEY }}
mithril_genesis_verification_key_url: ${{ vars.GENESIS_VERIFICATION_KEY_URL }}
mithril_era_reader_adapter_type: ${{ matrix.mithril_era_reader_adapter_type }}
mithril_era_reader_address_url: ${{ vars.ERA_READER_ADDRESS_URL }}
mithril_era_reader_verification_key_url: ${{ vars.ERA_READER_VERIFICATION_KEY_URL }}
mithril_era_reader_secret_key: ${{ secrets.ERA_READER_SECRET_KEY }}
Expand Down
Loading

0 comments on commit dd8c25b

Please sign in to comment.