|
| 1 | +name: Code Coverage |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: ["opened", "synchronize", "ready_for_review"] |
| 6 | + |
| 7 | + workflow_dispatch: |
| 8 | + push: |
| 9 | + branches: [master] |
| 10 | + |
| 11 | +jobs: |
| 12 | + check-coverage: |
| 13 | + name: check-coverage |
| 14 | + runs-on: ubuntu-latest |
| 15 | + container: |
| 16 | + image: xd009642/tarpaulin:develop |
| 17 | + options: --security-opt seccomp=unconfined |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v3 |
| 21 | + |
| 22 | + - name: Caching |
| 23 | + uses: Swatinem/rust-cache@v2 |
| 24 | + |
| 25 | + - name: Generate code coverage |
| 26 | + run: | |
| 27 | + cargo tarpaulin --skip-clean --ignore-tests --frozen --engine llvm --out xml --exclude-files contracts/*/src/error.rs --exclude-files contracts/*/src/bin/* |
| 28 | +
|
| 29 | + - name: Produce the coverage report |
| 30 | + uses: insightsengineering/coverage-action@v2 |
| 31 | + with: |
| 32 | + # Path to the Cobertura XML report. |
| 33 | + path: ./cobertura.xml |
| 34 | + # Minimum total coverage, if you want to the |
| 35 | + # workflow to enforce it as a standard. |
| 36 | + # This has no effect if the `fail` arg is set to `false`. |
| 37 | + threshold: 90 |
| 38 | + # Fail the workflow if the minimum code coverage |
| 39 | + # reuqirements are not satisfied. |
| 40 | + fail: false |
| 41 | + # Publish the rendered output as a PR comment |
| 42 | + publish: true |
| 43 | + # Create a coverage diff report. |
| 44 | + diff: true |
| 45 | + # Branch to diff against. |
| 46 | + # Compare the current coverage to the coverage |
| 47 | + # determined on this branch. |
| 48 | + diff-branch: master |
| 49 | + # This is where the coverage reports for the |
| 50 | + # `diff-branch` are stored. |
| 51 | + # Branch is created if it doesn't already exist'. |
| 52 | + # diff-storage: _xml_coverage_reports |
| 53 | + coverage-summary-title: "Code Coverage Summary" |
| 54 | + new-uncovered-statements-failure: true |
| 55 | + # new-uncovered-statements-failure: true |
| 56 | + |
| 57 | + simulate-tests: |
| 58 | + runs-on: ubuntu-latest |
| 59 | + steps: |
| 60 | + - name: Cancel Previous Runs |
| 61 | + |
| 62 | + |
| 63 | + - name: Checkout |
| 64 | + uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - name: Setup Nodejs |
| 67 | + uses: actions/setup-node@v3 |
| 68 | + |
| 69 | + - name: Get yarn cache directory path |
| 70 | + id: yarn-cache-dir-path |
| 71 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 72 | + - uses: actions/cache@v2 |
| 73 | + id: yarn-cache |
| 74 | + with: |
| 75 | + path: | |
| 76 | + ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 77 | + ./simulate-tests/node_modules/ |
| 78 | + key: ${{ runner.os }}-yarn-${{ hashFiles('./simulate-tests/yarn.lock') }} |
| 79 | + restore-keys: | |
| 80 | + ${{ runner.os }}-yarn- |
| 81 | + - name: Install Dependencies |
| 82 | + if: steps.yarn-cache.outputs.cache-hit != 'true' |
| 83 | + run: | |
| 84 | + npm install -g yarn |
| 85 | + cd simulate-tests |
| 86 | + yarn |
| 87 | +
|
| 88 | + - name: Run test |
| 89 | + run: | |
| 90 | + cd simulate-tests |
| 91 | + cp .env.example .env |
| 92 | + yarn test |
0 commit comments