diff --git a/.github/actions/alicenet-cache/action.yml b/.github/actions/alicenet-cache/action.yml index f966c28c..3b04ae65 100644 --- a/.github/actions/alicenet-cache/action.yml +++ b/.github/actions/alicenet-cache/action.yml @@ -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 @@ -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 diff --git a/.github/actions/alicenet-config/action.yml b/.github/actions/alicenet-config/action.yml index 5432fe45..b0adbe9e 100644 --- a/.github/actions/alicenet-config/action.yml +++ b/.github/actions/alicenet-config/action.yml @@ -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 diff --git a/.github/actions/golang-cache/action.yml b/.github/actions/golang-cache/action.yml index d9b947b3..573e1b57 100644 --- a/.github/actions/golang-cache/action.yml +++ b/.github/actions/golang-cache/action.yml @@ -1,4 +1,4 @@ -name: 'Setup golang and its cache' +name: 'Golang cache' description: 'Setup golang and its cache' runs: using: "composite" diff --git a/.github/actions/node-cache/action.yml b/.github/actions/node-cache/action.yml index 256a1d68..ca35db49 100644 --- a/.github/actions/node-cache/action.yml +++ b/.github/actions/node-cache/action.yml @@ -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 diff --git a/.github/actions/smart-contract-cache/action.yml b/.github/actions/smart-contract-cache/action.yml index 165347e1..7fc9e851 100644 --- a/.github/actions/smart-contract-cache/action.yml +++ b/.github/actions/smart-contract-cache/action.yml @@ -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 diff --git a/.github/actions/solidity-tests/action.yml b/.github/actions/solidity-tests/action.yml index 19ce5cd8..64737d2e 100644 --- a/.github/actions/solidity-tests/action.yml +++ b/.github/actions/solidity-tests/action.yml @@ -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' @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c1b80e6..cd363660 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -18,7 +20,7 @@ defaults: shell: bash jobs: - + # Build solidity solidity-build: runs-on: ubuntu-20.04 timeout-minutes: 10 @@ -26,12 +28,14 @@ jobs: 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 @@ -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 @@ -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 @@ -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