Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/actions/alicenet-cache/action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: 'Cache capnpro and other artifacts (swagger)'
name: 'AliceNet Cache'
description: 'Cache capnpro and other artifacts (swagger)'
runs:
using: "composite"
steps:
- uses: actions/cache@v3
name: "Cache capnpro and other artifacts (swagger)"
- name: "Cache capnpro and other artifacts (swagger)"
id: alicenet-cache
uses: actions/cache@v3
with:
path: |
localrpc/swagger-bindata/bindata.go
Expand All @@ -16,6 +16,7 @@ runs:
**/*_mngen.go
**/*_mngen_test.go
key: ${{ runner.os }}-go-${{ hashFiles('**/*.proto', './cmd/mngen/**', './localrpc/swagger/**') }}
- if: steps.alicenet-cache.outputs.cache-hit != 'true'
- name: "Build aliceNet cache [OPTIONAL]"
if: steps.alicenet-cache.outputs.cache-hit != 'true'
shell: bash
run: make generate-go
9 changes: 2 additions & 7 deletions .github/actions/alicenet-config/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ description: 'Configure the environment for alicenet'
runs:
using: "composite"
steps:
- uses: ./.github/actions/node-cache
- uses: ./.github/actions/golang-cache
- run: go install github.com/ethereum/go-ethereum/cmd/abigen@v1.10.8
- name: "Install abigen dependency"
shell: bash
- uses: ./.github/actions/smart-contract-cache
with:
execution-folder: "./bridge"
- uses: ./.github/actions/alicenet-cache
run: go install github.com/ethereum/go-ethereum/cmd/abigen@v1.10.8
2 changes: 1 addition & 1 deletion .github/actions/golang-cache/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Setup golang and its cache'
name: 'Golang cache'
description: 'Setup golang and its cache'
runs:
using: "composite"
Expand Down
12 changes: 8 additions & 4 deletions .github/actions/node-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ description: 'Configure node js and its cache'
runs:
using: "composite"
steps:
- uses: actions/setup-node@v3
- name: "Setup node"
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Node Cache

- name: "Node Cache"
id: node-cache
uses: actions/cache@v3.0.2
uses: actions/cache@v3.0.2 # This action allows caching dependencies and build outputs to improve workflow execution time.
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- if: steps.node-cache.outputs.cache-hit != 'true'

- name: "Build node cache [OPTIONAL]"
if: steps.node-cache.outputs.cache-hit != 'true'
shell: bash
run: npm ci && npm run clean && npm run compile
7 changes: 4 additions & 3 deletions .github/actions/smart-contract-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ runs:
OUTPUT=$(cat ./myhash.txt | sha256sum | cut -d' ' -f1)
echo $OUTPUT
printf "HASHLIST=${OUTPUT}" | tee --append "$GITHUB_ENV"
- uses: actions/cache@v3
name: "Cache contract bindings"
- name: "Cache contract bindings"
uses: actions/cache@v3
id: smart-contract-cache
with:
path: ./bridge/bindings
key: ${{ runner.os }}-go-${{ env.HASHLIST }}
- if: steps.smart-contract-cache.outputs.cache-hit != 'true'
- name: "Build smart contract cache [OPTIONAL]"
if: steps.smart-contract-cache.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{ inputs.execution-folder }}
run: npm run build
22 changes: 12 additions & 10 deletions .github/actions/solidity-tests/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 'Run the solidity unit tests in groups'
description: 'Run the solidity unit tests in groups'
name: 'Solidity grouped unit tests'
description: 'Runs the solidity unit tests in groups'

inputs:
test-group:
description: 'Regex to math the folder inside the test folder'
Expand All @@ -10,19 +11,20 @@ inputs:
sub-filter-exclude:
description: 'Sub folder to exclude in the search'
required: false
runs:
using: "composite"

runs:
using: "composite" # It contains a list of steps to run as opposed to a program to execute
steps:
- shell: bash
working-directory: ./bridge
run: npm run clean && npm run compile
- shell: bash
# It is called right after /node-cache actions. I don't think this step is necessary. To Be Verified
# - shell: bash
# working-directory: ./bridge
# run: npm run clean && npm run compile
- name: "Solidity test"
shell: bash
working-directory: ./bridge
run: |
SUB_FILTER_INCLUDE=/${{ inputs.sub-filter-include }}
# if inputs.sub-filter-include is empty we have to remove '/' if not
# the find command bellow will fail
# if inputs.sub-filter-include is empty we have to remove '/' otherwise the find command bellow will fail
if [[ "$SUB_FILTER_INCLUDE" == "/" ]]; then
SUB_FILTER_INCLUDE=""
fi
Expand Down
121 changes: 65 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Alicenet CI
name: "Alicenet CI"

on:
push:
branches: [ main, candidate ]
workflow_dispatch:
# push:
# branches: [ candidate ]
pull_request:
branches: [ main, candidate ]
branches: [ candidate ]
types: [ ready_for_review ]

env:
NODE_VERSION: 16.x
Expand All @@ -18,20 +20,22 @@ defaults:
shell: bash

jobs:

# Build solidity
solidity-build:
runs-on: ubuntu-20.04
timeout-minutes: 10
defaults:
run:
working-directory: ./bridge
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/node-cache
- uses: actions/checkout@v3
- uses: ./.github/actions/node-cache # calling node-cache action

# Solidity unit tests
solidity-unit-tests:
runs-on: ubuntu-20.04
timeout-minutes: 15
needs: solidity-build
strategy:
matrix:
# when adding a new test folder to the smart contracts make sure to
Expand All @@ -48,21 +52,20 @@ jobs:
- test-group: "[f-qF-Q]"
- test-group: "[r-sR-S]"
- test-group: "[t-zT-Z]"

needs: solidity-build
defaults:
run:
working-directory: ./bridge
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/node-cache
- uses: ./.github/actions/solidity-tests
- uses: ./.github/actions/node-cache # calling node-cache action
- uses: ./.github/actions/solidity-tests # calling solidity-test action
with:
test-group: ${{ matrix.test-group }}
sub-filter-include: ${{ matrix.sub-filter-include }}
sub-filter-exclude: ${{ matrix.sub-filter-exclude }}

solidity-linter:
# Linters
linter-solidity:
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: solidity-build
Expand All @@ -71,10 +74,11 @@ jobs:
working-directory: ./bridge
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/node-cache
- run: npm run lint-solidity
- uses: ./.github/actions/node-cache # calling node-cache action
- name: "Run solidity linter"
run: npm run lint-solidity

typescript-linter:
linter-typescript:
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: solidity-build
Expand All @@ -84,68 +88,73 @@ jobs:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/node-cache
- run: npm run clean && npm run compile && npm run typechain
- run: npm run lint
- uses: ./.github/actions/node-cache # calling node-cache action
- name: "Run hardhat typechain"
run: npm run typechain
- name: "Run eslint linter"
run: npm run lint

linter-golang:
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: golang-build
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/node-cache # calling node-cache action
- uses: ./.github/actions/golang-cache # calling golang-cache action
- uses: ./.github/actions/alicenet-config # calling alicenet-config action
- uses: ./.github/actions/smart-contract-cache # calling smart-contract-cache action
with:
execution-folder: "./bridge"
- uses: ./.github/actions/alicenet-cache # calling alicenet-cache action
- name: "Run golang linter"
uses: golangci/golangci-lint-action@v3

linter-golang-vet:
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: golang-build
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/golang-cache # calling golang-cache action
- uses: ./.github/actions/alicenet-config # calling alicenet-config action
- name: "Run go vet"
run: go vet ./...

golang-build:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: solidity-build
strategy:
matrix:
os: [ubuntu-20.04]
steps:
- name: "Sanitize branch name"
run: |
echo "BRANCH_NAME=$(echo ${{ github.head_ref || github.ref_name }} | sed -E 's/[^[:alnum:]]+/_/g')" >> $GITHUB_ENV
echo "OPERATING_SYSTEM=$(echo ${{ matrix.os }} | sed -E 's/[^[:alnum:]]+/_/g')" >> $GITHUB_ENV
echo "BRANCH_NAME=$(echo ${{ github.head_ref || github.ref_name }} | sed -E 's/[^[:alnum:]]+/_/g')" >> $GITHUB_ENV
echo "OPERATING_SYSTEM=$(echo ${{ matrix.os }} | sed -E 's/[^[:alnum:]]+/_/g')" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: ./.github/actions/alicenet-config
- run: make build
- name: Upload a Build Artifact
- uses: ./.github/actions/smart-contract-cache # calling smart-contract-cache action
- uses: ./.github/actions/golang-cache # calling golang-cache action
- uses: ./.github/actions/alicenet-config # calling alicenet-config action
- name: "Run make build"
run: make build
- name: "Upload the built artifact"
uses: actions/upload-artifact@v3.0.0
with:
name: alicenet-${{ env.BRANCH_NAME }}-${{ env.OPERATING_SYSTEM }}
path: ./madnet

golang-vet:
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: golang-build
continue-on-error: true
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/alicenet-config
- run: go vet ./...

golang-linter:
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: golang-build
continue-on-error: true
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/alicenet-config
- name: golangci-lint
uses: golangci/golangci-lint-action@v3

golang-unit-tests:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
timeout-minutes: 15
needs: golang-build
strategy:
matrix:
os: [ubuntu-20.04]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/alicenet-config
# tool to format the test output
- name: Set up gotestfmt
- uses: ./.github/actions/golang-cache # calling golang-cache action
- uses: ./.github/actions/alicenet-config # calling alicenet-config action
- name: "Set up gotestfmt pretty printer logging"
run: go install github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@latest
# Run tests with nice formatting. Save the original log in /tmp/gotest.log
# packages where the tests are stuck: ["blockchain", "badgerTrie", "consensus", "transport"]
- name: Run tests
- name: "Run tests"
run: |
set -euo pipefail
go test -json -v $(go list ./... | grep -Ev '/blockchain|/badgerTrie|/consensus|/transport|/testutils') 2>&1 | tee /tmp/gotest.log | gotestfmt
Expand Down