Skip to content

Commit

Permalink
Apex CI (#248)
Browse files Browse the repository at this point in the history
* Add apex ci

* APEX-184 Create Blade github action for apex-bridge and fw changes

-----------------------------------------------------

Co-authored-by: milos-ethernal <[email protected]>
Co-authored-by: Zoltan Babinski <[email protected]>

* Add apex ci

* test folder

* Add apex ci

* CI fixes

* Yaml and failing test fixes

* remove some comment

* file name

* Resolve comments

---------

Co-authored-by: Igor Crevar <[email protected]>
Co-authored-by: Zoltan Babinski <[email protected]>
  • Loading branch information
3 people authored May 23, 2024
1 parent 66d84d2 commit fe9fd74
Show file tree
Hide file tree
Showing 11 changed files with 461 additions and 345 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/apex-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
name: ApexBridge CI
on: # yamllint disable-line rule:truthy
push:
branches:
- feature/apex-bridge
pull_request:
branches:
- feature/apex-bridge
workflow_dispatch:
inputs:
build_blade:
description: Build Blade
type: boolean
default: true
lint:
description: Lint
type: boolean
default: true
# unit_test:
# description: Unit Tests
# type: boolean
# default: true
e2e_apex_tests:
description: E2E ApexBridge Tests
type: boolean
default: true
workflow_call:
inputs:
build_blade:
description: Build Blade
type: boolean
lint:
description: Lint
type: boolean
required: true
# unit_test:
# description: Unit Tests
# type: boolean
# required: true
e2e_apex_tests:
description: E2E ApexBridge Tests
type: boolean
default: true
outputs:
build_blade:
description: Build Blade output
value: ${{ jobs.build_blade.outputs.workflow_output }}
lint:
description: Lint output
value: ${{ jobs.lint.outputs.workflow_output }}
unit_test:
description: Unit Tests output
value: ${{ jobs.unit_test.outputs.workflow_output }}
e2e_apex_tests:
description: E2E ApexBridge Tests output
value: ${{ jobs.e2e_apex_tests.outputs.workflow_output }}

jobs:
build_blade:
name: Build Blade
uses: ./.github/workflows/build.yml
if: |
inputs.build_blade ||
github.event_name == 'pull_request' ||
(github.event_name == 'push' && github.ref == 'refs/heads/feature/apex-bridge')
lint:
name: Lint
uses: ./.github/workflows/lint.yml
needs: build_blade
if: |
inputs.lint ||
github.event_name == 'pull_request' ||
(github.event_name == 'push' && github.ref == 'refs/heads/feature/apex-bridge')
# unit_test:
# name: Unit Tests
# uses: ./.github/workflows/unit-test.yml
# needs: build_blade
# if: |
# inputs.unit_test ||
# github.event_name == 'pull_request' ||
# (github.event_name == 'push' && github.ref == 'refs/heads/feature/apex-bridge')
e2e_apex_test:
name: E2E ApexBridge Tests
uses: ./.github/workflows/e2e-apex-test.yml
needs: build_blade
if: |
inputs.e2e_polybft_test ||
github.event_name == 'pull_request' ||
(github.event_name == 'push' && github.ref == 'refs/heads/feature/apex-bridge')
secrets:
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
36 changes: 18 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on: # yamllint disable-line rule:truthy
branches:
- main
- develop
branches-ignore:
- feature/apex-bridge
pull_request:
branches-ignore:
- feature/apex-bridge
Expand Down Expand Up @@ -109,61 +107,63 @@ jobs:
uses: ./.github/workflows/build.yml
if: |
inputs.build_blade ||
github.event_name == 'pull_request' ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'))
(github.event_name == 'pull_request' && github.ref != 'refs/heads/feature/apex-bridge') ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref != 'refs/heads/feature/apex-bridge'))
lint:
name: Lint
uses: ./.github/workflows/lint.yml
needs: build_blade
if: |
inputs.lint ||
github.event_name == 'pull_request' ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'))
(github.event_name == 'pull_request' && github.ref != 'refs/heads/feature/apex-bridge') ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref != 'refs/heads/feature/apex-bridge'))
unit_test:
name: Unit Tests
uses: ./.github/workflows/unit-test.yml
needs: build_blade
if: |
inputs.unit_test ||
github.event_name == 'pull_request' ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'))
(github.event_name == 'pull_request' && github.ref != 'refs/heads/feature/apex-bridge') ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref != 'refs/heads/feature/apex-bridge'))
e2e_polybft_test:
name: E2E PolyBFT Tests
uses: ./.github/workflows/e2e-polybft-test.yml
needs: build_blade
if: |
inputs.e2e_polybft_test ||
github.event_name == 'pull_request' ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'))
(github.event_name == 'pull_request' && github.ref != 'refs/heads/feature/apex-bridge') ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref != 'refs/heads/feature/apex-bridge'))
secrets:
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
e2e_legacy_test:
name: E2E Legacy Tests
uses: ./.github/workflows/e2e-legacy-test.yml
needs: build_blade
if: |
inputs.e2e_legacy_test ||
github.event_name == 'pull_request' ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'))
(github.event_name == 'pull_request' && github.ref != 'refs/heads/feature/apex-bridge') ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref != 'refs/heads/feature/apex-bridge'))
property_polybft_test:
name: Property PolyBFT Tests
uses: ./.github/workflows/property-polybft-test.yml
needs: build_blade
if: |
inputs.property_polybft_test ||
github.event_name == 'pull_request' ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'))
(github.event_name == 'pull_request' && github.ref != 'refs/heads/feature/apex-bridge') ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref != 'refs/heads/feature/apex-bridge'))
fuzz_test:
name: Fuzz Tests
uses: ./.github/workflows/fuzz-test.yml
needs: build_blade
if: |
inputs.fuzz_test ||
github.event_name == 'pull_request' ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'))
(github.event_name == 'pull_request' && github.ref != 'refs/heads/feature/apex-bridge') ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref != 'refs/heads/feature/apex-bridge'))
benchmark_test:
name: Benchmark Tests
uses: ./.github/workflows/benchmark-test.yml
needs: build_blade
if: |
inputs.benchmark_test ||
github.event_name == 'pull_request' ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'))
(github.event_name == 'pull_request' && github.ref != 'refs/heads/feature/apex-bridge') ||
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref != 'refs/heads/feature/apex-bridge'))
75 changes: 75 additions & 0 deletions .github/workflows/e2e-apex-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
name: E2E ApexBridge Tests
on: # yamllint disable-line rule:truthy
workflow_call:
outputs:
workflow_output:
description: E2E ApexBridge Tests output
value: ${{ jobs.e2e_apex_bridge.outputs.e2e_apex_output_failure }}
secrets:
PERSONAL_ACCESS_TOKEN:
required: true

jobs:
e2e_apex_bridge:
name: Run E2E ApexBridge Tests
runs-on: ubuntu-latest
env:
E2E_TESTS: true
E2E_LOGS: true
CI_VERBOSE: true
outputs:
e2e_apex_output_failure: ${{ steps.run_e2e_apex_failure.outputs.test_output }}
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Install Go
uses: actions/[email protected]
with:
go-version: 1.21.x
check-latest: true
- name: Generate OpenSSL certificate
run: openssl req -x509 -out localhost.crt -keyout localhost.key -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -extensions EXT -config <(printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
- name: Copy certificate key
run: sudo cp localhost.key /etc/ssl/private/localhost.key
- name: Copy certificate itself
run: sudo cp localhost.crt /usr/local/share/ca-certificates/localhost.crt
- name: Add certificate to trusted list
run: sudo update-ca-certificates
- name: Update certificate key folder permissions
run: sudo chmod -R 755 /etc/ssl/private
- name: Update certificate key file permissions
run: sudo chmod 644 /etc/ssl/private/localhost.key
- name: Install Cardano tools
uses: milos-ethernal/cardano-node-action@5a3bce7266cc1500d96e8fa63b3bb97135988482
- name: Install ogmios
uses: milos-ethernal/ogmios-action@13e2be0b00da80f26bb8583fa129bd7c08856a49
- name: Checkout apex-bridge repo
uses: actions/[email protected]
with:
repository: Ethernal-Tech/apex-bridge
ref: main
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Build apex-bridge
run: |
go build
sudo mv apex-bridge /usr/local/bin/
- name: Verify apex-bridge executable
run: apex-bridge --help
- name: Checkout blade
uses: actions/[email protected]
- name: Check certificate key permissions
run: ls -l /etc/ssl/private/localhost.key
- name: Run tests
run: make test-e2e-apex-bridge
- name: Run tests failed
if: failure()
id: run_e2e_apex_failure
run: echo "test_output=false" >> $GITHUB_OUTPUT
- name: Archive test logs
if: always()
uses: actions/[email protected]
with:
name: e2e-apex-bridge-logs
path: e2e-logs-*/
retention-days: 30
14 changes: 14 additions & 0 deletions .github/workflows/e2e-polybft-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ jobs:
uses: milos-ethernal/cardano-node-action@5a3bce7266cc1500d96e8fa63b3bb97135988482
- name: Install ogmios
uses: milos-ethernal/ogmios-action@13e2be0b00da80f26bb8583fa129bd7c08856a49
- name: Checkout apex-bridge repo
uses: actions/[email protected]
with:
repository: Ethernal-Tech/apex-bridge
ref: main
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Build apex-bridge
run: |
go build
sudo mv apex-bridge /usr/local/bin/
- name: Verify apex-bridge executable
run: apex-bridge --help
- name: Checkout blade
uses: actions/[email protected]
- name: Check certificate key permissions
run: ls -l /etc/ssl/private/localhost.key
- name: Run tests
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ test-e2e-polybft: check-go
env EDGE_BINARY=${PWD}/artifacts/blade E2E_TESTS=true E2E_LOGS=true \
go test -v -timeout=1h30m ./e2e-polybft/e2e/...

.PHONY: test-e2e-apex-bridge
test-e2e-apex-bridge: check-go
go build -o artifacts/blade .
env EDGE_BINARY=${PWD}/artifacts/blade E2E_TESTS=true E2E_LOGS=true \
go test -v -timeout=1h30m ./e2e-polybft/e2e/... -run "ApexBridge"

.PHONY: test-property-polybft
test-property-polybft: check-go
go build -o artifacts/blade .
Expand Down
15 changes: 11 additions & 4 deletions build-sc.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/bin/bash

BRANCH=main # optimization-chain-registration

cd ./apex-bridge-smartcontracts
git checkout main
# git pull origin
# git branch -D feat/tries
# git fetch origin
# git switch feat/tries
git fetch origin
git pull origin
if [ "$BRANCH" != "main" ]; then
PRINT "SWITCHING TO ${BRANCH}"
git branch -D ${BRANCH}
git switch ${BRANCH}
git pull origin # this is not important but lets have it here
fi
npm i && npx hardhat compile
cd ..
go run consensus/polybft/contractsapi/apex-artifacts-gen/main.go
Expand Down
Loading

0 comments on commit fe9fd74

Please sign in to comment.