From c1670f4282a40a149c2bd547710b2997feb0849d Mon Sep 17 00:00:00 2001 From: eanzhao Date: Wed, 17 Jul 2024 15:57:23 +0800 Subject: [PATCH 01/24] commit yml files --- .github/workflows/build-and-test.yml | 55 ++++++++++++++++++++++ .github/workflows/publish-test-summary.yml | 29 ++++++++++++ README.md | 8 ++-- 3 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build-and-test.yml create mode 100644 .github/workflows/publish-test-summary.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000000..6d1cfefa25 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,55 @@ +name: build-and-test +on: + push: + branches: + - dev + - master + +env: + DOTNET_INSTALL_DIR: "./.dotnet" + Solution_Name: AElf.All.sln + Service_Name: AELF + +jobs: + test: + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '6.0' + + - name: Download AElf build tools + run: bash scripts/download_binary.sh + + - name: Install Protobuf + run: bash scripts/install_protobuf.sh + + - name: Build Solution + run: bash scripts/build.sh + + - name: Run Tests + run: dotnet test --logger "trx;LogFileName=TestResults.trx" ${{ env.Solution_Name }} + + - name: Upload Test Results + uses: actions/upload-artifact@v2 + with: + name: test-results + path: TestResults.trx + + - name: Parse Test Results + run: | + dotnet tool install --global trx2junit + trx2junit TestResults.trx + python3 -c "import xml.etree.ElementTree as ET; import json; root = ET.parse('TestResults.xml').getroot(); summary = root.find('.//Counters'); passed = summary.get('passed'); failed = summary.get('failed'); with open('TestSummary.json', 'w') as f: json.dump({'passed': passed, 'failed': failed}, f)" + + - name: Upload Test Summary + uses: actions/upload-artifact@v2 + with: + name: test-summary + path: TestSummary.json \ No newline at end of file diff --git a/.github/workflows/publish-test-summary.yml b/.github/workflows/publish-test-summary.yml new file mode 100644 index 0000000000..54563e5b3a --- /dev/null +++ b/.github/workflows/publish-test-summary.yml @@ -0,0 +1,29 @@ +name: Publish Test Summary +on: + workflow_run: + workflows: ["build-and-test"] + types: + - completed + +jobs: + publish: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion != 'skipped' }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Download Test Summary + uses: actions/download-artifact@v2 + with: + name: test-summary + + - name: Publish Test Summary + uses: actions/gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: . + publish_branch: gh-pages + user_name: 'GitHub Action' + user_email: 'yiqi.zhao@aelf.io' + commit_message: 'Update test summary' \ No newline at end of file diff --git a/README.md b/README.md index 616aa7f841..44488b05c7 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/aelfblockchain.svg?label=%40aelfblockchain&style=social)](https://twitter.com/aelfblockchain) [![Telegram](https://badgen.net/badge/telegram/join/blue?icon=telegram)](https://t.me/aelfdeveloper) - BRANCH | AZURE PIPELINES | TESTS | CODE COVERAGE - ------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ - MASTER | [![Build Status](https://dev.azure.com/AElfProject/AElf/_apis/build/status/AElfProject.AElf?branchName=master)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=master) | [![Test Status](https://img.shields.io/azure-devops/tests/AElfProject/AElf/1/master)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=master) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) - DEV | [![Build Status](https://dev.azure.com/AElfProject/AElf/_apis/build/status/AElfProject.AElf?branchName=dev)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=dev) | [![Test Status](https://img.shields.io/azure-devops/tests/AElfProject/AElf/1/dev)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=dev) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) + BRANCH | GITHUB ACTIONS BUILD AND TEST | CODE COVERAGE + ------ |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ + MASTER | ![Tests Summary](https://img.shields.io/badge/dynamic/json?label=tests&url=https%3A%2F%2Feanzhao.github.io%2FAElf%2FTestSummary.json&query=%24.passed%20%2F%20%24.failed&color=blue&branch=master) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) + DEV | ![Tests Summary](https://img.shields.io/badge/dynamic/json?label=tests&url=https%3A%2F%2Feanzhao.github.io%2FAElf%2FTestSummary.json&query=%24.passed%20%2F%20%24.failed&color=blue&branch=dev) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) Welcome to AElf's official GitHub repo ! From f90e762ed502cb47d2fde4fc13809effeb299658 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Wed, 17 Jul 2024 16:33:13 +0800 Subject: [PATCH 02/24] fix publish-test-summary.yml --- .github/workflows/publish-test-summary.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-test-summary.yml b/.github/workflows/publish-test-summary.yml index 54563e5b3a..67426eaede 100644 --- a/.github/workflows/publish-test-summary.yml +++ b/.github/workflows/publish-test-summary.yml @@ -19,11 +19,11 @@ jobs: name: test-summary - name: Publish Test Summary - uses: actions/gh-pages@v3 + uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: . publish_branch: gh-pages - user_name: 'GitHub Action' + user_name: 'eanzhao' user_email: 'yiqi.zhao@aelf.io' commit_message: 'Update test summary' \ No newline at end of file From b5c39417e6b16b446662f9b23dc9de2b3de5c726 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Wed, 17 Jul 2024 17:56:44 +0800 Subject: [PATCH 03/24] Split build and test workflows --- .github/workflows/build-and-test.yml | 55 ---------------------------- .github/workflows/build.yml | 34 +++++++++++++++++ .github/workflows/test.yml | 37 +++++++++++++++++++ README.md | 8 ++-- 4 files changed, 75 insertions(+), 59 deletions(-) delete mode 100644 .github/workflows/build-and-test.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml deleted file mode 100644 index 6d1cfefa25..0000000000 --- a/.github/workflows/build-and-test.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: build-and-test -on: - push: - branches: - - dev - - master - -env: - DOTNET_INSTALL_DIR: "./.dotnet" - Solution_Name: AElf.All.sln - Service_Name: AELF - -jobs: - test: - runs-on: ubuntu-latest - permissions: - pull-requests: write - contents: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup dotnet - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '6.0' - - - name: Download AElf build tools - run: bash scripts/download_binary.sh - - - name: Install Protobuf - run: bash scripts/install_protobuf.sh - - - name: Build Solution - run: bash scripts/build.sh - - - name: Run Tests - run: dotnet test --logger "trx;LogFileName=TestResults.trx" ${{ env.Solution_Name }} - - - name: Upload Test Results - uses: actions/upload-artifact@v2 - with: - name: test-results - path: TestResults.trx - - - name: Parse Test Results - run: | - dotnet tool install --global trx2junit - trx2junit TestResults.trx - python3 -c "import xml.etree.ElementTree as ET; import json; root = ET.parse('TestResults.xml').getroot(); summary = root.find('.//Counters'); passed = summary.get('passed'); failed = summary.get('failed'); with open('TestSummary.json', 'w') as f: json.dump({'passed': passed, 'failed': failed}, f)" - - - name: Upload Test Summary - uses: actions/upload-artifact@v2 - with: - name: test-summary - path: TestSummary.json \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..6b203af7a4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,34 @@ +name: Build +on: + push: + branches: + - dev + - master + +env: + DOTNET_INSTALL_DIR: "./.dotnet" + Solution_Name: AElf.All.sln + Service_Name: AELF + +jobs: + test: + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '6.0' + + - name: Download AElf build tools + run: bash scripts/download_binary.sh + + - name: Install Protobuf + run: bash scripts/install_protobuf.sh + + - name: Build Solution + run: bash scripts/build.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000..9eaaf6465f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: Test +on: + push: + branches: + - dev + - master + +env: + DOTNET_INSTALL_DIR: "./.dotnet" + Solution_Name: AElf.All.sln + Service_Name: AELF + +jobs: + test: + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '6.0' + + - name: Download AElf build tools + run: bash scripts/download_binary.sh + + - name: Install Protobuf + run: bash scripts/install_protobuf.sh + + - name: Build Solution + run: bash scripts/build.sh + + - name: Run Tests + run: dotnet test ${{ env.Solution_Name }} diff --git a/README.md b/README.md index 44488b05c7..e74d0d24a0 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/aelfblockchain.svg?label=%40aelfblockchain&style=social)](https://twitter.com/aelfblockchain) [![Telegram](https://badgen.net/badge/telegram/join/blue?icon=telegram)](https://t.me/aelfdeveloper) - BRANCH | GITHUB ACTIONS BUILD AND TEST | CODE COVERAGE - ------ |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ - MASTER | ![Tests Summary](https://img.shields.io/badge/dynamic/json?label=tests&url=https%3A%2F%2Feanzhao.github.io%2FAElf%2FTestSummary.json&query=%24.passed%20%2F%20%24.failed&color=blue&branch=master) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) - DEV | ![Tests Summary](https://img.shields.io/badge/dynamic/json?label=tests&url=https%3A%2F%2Feanzhao.github.io%2FAElf%2FTestSummary.json&query=%24.passed%20%2F%20%24.failed&color=blue&branch=dev) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) + BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE + ------ |-------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ + MASTER | ![GitHub Workflow Build Status](https://img.shields.io/github/workflow/status/AElfProject/AElf/build.yml?branch=master&style=flat-square) | ![GitHub Workflow Test Status](https://img.shields.io/github/workflow/status/AElfProject/AElf/test.yaml?branch=master&style=flat-square) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) + DEV | ![GitHub Workflow Build Status](https://img.shields.io/github/workflow/status/AElfProject/AElf/build.yml?branch=dev&style=flat-square) | ![GitHub Workflow Test Status](https://img.shields.io/github/workflow/status/AElfProject/AElf/test.yaml?branch=dev&style=flat-square) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) Welcome to AElf's official GitHub repo ! From 062042bb4cfae7b2b5021c19141f1a21a2836705 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Fri, 19 Jul 2024 17:13:14 +0800 Subject: [PATCH 04/24] Refactor test.yml --- .github/workflows/publish-test-summary.yml | 29 -------- .github/workflows/test.yml | 78 ++++++++++++++++------ 2 files changed, 59 insertions(+), 48 deletions(-) delete mode 100644 .github/workflows/publish-test-summary.yml diff --git a/.github/workflows/publish-test-summary.yml b/.github/workflows/publish-test-summary.yml deleted file mode 100644 index 67426eaede..0000000000 --- a/.github/workflows/publish-test-summary.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Publish Test Summary -on: - workflow_run: - workflows: ["build-and-test"] - types: - - completed - -jobs: - publish: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion != 'skipped' }} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Download Test Summary - uses: actions/download-artifact@v2 - with: - name: test-summary - - - name: Publish Test Summary - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: . - publish_branch: gh-pages - user_name: 'eanzhao' - user_email: 'yiqi.zhao@aelf.io' - commit_message: 'Update test summary' \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9eaaf6465f..7aff779662 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,37 +1,77 @@ -name: Test on: push: branches: - dev - master -env: - DOTNET_INSTALL_DIR: "./.dotnet" - Solution_Name: AElf.All.sln - Service_Name: AELF +permissions: + contents: read + actions: read + checks: write jobs: - test: + build-test: + name: Build & Test runs-on: ubuntu-latest - permissions: - pull-requests: write - contents: write steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + - name: Setup dotnet uses: actions/setup-dotnet@v4 with: dotnet-version: '6.0' - - name: Download AElf build tools - run: bash scripts/download_binary.sh + - run: dotnet restore + - run: dotnet build --no-restore + - run: dotnet test --no-build --no-restore --verbosity normal -l:"trx;LogFileName=TestResults.xml" + + - name: Install xmlstarlet + run: sudo apt-get install -y xmlstarlet - - name: Install Protobuf - run: bash scripts/install_protobuf.sh + - name: Extract Test Counts + id: test_counts + run: | + passed=0 + failed=0 + skipped=0 + for file in $(find . -name 'TestResults.xml') + do + passed=$((passed + $(xmlstarlet sel -t -v "/TestRun/ResultSummary/Counters/@passed" "$file"))) + failed=$((failed + $(xmlstarlet sel -t -v "/TestRun/ResultSummary/Counters/@failed" "$file"))) + total=$(xmlstarlet sel -t -v "/TestRun/ResultSummary/Counters/@total" "$file") + executed=$(xmlstarlet sel -t -v "/TestRun/ResultSummary/Counters/@executed" "$file") + skipped=$((total - executed)) + done + echo "::set-output name=passed::$passed" + echo "::set-output name=failed::$failed" + echo "::set-output name=skipped::$skipped" + + - name: Update Gist + uses: actions/github-script@v5 + with: + github-token: ${{secrets.GIST_TOKEN}} + script: | + const fs = require('fs'); + const passed = "${{ steps.test_counts.outputs.passed }}"; + const failed = "${{ steps.test_counts.outputs.failed }}"; + const skipped = "${{ steps.test_counts.outputs.skipped }}"; + const gistId = "59e13bd3823d754542ac98d24b3329b4"; + const filename = "test-results.json"; + const color = failed > 0 ? "red" : "brightgreen"; + const content = `{"schemaVersion":1,"label":"tests","message":"${passed} passed, ${failed} failed, ${skipped} skipped","color":"${color}"}`; - - name: Build Solution - run: bash scripts/build.sh + let gist; + try { + gist = await github.rest.gists.get({ gist_id: gistId }); + } catch (error) { + if (error.status !== 404) { + throw error; + } + } - - name: Run Tests - run: dotnet test ${{ env.Solution_Name }} + await github.rest.gists.update({ + gist_id: gistId, + files: { + [filename]: { content } + } + }); \ No newline at end of file From 5918f43f719d9991e593648cfdc220d24ae1dd77 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Mon, 22 Jul 2024 16:18:12 +0800 Subject: [PATCH 05/24] Commit yml files for using github actions to build and test solution. --- .github/workflows/build.yml | 33 ++++++++++++ .github/workflows/test.yml | 102 ++++++++++++++++++++++++++++++++++++ README.md | 9 ++-- 3 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..0f4398de3d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,33 @@ +name: Build +on: + push: + branches: + - dev + - master + - feature/use-github-actions + +env: + DOTNET_INSTALL_DIR: "./.dotnet" + +jobs: + build: + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0' + + - name: Download AElf build tools + run: bash scripts/download_binary.sh + + - name: Install Protobuf + run: bash scripts/install_protobuf.sh + + - name: Build Solution + run: bash scripts/build.sh \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000..ad8adb12d3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,102 @@ +name: Test +on: + push: + branches: + - dev + - master + - feature/use-github-actions + +env: + DOTNET_INSTALL_DIR: "./.dotnet" + SOLUTION_NAME: "AElf.All.sln" + GIST_ID: "59e13bd3823d754542ac98d24b3329b4" + +jobs: + build-and-test: + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0' + + - name: Download AElf build tools + run: bash scripts/download_binary.sh + + - name: Install Protobuf + run: sudo apt-get update && sudo apt-get install -y protobuf-compiler + + - run: dotnet restore ${{ env.SOLUTION_NAME }} + - run: dotnet build --no-restore ${{ env.SOLUTION_NAME }} + + - name: Run Unit Tests + run: | + for testproj in $(find . -name '*Tests.csproj') + do + dotnet test --no-build --no-restore --verbosity normal -l:"trx;LogFileName=TestResults.xml" $testproj || true + done + + - name: Install xmlstarlet + run: | + sudo apt-get update + sudo apt-get install -y xmlstarlet + + - name: Extract Test Counts + id: test_counts + run: | + passed=0 + failed=0 + skipped=0 + for file in $(find . -name 'TestResults.xml') + do + passed_value=$(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@passed" "$file") + passed=$((passed + passed_value)) + failed_value=$(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@failed" "$file") + failed=$((failed + failed_value)) + total_value=$(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@total" "$file") + executed_value=$(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@executed" "$file") + skipped_value=$((total_value - executed_value)) + skipped=$((skipped + skipped_value)) + done + echo "PASSED=$passed" >> $GITHUB_ENV + echo "FAILED=$failed" >> $GITHUB_ENV + echo "SKIPPED=$skipped" >> $GITHUB_ENV + + - name: Get branch name + run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV + + - name: Update Gist + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GIST_TOKEN }} + script: | + const fs = require('fs'); + const passed = "${{ env.PASSED }}"; + const failed = "${{ env.FAILED }}"; + const skipped = "${{ env.SKIPPED }}"; + const gistId = "${{ env.GIST_ID }}"; + const branchName = "${{ env.BRANCH_NAME }}"; + const filename = `${branchName}-test-results.json`; + const color = failed > 0 ? "red" : "brightgreen"; + const content = `{"schemaVersion":1,"label":"tests","message":"${passed} passed, ${failed} failed, ${skipped} skipped","color":"${color}"}`; + + let gist; + try { + gist = await github.rest.gists.get({ gist_id: gistId }); + } catch (error) { + if (error.status !== 404) { + throw error; + } + } + + await github.rest.gists.update({ + gist_id: gistId, + files: { + [filename]: { content } + } + }); \ No newline at end of file diff --git a/README.md b/README.md index 616aa7f841..7d99f352b6 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,10 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/aelfblockchain.svg?label=%40aelfblockchain&style=social)](https://twitter.com/aelfblockchain) [![Telegram](https://badgen.net/badge/telegram/join/blue?icon=telegram)](https://t.me/aelfdeveloper) - BRANCH | AZURE PIPELINES | TESTS | CODE COVERAGE - ------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ - MASTER | [![Build Status](https://dev.azure.com/AElfProject/AElf/_apis/build/status/AElfProject.AElf?branchName=master)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=master) | [![Test Status](https://img.shields.io/azure-devops/tests/AElfProject/AElf/1/master)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=master) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) - DEV | [![Build Status](https://dev.azure.com/AElfProject/AElf/_apis/build/status/AElfProject.AElf?branchName=dev)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=dev) | [![Test Status](https://img.shields.io/azure-devops/tests/AElfProject/AElf/1/dev)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=dev) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) - +BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE +------ |--------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ +MASTER | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/eanzhao/59e13bd3823d754542ac98d24b3329b4/raw/master-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) +DEV | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/eanzhao/59e13bd3823d754542ac98d24b3329b4/raw/dev-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) Welcome to AElf's official GitHub repo ! AElf is a blockchain system aiming to achieve scalability and extensibility through the use of side-chains and a flexible design. To support multiple use cases AElf makes it as easy as possible to extend/customize the system by providing easy to use tools and frameworks in order to customize the chains and write smart contracts. AElf will eventually support various languages that will let developers choose the one they are the most comfortable with. From 6c5d7545c58da84c848a4439633cc0151abdd582 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Mon, 22 Jul 2024 16:52:23 +0800 Subject: [PATCH 06/24] Improve test.yml --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad8adb12d3..2d4bc4bcc2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -80,9 +80,10 @@ jobs: const failed = "${{ env.FAILED }}"; const skipped = "${{ env.SKIPPED }}"; const gistId = "${{ env.GIST_ID }}"; - const branchName = "${{ env.BRANCH_NAME }}"; + let branchName = "${{ env.BRANCH_NAME }}"; + branchName = branchName.replace(/\//g, '-'); const filename = `${branchName}-test-results.json`; - const color = failed > 0 ? "red" : "brightgreen"; + const color = failed > 0 ? "red" : (skipped > 0 ? "green" : "brightgreen"); const content = `{"schemaVersion":1,"label":"tests","message":"${passed} passed, ${failed} failed, ${skipped} skipped","color":"${color}"}`; let gist; From 3a21bea8cba1a43a2502241f93cd73601c4e6877 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Mon, 22 Jul 2024 18:14:21 +0800 Subject: [PATCH 07/24] Fix readme --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7d99f352b6..3ce67e7d93 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,11 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/aelfblockchain.svg?label=%40aelfblockchain&style=social)](https://twitter.com/aelfblockchain) [![Telegram](https://badgen.net/badge/telegram/join/blue?icon=telegram)](https://t.me/aelfdeveloper) -BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE ------- |--------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ -MASTER | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/eanzhao/59e13bd3823d754542ac98d24b3329b4/raw/master-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) -DEV | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/eanzhao/59e13bd3823d754542ac98d24b3329b4/raw/dev-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) +BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE +------ |--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ +MASTER | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/eanzhao/59e13bd3823d754542ac98d24b3329b4/raw/master-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) +DEV | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/eanzhao/59e13bd3823d754542ac98d24b3329b4/raw/dev-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) + Welcome to AElf's official GitHub repo ! AElf is a blockchain system aiming to achieve scalability and extensibility through the use of side-chains and a flexible design. To support multiple use cases AElf makes it as easy as possible to extend/customize the system by providing easy to use tools and frameworks in order to customize the chains and write smart contracts. AElf will eventually support various languages that will let developers choose the one they are the most comfortable with. From ab9dc69eb903ba7d674822c0e82b435325a8bbf2 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Wed, 24 Jul 2024 11:37:13 +0800 Subject: [PATCH 08/24] Modify test.yml to not use gist. --- .github/workflows/test.yml | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2d4bc4bcc2..b46b65529b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Setup dotnet uses: actions/setup-dotnet@v4 with: @@ -70,10 +71,10 @@ jobs: - name: Get branch name run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV - - name: Update Gist + - name: Prepare Content uses: actions/github-script@v5 with: - github-token: ${{ secrets.GIST_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const fs = require('fs'); const passed = "${{ env.PASSED }}"; @@ -86,18 +87,13 @@ jobs: const color = failed > 0 ? "red" : (skipped > 0 ? "green" : "brightgreen"); const content = `{"schemaVersion":1,"label":"tests","message":"${passed} passed, ${failed} failed, ${skipped} skipped","color":"${color}"}`; - let gist; - try { - gist = await github.rest.gists.get({ gist_id: gistId }); - } catch (error) { - if (error.status !== 404) { - throw error; - } - } - - await github.rest.gists.update({ - gist_id: gistId, - files: { - [filename]: { content } - } - }); \ No newline at end of file + fs.writeFileSync(filename, content); + - name: Commit and Push + run: | + git config --global user.email "action@github.com" + git config --local user.name "GitHub Action" + git checkout feature/use-github-actions + git pull + git add -A + git diff --quiet && git diff --staged --quiet || git commit -m "Update test results" + git push \ No newline at end of file From fb82e5a9eeaaf0bdf5183360c33f067f147da2fa Mon Sep 17 00:00:00 2001 From: eanzhao Date: Wed, 24 Jul 2024 11:44:04 +0800 Subject: [PATCH 09/24] Rename token name. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b46b65529b..0f8818fb1c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -74,7 +74,7 @@ jobs: - name: Prepare Content uses: actions/github-script@v5 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.COMMIT_TOKEN }} script: | const fs = require('fs'); const passed = "${{ env.PASSED }}"; From 9f4fe28e9601b3c4d0614e92ed10b8f198bae2d1 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 24 Jul 2024 04:05:44 +0000 Subject: [PATCH 10/24] Update test results --- feature-use-github-actions-test-results.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 feature-use-github-actions-test-results.json diff --git a/feature-use-github-actions-test-results.json b/feature-use-github-actions-test-results.json new file mode 100644 index 0000000000..6c45d1e29c --- /dev/null +++ b/feature-use-github-actions-test-results.json @@ -0,0 +1 @@ +{"schemaVersion":1,"label":"tests","message":"2306 passed, 0 failed, 23 skipped","color":"green"} \ No newline at end of file From 561285b00b9d7510b80e43b72b7cae1f2449d8cb Mon Sep 17 00:00:00 2001 From: eanzhao Date: Wed, 24 Jul 2024 12:42:05 +0800 Subject: [PATCH 11/24] Fix Commit and Push --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0f8818fb1c..a3e7dda256 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,12 +88,12 @@ jobs: const content = `{"schemaVersion":1,"label":"tests","message":"${passed} passed, ${failed} failed, ${skipped} skipped","color":"${color}"}`; fs.writeFileSync(filename, content); + - name: Commit and Push run: | git config --global user.email "action@github.com" git config --local user.name "GitHub Action" - git checkout feature/use-github-actions - git pull git add -A + git checkout feature/use-github-actions git diff --quiet && git diff --staged --quiet || git commit -m "Update test results" git push \ No newline at end of file From 9e541961b2e54b8f3ef16c24bbe39d63f34f11b0 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Wed, 24 Jul 2024 14:42:55 +0800 Subject: [PATCH 12/24] Update joob Commit and push --- .github/workflows/test.yml | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a3e7dda256..764e538c10 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,12 +88,27 @@ jobs: const content = `{"schemaVersion":1,"label":"tests","message":"${passed} passed, ${failed} failed, ${skipped} skipped","color":"${color}"}`; fs.writeFileSync(filename, content); + echo "FILENAME=$filename" >> $GITHUB_ENV - - name: Commit and Push - run: | - git config --global user.email "action@github.com" - git config --local user.name "GitHub Action" - git add -A - git checkout feature/use-github-actions - git diff --quiet && git diff --staged --quiet || git commit -m "Update test results" - git push \ No newline at end of file + - name: Commit and push + uses: actions/github-script@v3 + with: + github-token: ${{ secrets.COMMIT_TOKEN }} + script: | + const fs = require('fs'); + const path = require('path'); + const filename = process.env.FILENAME; + const filePath = path.join(process.env.GITHUB_WORKSPACE, filename); + const fileContent = fs.readFileSync(filePath, 'utf8'); + + const github = require('@actions/github'); + const octokit = github.getOctokit(process.env.GITHUB_TOKEN); + + await octokit.repos.createOrUpdateFileContents({ + owner: context.repo.owner, + repo: context.repo.repo, + path: filename, + message: `Update ${filename}`, + content: Buffer.from(fileContent).toString('base64'), + branch: 'feature/use-github-actions' + }); \ No newline at end of file From 31d6cd98b232431606afa86490c175b9e51b6959 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Wed, 24 Jul 2024 15:14:08 +0800 Subject: [PATCH 13/24] Only run a few tests to save time --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 764e538c10..c992c7b205 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,7 +37,7 @@ jobs: - name: Run Unit Tests run: | - for testproj in $(find . -name '*Tests.csproj') + for testproj in $(find . -name 'AElf.Contracts.AEDPoSExtension.Demo.Tests') do dotnet test --no-build --no-restore --verbosity normal -l:"trx;LogFileName=TestResults.xml" $testproj || true done From e2fddaa83983d06f6681f2f16365cebcd53917fd Mon Sep 17 00:00:00 2001 From: eanzhao Date: Wed, 24 Jul 2024 15:24:23 +0800 Subject: [PATCH 14/24] Fix Commit and push --- .github/workflows/test.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c992c7b205..1b27a00bb2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,23 +88,21 @@ jobs: const content = `{"schemaVersion":1,"label":"tests","message":"${passed} passed, ${failed} failed, ${skipped} skipped","color":"${color}"}`; fs.writeFileSync(filename, content); - echo "FILENAME=$filename" >> $GITHUB_ENV - name: Commit and push - uses: actions/github-script@v3 + uses: actions/github-script@v5 with: github-token: ${{ secrets.COMMIT_TOKEN }} script: | const fs = require('fs'); const path = require('path'); - const filename = process.env.FILENAME; + let branchName = "${{ env.BRANCH_NAME }}"; + branchName = branchName.replace(/\//g, '-'); + const filename = `${branchName}-test-results.json`; const filePath = path.join(process.env.GITHUB_WORKSPACE, filename); const fileContent = fs.readFileSync(filePath, 'utf8'); - const github = require('@actions/github'); - const octokit = github.getOctokit(process.env.GITHUB_TOKEN); - - await octokit.repos.createOrUpdateFileContents({ + await github.rest.repos.createOrUpdateFileContents({ owner: context.repo.owner, repo: context.repo.repo, path: filename, From 98cd7d243920c1944e6c67e1c4f0b642d53b747a Mon Sep 17 00:00:00 2001 From: eanzhao Date: Fri, 26 Jul 2024 16:18:34 +0800 Subject: [PATCH 15/24] Update test.yml --- .github/workflows/test.yml | 76 +++++++++++++------- feature-use-github-actions-test-results.json | 1 - 2 files changed, 52 insertions(+), 25 deletions(-) delete mode 100644 feature-use-github-actions-test-results.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1b27a00bb2..8353a3f3e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,8 @@ name: Test + +permissions: + contents: write + on: push: branches: @@ -7,9 +11,8 @@ on: - feature/use-github-actions env: - DOTNET_INSTALL_DIR: "./.dotnet" SOLUTION_NAME: "AElf.All.sln" - GIST_ID: "59e13bd3823d754542ac98d24b3329b4" + BRANCH_NAME: "feature/badge" jobs: build-and-test: @@ -55,21 +58,19 @@ jobs: skipped=0 for file in $(find . -name 'TestResults.xml') do - passed_value=$(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@passed" "$file") - passed=$((passed + passed_value)) - failed_value=$(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@failed" "$file") - failed=$((failed + failed_value)) + passed=$((passed + $(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@passed" "$file"))) + failed=$((failed + $(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@failed" "$file"))) + total_value=$(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@total" "$file") executed_value=$(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@executed" "$file") - skipped_value=$((total_value - executed_value)) - skipped=$((skipped + skipped_value)) + skipped=$((skipped + total_value - executed_value)) done echo "PASSED=$passed" >> $GITHUB_ENV echo "FAILED=$failed" >> $GITHUB_ENV echo "SKIPPED=$skipped" >> $GITHUB_ENV - - name: Get branch name - run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV + - name: Set file name + run: echo "FILENAME=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-')-test-results.json" >> $GITHUB_ENV - name: Prepare Content uses: actions/github-script@v5 @@ -81,32 +82,59 @@ jobs: const failed = "${{ env.FAILED }}"; const skipped = "${{ env.SKIPPED }}"; const gistId = "${{ env.GIST_ID }}"; - let branchName = "${{ env.BRANCH_NAME }}"; - branchName = branchName.replace(/\//g, '-'); - const filename = `${branchName}-test-results.json`; const color = failed > 0 ? "red" : (skipped > 0 ? "green" : "brightgreen"); const content = `{"schemaVersion":1,"label":"tests","message":"${passed} passed, ${failed} failed, ${skipped} skipped","color":"${color}"}`; - fs.writeFileSync(filename, content); + fs.writeFileSync("${{ env.FILENAME }}", content); + + - name: Check if file exists + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.COMMIT_TOKEN }} + script: | + let fileExists = false; + try { + const { data } = await github.rest.repos.getContent({ + owner: context.repo.owner, + repo: context.repo.repo, + path: "${{ env.FILENAME }}", + ref: "${{ env.BRANCH_NAME }}", + }); + fileExists = !!data; + } catch (error) { + if (error.status !== 404) { + throw error; + } + } + core.exportVariable('FILE_EXISTS', fileExists); - - name: Commit and push + - name: Create or update file uses: actions/github-script@v5 with: github-token: ${{ secrets.COMMIT_TOKEN }} script: | const fs = require('fs'); const path = require('path'); - let branchName = "${{ env.BRANCH_NAME }}"; - branchName = branchName.replace(/\//g, '-'); - const filename = `${branchName}-test-results.json`; - const filePath = path.join(process.env.GITHUB_WORKSPACE, filename); + const filePath = path.join(process.env.GITHUB_WORKSPACE, "${{ env.FILENAME }}"); const fileContent = fs.readFileSync(filePath, 'utf8'); - await github.rest.repos.createOrUpdateFileContents({ + const params = { owner: context.repo.owner, repo: context.repo.repo, - path: filename, - message: `Update ${filename}`, + path: "${{ env.FILENAME }}", + message: `Update ${{ env.FILENAME }}`, content: Buffer.from(fileContent).toString('base64'), - branch: 'feature/use-github-actions' - }); \ No newline at end of file + branch: "${{ env.BRANCH_NAME }}" + }; + + if (${{ env.FILE_EXISTS }}) { + const { data } = await github.rest.repos.getContent({ + owner: context.repo.owner, + repo: context.repo.repo, + path: "${{ env.FILENAME }}", + ref: "${{ env.BRANCH_NAME }}" + }); + params.sha = data.sha; + } + + await github.rest.repos.createOrUpdateFileContents(params); diff --git a/feature-use-github-actions-test-results.json b/feature-use-github-actions-test-results.json deleted file mode 100644 index 6c45d1e29c..0000000000 --- a/feature-use-github-actions-test-results.json +++ /dev/null @@ -1 +0,0 @@ -{"schemaVersion":1,"label":"tests","message":"2306 passed, 0 failed, 23 skipped","color":"green"} \ No newline at end of file From 4c5247bd11b20115c3ef77c2a44f8a1a944a86ff Mon Sep 17 00:00:00 2001 From: eanzhao Date: Fri, 26 Jul 2024 17:23:19 +0800 Subject: [PATCH 16/24] Add codecov uploading to test.yml --- .github/workflows/test.yml | 17 ++++++++++++++++- README.md | 8 ++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8353a3f3e5..53097431a9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,9 +42,24 @@ jobs: run: | for testproj in $(find . -name 'AElf.Contracts.AEDPoSExtension.Demo.Tests') do - dotnet test --no-build --no-restore --verbosity normal -l:"trx;LogFileName=TestResults.xml" $testproj || true + dotnet test --no-build --no-restore --verbosity normal -l:"trx;LogFileName=TestResults.xml" --collect:"XPlat Code Coverage" $testproj || true done + - name: Install ReportGenerator tool + run: dotnet tool install --global dotnet-reportgenerator-globaltool + + - name: Create Code Coverage Report + run: | + reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:./coverage/reports" -reporttypes:"Cobertura" + echo "COVERAGE_FILE=./coverage/reports/Cobertura.xml" >> $GITHUB_ENV + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ${{ env.COVERAGE_FILE }} + fail_ci_if_error: true + - name: Install xmlstarlet run: | sudo apt-get update diff --git a/README.md b/README.md index 3ce67e7d93..321a841d5e 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/aelfblockchain.svg?label=%40aelfblockchain&style=social)](https://twitter.com/aelfblockchain) [![Telegram](https://badgen.net/badge/telegram/join/blue?icon=telegram)](https://t.me/aelfdeveloper) -BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE ------- |--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ -MASTER | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/eanzhao/59e13bd3823d754542ac98d24b3329b4/raw/master-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) -DEV | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/eanzhao/59e13bd3823d754542ac98d24b3329b4/raw/dev-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) +BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE +------ |--------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ +MASTER | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/eanzhao/AElf/feature/badge/main-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) +DEV | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/eanzhao/AElf/feature/badge/dev-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) Welcome to AElf's official GitHub repo ! From b2cf1db5df4b9c93787ede84851a738d85d1b06a Mon Sep 17 00:00:00 2001 From: eanzhao Date: Mon, 29 Jul 2024 11:51:52 +0800 Subject: [PATCH 17/24] Run all tests --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 53097431a9..faa573b0da 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,7 @@ jobs: - name: Run Unit Tests run: | - for testproj in $(find . -name 'AElf.Contracts.AEDPoSExtension.Demo.Tests') + for testproj in $(find . -name '*Tests') do dotnet test --no-build --no-restore --verbosity normal -l:"trx;LogFileName=TestResults.xml" --collect:"XPlat Code Coverage" $testproj || true done From fa8b1bf5242082babbf986117c45aa11a6d2ab19 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Mon, 29 Jul 2024 11:54:02 +0800 Subject: [PATCH 18/24] Update readme for current repo --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 321a841d5e..0750361e6f 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/aelfblockchain.svg?label=%40aelfblockchain&style=social)](https://twitter.com/aelfblockchain) [![Telegram](https://badgen.net/badge/telegram/join/blue?icon=telegram)](https://t.me/aelfdeveloper) -BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE ------- |--------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ -MASTER | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/eanzhao/AElf/feature/badge/main-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) -DEV | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/eanzhao/AElf/feature/badge/dev-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) +BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE +------ |----------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ +MASTER | ![GitHub Workflow Build Status](https://github.com/eanzhao/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/eanzhao/AElf/feature/badge/main-test-results.json) | [![codecov](https://codecov.io/gh/eanzhao/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/eanzhao/AElf) +DEV | ![GitHub Workflow Build Status](https://github.com/eanzhao/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/eanzhao/AElf/feature/badge/dev-test-results.json) | [![codecov](https://codecov.io/gh/eanzhao/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/eanzhao/AElf) Welcome to AElf's official GitHub repo ! From 166c09a80fdc7e3746db38d6849ea0e3ee3da00c Mon Sep 17 00:00:00 2001 From: eanzhao Date: Mon, 29 Jul 2024 12:25:44 +0800 Subject: [PATCH 19/24] Fix readme --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eece96feda..c3c72f0de1 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/aelfblockchain.svg?label=%40aelfblockchain&style=social)](https://twitter.com/aelfblockchain) [![Telegram](https://badgen.net/badge/telegram/join/blue?icon=telegram)](https://t.me/aelfdeveloper) -BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE ------- |----------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ -MASTER | ![GitHub Workflow Build Status](https://github.com/eanzhao/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/eanzhao/AElf/feature/badge/main-test-results.json) | [![codecov](https://codecov.io/gh/eanzhao/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/eanzhao/AElf) -DEV | ![GitHub Workflow Build Status](https://github.com/eanzhao/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/eanzhao/AElf/feature/badge/dev-test-results.json) | [![codecov](https://codecov.io/gh/eanzhao/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/eanzhao/AElf) +BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE +------ |----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ +MASTER | ![GitHub Workflow Build Status](https://github.com/eanzhao/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/eanzhao/AElf/feature/badge/master-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) +DEV | ![GitHub Workflow Build Status](https://github.com/eanzhao/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/eanzhao/AElf/feature/badge/dev-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) Welcome to AElf's official GitHub repo ! From 99bb4f44cc0047bb7a07fbeeb4b566e539e7eec2 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Mon, 29 Jul 2024 12:34:06 +0800 Subject: [PATCH 20/24] Fix myget badge. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c3c72f0de1..09d8f949a9 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![GitHub closed issues](https://img.shields.io/github/issues-closed/aelfproject/aelf.svg)](https://app.gitkraken.com/glo/board/XKsOZJarBgAPseno) [![lisence](https://img.shields.io/github/license/AElfProject/AElf.svg)](https://github.com/AElfProject/AElf/blob/dev/LICENSE) [![Nuget](https://img.shields.io/nuget/v/AElf.OS.svg)](https://www.nuget.org/packages?q=aelf) -[![MyGet (with prereleases)](https://img.shields.io/myget/aelf-project-dev/vpre/aelf.os.svg?label=myget)](https://www.myget.org/gallery/aelf-project-dev) +[![MyGet (with prereleases)](https://img.shields.io/myget/aelf-project/vpre/aelf.os.svg?label=myget)](https://www.myget.org/gallery/aelf-project) [![Twitter Follow](https://img.shields.io/twitter/follow/aelfblockchain.svg?label=%40aelfblockchain&style=social)](https://twitter.com/aelfblockchain) [![Telegram](https://badgen.net/badge/telegram/join/blue?icon=telegram)](https://t.me/aelfdeveloper) From 88cdb14c2faa7d8af9f878f42cc1dd2d2edbdf45 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Mon, 29 Jul 2024 17:41:57 +0800 Subject: [PATCH 21/24] Add continue-on-error config to test.yml --- .github/workflows/test.yml | 2 ++ README.md | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index faa573b0da..e882dd867f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,6 +44,7 @@ jobs: do dotnet test --no-build --no-restore --verbosity normal -l:"trx;LogFileName=TestResults.xml" --collect:"XPlat Code Coverage" $testproj || true done + continue-on-error: true - name: Install ReportGenerator tool run: dotnet tool install --global dotnet-reportgenerator-globaltool @@ -59,6 +60,7 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} file: ${{ env.COVERAGE_FILE }} fail_ci_if_error: true + continue-on-error: true - name: Install xmlstarlet run: | diff --git a/README.md b/README.md index 09d8f949a9..2f975b81a8 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/aelfblockchain.svg?label=%40aelfblockchain&style=social)](https://twitter.com/aelfblockchain) [![Telegram](https://badgen.net/badge/telegram/join/blue?icon=telegram)](https://t.me/aelfdeveloper) -BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE ------- |----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ -MASTER | ![GitHub Workflow Build Status](https://github.com/eanzhao/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/eanzhao/AElf/feature/badge/master-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) -DEV | ![GitHub Workflow Build Status](https://github.com/eanzhao/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/eanzhao/AElf/feature/badge/dev-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) +BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE +------ |--------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ +MASTER | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/AElfProject/AElf/feature/badge/master-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) +DEV | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/AElfProject/AElf/feature/badge/dev-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) Welcome to AElf's official GitHub repo ! From fb5359a5625b8f897d59dbc4d3610d4f2d3f89b0 Mon Sep 17 00:00:00 2001 From: "yongen.loong" Date: Thu, 1 Aug 2024 10:32:38 +0800 Subject: [PATCH 22/24] docs: readme --- README.md | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 616aa7f841..db7534e416 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# AElf - A Decentralized Cloud Computing Blockchain Network +# aelf - A Decentralized Cloud Computing Blockchain Network [![GitHub closed issues](https://img.shields.io/github/issues-closed/aelfproject/aelf.svg)](https://app.gitkraken.com/glo/board/XKsOZJarBgAPseno) [![lisence](https://img.shields.io/github/license/AElfProject/AElf.svg)](https://github.com/AElfProject/AElf/blob/dev/LICENSE) @@ -12,34 +12,29 @@ MASTER | [![Build Status](https://dev.azure.com/AElfProject/AElf/_apis/build/status/AElfProject.AElf?branchName=master)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=master) | [![Test Status](https://img.shields.io/azure-devops/tests/AElfProject/AElf/1/master)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=master) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) DEV | [![Build Status](https://dev.azure.com/AElfProject/AElf/_apis/build/status/AElfProject.AElf?branchName=dev)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=dev) | [![Test Status](https://img.shields.io/azure-devops/tests/AElfProject/AElf/1/dev)](https://dev.azure.com/AElfProject/AElf/_build/latest?definitionId=1&branchName=dev) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) -Welcome to AElf's official GitHub repo ! +Welcome to aelf's official GitHub repo ! -AElf is a blockchain system aiming to achieve scalability and extensibility through the use of side-chains and a flexible design. To support multiple use cases AElf makes it as easy as possible to extend/customize the system by providing easy to use tools and frameworks in order to customize the chains and write smart contracts. AElf will eventually support various languages that will let developers choose the one they are the most comfortable with. +aelf is a blockchain system aiming to achieve scalability and extensibility through the use of side-chains and a flexible design. To support multiple use cases aelf makes it as easy as possible to extend/customize the system by providing easy to use tools and frameworks in order to customize the chains and write smart contracts. aelf will eventually support various languages that will let developers choose the one they are the most comfortable with. For more information you can follow these links: -* [Official website](https://aelf.io) -* [Documentation](https://docs.aelf.io/en/latest/) - * [Environment setup](https://docs.aelf.io/en/latest/getting_started/development-environment/index.html) - * [Running a node](https://docs.aelf.io/en/latest/getting_started/development-environment/node.html) - * [Smart contract development](https://docs.aelf.io/en/latest/getting_started/smart_contracts/index.html) - * [Web Api](https://docs.aelf.io/en/latest/reference/web-api/web-api.html) - * [Testnet](https://docs.aelf.io/en/latest/tutorials/testnet.html) -* [White Paper](https://aelf.com/gridcn/aelf_whitepaper_v1.7_en.pdf) - -This repository contains the code that runs an AElf node, you'll find bellow other important repositories in the AElf +* [Official website](https://aelf.com/) +* [Documentation](https://docs.aelf.com/) +* [White Paper](https://docs.aelf.com/resources/whitepaper-2/) + +This repository contains the code that runs an aelf node, you'll find below other important repositories in the aelf ecosystem: TOOL/LIBRARY | description -------------|------------- -[aelf-sdk.js](https://docs.aelf.io/en/latest/reference/chain-sdk/javascript/js-sdk.html) | Javascript development kit for interacting with an AElf node, useful for dApp developers. -[aelf-command](https://docs.aelf.io/en/latest/reference/cli/methods.html) | CLI tool for interacting with an AElf node and wallet. -[aelf-boilerplate](https://aelf-boilerplate-docs.readthedocs.io/en/latest/) | framework for smart contract and dApp development. +[aelf-sdk.js](https://docs.aelf.com/tools/chain-sdk/javascript-sdk/) | Javascript development kit for interacting with an aelf node, useful for dApp developers. +[aelf-command](https://docs.aelf.com/tools/aelf-cli/introduction/) | CLI tool for interacting with an aelf node and wallet. +[aelf-contract-templates](https://docs.aelf.com/tools/smart-contract-templates/developing-smart-contracts/) | framework for smart contract and dApp development. ## Getting Started ### This repository -This repo is where you will find the code that can use to run an AElf node. It also contains a **tests** folder that centralizes all the unit tests. +This repo is where you will find the code that can use to run an aelf node. It also contains a **tests** folder that centralizes all the unit tests. ### Documentation @@ -62,11 +57,11 @@ We currently only use GitHub for tracking issues, feature request and pull reque If you think you have found a bug in our system feel free to open a GitHub issue, but first: - check with GitHub's search engine that the bug doesn't already exist. -- in the request give as much information as possible such as: the OS, the version of AElf, how to reproduce... +- in the request give as much information as possible such as: the OS, the version of aelf, how to reproduce... #### Missing feature -We also use the GitHub issue tracker for features. If you think that some piece of functionality is missing in AElf, you can open an issue with the following in mind: +We also use the GitHub issue tracker for features. If you think that some piece of functionality is missing in aelf, you can open an issue with the following in mind: - check for similare feature requests already open. - provide as much detail and context as possible. - be as convincing as possible as to why we need this feature and how everybody can benefit from it. @@ -83,8 +78,8 @@ When you are ready for a review by the core team, just remove ```[WIP]``` from y ## Versioning -We use Semantic Versioning (SemVer) for versioning, if you're intereted in closely following AElf's developement please check out the [SemVer docs](https://semver.org/). +We use Semantic Versioning (SemVer) for versioning, if you're intereted in closely following aelf's developement please check out the [SemVer docs](https://semver.org/). ## License -AElf is licenced under [MIT](https://github.com/AElfProject/AElf/blob/dev/LICENSE) +aelf is licenced under [MIT](https://github.com/AElfProject/AElf/blob/dev/LICENSE) From cc71fbe3b174eb6a8b369e21ded14b53ae50e45e Mon Sep 17 00:00:00 2001 From: yongenaelf <132553186+yongenaelf@users.noreply.github.com> Date: Tue, 6 Aug 2024 14:41:04 +0800 Subject: [PATCH 23/24] docs: link to aelf-docs --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index db7534e416..403a849eca 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,7 @@ This repo is where you will find the code that can use to run an aelf node. It a ### Documentation -We strongly recommend you follow official documentation that will guide you through installing dependencies and running the node, -these two guides will get you started: -* [Environment setup](https://docs.aelf.io/en/latest/getting_started/development-environment/index.html) -* [Running a node](https://docs.aelf.io/en/latest/getting_started/development-environment/node.html) +We strongly recommend you follow [official documentation](https://docs.aelf.com/) that will guide you through installing dependencies and running the node. ## Contributing From 561603fd367ede1e0cfb146215f28fb5c3f43a71 Mon Sep 17 00:00:00 2001 From: eanzhao Date: Tue, 6 Aug 2024 20:11:13 +0800 Subject: [PATCH 24/24] Tune impl of test workflow --- .github/workflows/test.yml | 147 ++----------------------------------- README.md | 8 +- 2 files changed, 10 insertions(+), 145 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e882dd867f..a0076d5ca5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,4 @@ name: Test - -permissions: - contents: write - on: push: branches: @@ -10,10 +6,6 @@ on: - master - feature/use-github-actions -env: - SOLUTION_NAME: "AElf.All.sln" - BRANCH_NAME: "feature/badge" - jobs: build-and-test: runs-on: ubuntu-latest @@ -21,137 +13,10 @@ jobs: pull-requests: write contents: write steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup dotnet - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '8.0' - - - name: Download AElf build tools - run: bash scripts/download_binary.sh - - - name: Install Protobuf - run: sudo apt-get update && sudo apt-get install -y protobuf-compiler - - - run: dotnet restore ${{ env.SOLUTION_NAME }} - - run: dotnet build --no-restore ${{ env.SOLUTION_NAME }} - - - name: Run Unit Tests - run: | - for testproj in $(find . -name '*Tests') - do - dotnet test --no-build --no-restore --verbosity normal -l:"trx;LogFileName=TestResults.xml" --collect:"XPlat Code Coverage" $testproj || true - done - continue-on-error: true - - - name: Install ReportGenerator tool - run: dotnet tool install --global dotnet-reportgenerator-globaltool - - - name: Create Code Coverage Report - run: | - reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:./coverage/reports" -reporttypes:"Cobertura" - echo "COVERAGE_FILE=./coverage/reports/Cobertura.xml" >> $GITHUB_ENV - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ${{ env.COVERAGE_FILE }} - fail_ci_if_error: true - continue-on-error: true - - - name: Install xmlstarlet - run: | - sudo apt-get update - sudo apt-get install -y xmlstarlet - - - name: Extract Test Counts - id: test_counts - run: | - passed=0 - failed=0 - skipped=0 - for file in $(find . -name 'TestResults.xml') - do - passed=$((passed + $(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@passed" "$file"))) - failed=$((failed + $(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@failed" "$file"))) - - total_value=$(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@total" "$file") - executed_value=$(xmlstarlet sel -N x="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" -t -v "/x:TestRun/x:ResultSummary/x:Counters/@executed" "$file") - skipped=$((skipped + total_value - executed_value)) - done - echo "PASSED=$passed" >> $GITHUB_ENV - echo "FAILED=$failed" >> $GITHUB_ENV - echo "SKIPPED=$skipped" >> $GITHUB_ENV - - - name: Set file name - run: echo "FILENAME=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-')-test-results.json" >> $GITHUB_ENV - - - name: Prepare Content - uses: actions/github-script@v5 + - name: Run dotnet ci action + uses: AElfProject/dotnet-ci-action@v0.0.1 with: - github-token: ${{ secrets.COMMIT_TOKEN }} - script: | - const fs = require('fs'); - const passed = "${{ env.PASSED }}"; - const failed = "${{ env.FAILED }}"; - const skipped = "${{ env.SKIPPED }}"; - const gistId = "${{ env.GIST_ID }}"; - const color = failed > 0 ? "red" : (skipped > 0 ? "green" : "brightgreen"); - const content = `{"schemaVersion":1,"label":"tests","message":"${passed} passed, ${failed} failed, ${skipped} skipped","color":"${color}"}`; - - fs.writeFileSync("${{ env.FILENAME }}", content); - - - name: Check if file exists - uses: actions/github-script@v5 - with: - github-token: ${{ secrets.COMMIT_TOKEN }} - script: | - let fileExists = false; - try { - const { data } = await github.rest.repos.getContent({ - owner: context.repo.owner, - repo: context.repo.repo, - path: "${{ env.FILENAME }}", - ref: "${{ env.BRANCH_NAME }}", - }); - fileExists = !!data; - } catch (error) { - if (error.status !== 404) { - throw error; - } - } - core.exportVariable('FILE_EXISTS', fileExists); - - - name: Create or update file - uses: actions/github-script@v5 - with: - github-token: ${{ secrets.COMMIT_TOKEN }} - script: | - const fs = require('fs'); - const path = require('path'); - const filePath = path.join(process.env.GITHUB_WORKSPACE, "${{ env.FILENAME }}"); - const fileContent = fs.readFileSync(filePath, 'utf8'); - - const params = { - owner: context.repo.owner, - repo: context.repo.repo, - path: "${{ env.FILENAME }}", - message: `Update ${{ env.FILENAME }}`, - content: Buffer.from(fileContent).toString('base64'), - branch: "${{ env.BRANCH_NAME }}" - }; - - if (${{ env.FILE_EXISTS }}) { - const { data } = await github.rest.repos.getContent({ - owner: context.repo.owner, - repo: context.repo.repo, - path: "${{ env.FILENAME }}", - ref: "${{ env.BRANCH_NAME }}" - }); - params.sha = data.sha; - } - - await github.rest.repos.createOrUpdateFileContents(params); + commit-token: ${{ secrets.COMMIT_TOKEN }} + codecov-token: ${{ secrets.CODECOV_TOKEN }} + branch-name: "feature/badge-json" + solution-name: "AElf.All.sln" \ No newline at end of file diff --git a/README.md b/README.md index 2f975b81a8..7ad7cb7060 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/aelfblockchain.svg?label=%40aelfblockchain&style=social)](https://twitter.com/aelfblockchain) [![Telegram](https://badgen.net/badge/telegram/join/blue?icon=telegram)](https://t.me/aelfdeveloper) -BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE ------- |--------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ -MASTER | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/AElfProject/AElf/feature/badge/master-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) -DEV | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/AElfProject/AElf/feature/badge/dev-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) +BRANCH | GITHUB ACTIONS BUILD | TESTS | CODE COVERAGE +------ |--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ +MASTER | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=master) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/AElfProject/AElf/feature/badge-json/master-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/master/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) +DEV | ![GitHub Workflow Build Status](https://github.com/AElfProject/AElf/actions/workflows/build.yml/badge.svg?branch=dev) | ![GitHub Workflow Test Status](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/AElfProject/AElf/feature/badge-json/dev-test-results.json) | [![codecov](https://codecov.io/gh/AElfProject/AElf/branch/dev/graph/badge.svg)](https://codecov.io/gh/AElfProject/AElf) Welcome to AElf's official GitHub repo !