| 1 | name: Code Coverage |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: ["main", "features/**"] |
| 6 | pull_request: |
| 7 | branches: ["main", "features/**"] |
| 8 | |
| 9 | permissions: {} |
| 10 | |
| 11 | concurrency: |
| 12 | group: ${{ github.workflow }}-${{ github.ref }} |
| 13 | cancel-in-progress: true |
| 14 | |
| 15 | env: |
| 16 | CARGO_TERM_COLOR: always |
| 17 | # without matrix_sdk=trace, expressions in `trace!` fields are not evaluated |
| 18 | # when the `trace!` statement is hit, and thus not covered |
| 19 | RUST_LOG: info,matrix_sdk=trace |
| 20 | |
| 21 | jobs: |
| 22 | xtask: |
| 23 | uses: ./.github/workflows/xtask.yml |
| 24 | |
| 25 | code_coverage: |
| 26 | name: Code Coverage |
| 27 | needs: xtask |
| 28 | runs-on: "ubuntu-latest" |
| 29 | permissions: |
| 30 | contents: read |
| 31 | id-token: write |
| 32 | |
| 33 | # run several docker containers with the same networking stack so the hostname 'synapse' |
| 34 | # maps to the synapse container, etc. |
| 35 | services: |
| 36 | # tests need a synapse: this is a service and not michaelkaye/setup-matrix-synapse@main as the |
| 37 | # latter does not provide networking for services to communicate with it. |
| 38 | synapse: |
| 39 | image: ghcr.io/matrix-org/synapse-service:v1.117.0 # keep in sync with ./ci.yml |
| 40 | env: |
| 41 | SYNAPSE_COMPLEMENT_DATABASE: sqlite |
| 42 | SERVER_NAME: synapse |
| 43 | ports: |
| 44 | - 8008:8008 |
| 45 | |
| 46 | steps: |
| 47 | # This CI workflow can run into space issue, so we're cleaning up some |
| 48 | # space here. |
| 49 | - name: Create some more space |
| 50 | run: | |
| 51 | echo "Disk space before cleanup" |
| 52 | df -h |
| 53 | |
| 54 | cd /opt |
| 55 | find . -maxdepth 1 -mindepth 1 '!' -path ./containerd '!' -path ./actionarchivecache '!' -path ./runner '!' -path ./runner-cache -exec rm -rf '{}' ';' |
| 56 | rm -rf /opt/hostedtoolcache |
| 57 | |
| 58 | # Get rid of binaries and libs we're not interested in. |
| 59 | sudo rm -rf \ |
| 60 | /usr/local/julia* \ |
| 61 | /usr/local/aws* |
| 62 | |
| 63 | sudo rm -rf \ |
| 64 | /usr/local/bin/minikube \ |
| 65 | /usr/local/bin/node \ |
| 66 | /usr/local/bin/stack \ |
| 67 | /usr/local/bin/bicep \ |
| 68 | /usr/local/bin/pulumi* \ |
| 69 | /usr/local/bin/helm \ |
| 70 | /usr/local/bin/azcopy \ |
| 71 | /usr/local/bin/packer \ |
| 72 | /usr/local/bin/cmake-gui \ |
| 73 | /usr/local/bin/cpack |
| 74 | |
| 75 | sudo rm -rf \ |
| 76 | /usr/local/share/powershell \ |
| 77 | /usr/local/share/chromium |
| 78 | |
| 79 | sudo rm -rf /usr/local/lib/android |
| 80 | |
| 81 | echo "::group::/usr/local/bin/*" |
| 82 | du -hsc /usr/local/bin/* | sort -h |
| 83 | echo "::endgroup::" |
| 84 | |
| 85 | echo "::group::/usr/local/share/*" |
| 86 | du -hsc /usr/local/share/* | sort -h |
| 87 | echo "::endgroup::" |
| 88 | |
| 89 | echo "::group::/usr/local/*" |
| 90 | du -hsc /usr/local/* | sort -h |
| 91 | echo "::endgroup::" |
| 92 | |
| 93 | echo "::group::/usr/local/lib/*" |
| 94 | du -hsc /usr/local/lib/* | sort -h |
| 95 | echo "::endgroup::" |
| 96 | |
| 97 | echo "::group::/opt/*" |
| 98 | du -hsc /opt/* | sort -h |
| 99 | echo "::endgroup::" |
| 100 | |
| 101 | echo "Disk space after cleanup" |
| 102 | df -h |
| 103 | |
| 104 | - name: Checkout repository |
| 105 | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 106 | with: |
| 107 | ref: ${{ github.event.pull_request.head.sha }} |
| 108 | persist-credentials: false |
| 109 | |
| 110 | - name: Install libsqlite |
| 111 | run: | |
| 112 | sudo apt-get update |
| 113 | sudo apt-get install libsqlite3-dev |
| 114 | sudo apt-get clean |
| 115 | sudo rm -rf /var/lib/apt/lists/* |
| 116 | |
| 117 | - name: Install Rust |
| 118 | uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1 |
| 119 | with: |
| 120 | toolchain: stable |
| 121 | |
| 122 | # Cargo config can screw with caching and is only used for alias config |
| 123 | # and extra lints, which we don't care about here |
| 124 | - name: Delete cargo config |
| 125 | run: rm .cargo/config.toml |
| 126 | |
| 127 | - name: Load cache |
| 128 | uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 |
| 129 | with: |
| 130 | prefix-key: "coverage" |
| 131 | save-if: ${{ github.ref == 'refs/heads/main' }} |
| 132 | |
| 133 | - name: Install nextest and llvm-cov |
| 134 | uses: taiki-e/install-action@b550161ef8a7bc4f2a671c0b03a18ac9ccedea1e # v 2.79.1 |
| 135 | with: |
| 136 | tool: nextest,cargo-llvm-cov |
| 137 | |
| 138 | - name: Get xtask |
| 139 | uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| 140 | with: |
| 141 | path: target/debug/xtask |
| 142 | key: "${{ needs.xtask.outputs.cachekey-linux }}" |
| 143 | fail-on-cache-miss: true |
| 144 | |
| 145 | - name: Check total disk space before running |
| 146 | run: | |
| 147 | df -h |
| 148 | |
| 149 | - name: Create the coverage report |
| 150 | run: | |
| 151 | target/debug/xtask ci coverage -o codecov |
| 152 | env: |
| 153 | CARGO_PROFILE_COV_INHERITS: 'dev' |
| 154 | CARGO_PROFILE_COV_DEBUG: 1 |
| 155 | HOMESERVER_URL: "http://localhost:8008" |
| 156 | HOMESERVER_DOMAIN: "synapse" |
| 157 | |
| 158 | - name: Upload coverage to Codecov |
| 159 | uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 |
| 160 | with: |
| 161 | use_oidc: true |
| 162 | |
| 163 | - name: Upload test results to Codecov |
| 164 | if: ${{ !cancelled() }} |
| 165 | uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 |
| 166 | with: |
| 167 | use_oidc: true |
| 168 | report_type: "test_results" |