Skip to content
Merged
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
31 changes: 31 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
pull_request:
branches:
- develop
- main

jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Init
run: npm ci
- name: Run Coverage
run: (npm run coverage 2>&1) | tee /tmp/coverage.out | cat
- name: Extract coverage
run: echo "COVERAGE=$(cat /tmp/coverage.out | grep "Global test coverage")" >> $GITHUB_ENV
- name: Display coverage in Github PR checks
# See https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-run
# and https://www.kenmuse.com/blog/creating-github-checks/
env:
GH_TOKEN: ${{ github.token }}
run: | # TODO: Set "failure" conclusion if coverage is too low
curl -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/check-runs \
-d '{"name":"Coverage ratio", "head_sha":"${{ github.event.pull_request.head.sha }}", "status":"completed", "conclusion":"success", "output":{"title":"${{env.COVERAGE}}", "summary":""}}'

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## vNext
- Display coverage in Github PR checks. (#26)
- Add integration test suite. (#21)
- Add unit test suite. (#20)

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ A subgraph to explore the PoCo smarcontracts

[CHANGELOG](./CHANGELOG.md)

# Setup coverage⁠

> In order for Matchstick to check which handlers are being run, those handlers need to be exported from the test file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice


Check how to export handlers with [Matchstick - Test Coverage documentation](https://thegraph.com/docs/en/subgraphs/developing/creating/unit-testing-framework/#test-coverage).

> [!NOTE]
> Since Matchstick code coverage is in very early stages, Matchstick cannot check for branch coverage, but rely on the assertion that a given handler has been called.


## local dev

run local services:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"prepare": "husky",
"codegen": "graph codegen subgraph.template.yaml",
"test": "npm run codegen && graph test",
"coverage": "npm run codegen && graph test -- -c",
"test-docker": "npm run codegen && docker run -it --rm -v $(pwd):/matchstick/subgraph rainprotocol/matchstick:main",
"build": "npm run codegen && cp subgraph.template.yaml subgraph.yaml && graph build --network ${NETWORK_NAME:-bellecour}",
"create": "graph create ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020}",
Expand Down
4 changes: 3 additions & 1 deletion test/Modules/IexecCategoryManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { ethereum } from '@graphprotocol/graph-ts';
import { assert, describe, newTypedMockEventWithParams, test } from 'matchstick-as/assembly/index';
import { CreateCategory } from '../../generated/Core/IexecInterfaceToken';
import { handleCreateCategory } from '../../src/Modules/IexecCategoryManager';
import { handleCreateCategory } from '../../src/Modules';

describe('IexecCategoryManager', () => {
test('Should handle CreateCategory', () => {
Expand Down Expand Up @@ -33,3 +33,5 @@ describe('IexecCategoryManager', () => {
});
});
});

export { handleCreateCategory };
2 changes: 2 additions & 0 deletions test/Modules/IexecPoco.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ describe('IexecPoco', () => {
assert.fieldEquals('Transaction', transactionId, 'id', transactionId);
});
});

export { handleDealSponsored };
Loading