diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..e5e4b08 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: + # Enable version updates for github-actions + - package-ecosystem: "github-actions" + # Look for a `Dockerfile` in the `root` directory + directory: "/" + # Check for updates once a month + schedule: + interval: "monthly" \ No newline at end of file diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml new file mode 100644 index 0000000..dad27d5 --- /dev/null +++ b/.github/workflows/quality.yml @@ -0,0 +1,67 @@ +name: Quality Check +on: + pull_request: + branches: + - "**" + +permissions: + contents: read + pull-requests: write + +jobs: + format: + name: Check Code Formatting + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + - name: Check formatting + run: cargo fmt -- --check + test: + name: Test and coverage + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + rustflags: "-A warnings" + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Install Protoc + uses: arduino/setup-protoc@v3 + - name: Run tests with coverage + run: | + RPC_URLS=${{ secrets.RPC_URLS }} cargo llvm-cov --release --workspace --summary-only --remap-path-prefix --json > coverage.json + - name: Generate coverage summary + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + run: | + # Read JSON and convert it to Markdown table using jq + echo "
Coverage report" > coverage.md + echo "" >> coverage.md + echo "Filename | Lines Covered (%) | Functions Covered (%) " >> coverage.md + echo "--- | --- | --- " >> coverage.md + jq -r ' + .data[0].files as $files | $files[] | + [ + .filename, + (.summary.lines.percent * 100|round / 100), + (.summary.functions.percent * 100 |round / 100) + ] | + @tsv | + gsub("\t"; " | ") + ' coverage.json >> coverage.md + echo "" >> coverage.md + echo "
" >> coverage.md + - name: Add reactions + uses: peter-evans/create-or-update-comment@v4 + with: + body-path: coverage.md + issue-number: ${{ github.event.pull_request.number }} + comment-author: "github-actions[bot]"