name: Code Coverage on: push: branches: [main] pull_request: branches: [main] permissions: {} concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: CARGO_TERM_COLOR: always # without matrix_sdk=trace, expressions in `trace!` fields are not evaluated # when the `trace!` statement is hit, and thus not covered RUST_LOG: info,matrix_sdk=trace jobs: xtask: uses: ./.github/workflows/xtask.yml code_coverage: name: Code Coverage needs: xtask runs-on: "ubuntu-latest" permissions: contents: read id-token: write # run several docker containers with the same networking stack so the hostname 'synapse' # maps to the synapse container, etc. services: # tests need a synapse: this is a service and not michaelkaye/setup-matrix-synapse@main as the # latter does not provide networking for services to communicate with it. synapse: image: ghcr.io/matrix-org/synapse-service:v1.117.0 # keep in sync with ./ci.yml env: SYNAPSE_COMPLEMENT_DATABASE: sqlite SERVER_NAME: synapse ports: - 8008:8008 steps: # This CI workflow can run into space issue, so we're cleaning up some # space here. - name: Create some more space run: | echo "Disk space before cleanup" df -h cd /opt find . -maxdepth 1 -mindepth 1 '!' -path ./containerd '!' -path ./actionarchivecache '!' -path ./runner '!' -path ./runner-cache -exec rm -rf '{}' ';' rm -rf /opt/hostedtoolcache # Get rid of binaries and libs we're not interested in. sudo rm -rf \ /usr/local/julia* \ /usr/local/aws* sudo rm -rf \ /usr/local/bin/minikube \ /usr/local/bin/node \ /usr/local/bin/stack \ /usr/local/bin/bicep \ /usr/local/bin/pulumi* \ /usr/local/bin/helm \ /usr/local/bin/azcopy \ /usr/local/bin/packer \ /usr/local/bin/cmake-gui \ /usr/local/bin/cpack sudo rm -rf \ /usr/local/share/powershell \ /usr/local/share/chromium sudo rm -rf /usr/local/lib/android echo "::group::/usr/local/bin/*" du -hsc /usr/local/bin/* | sort -h echo "::endgroup::" echo "::group::/usr/local/share/*" du -hsc /usr/local/share/* | sort -h echo "::endgroup::" echo "::group::/usr/local/*" du -hsc /usr/local/* | sort -h echo "::endgroup::" echo "::group::/usr/local/lib/*" du -hsc /usr/local/lib/* | sort -h echo "::endgroup::" echo "::group::/opt/*" du -hsc /opt/* | sort -h echo "::endgroup::" echo "Disk space after cleanup" df -h - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: ref: ${{ github.event.pull_request.head.sha }} persist-credentials: false - name: Install libsqlite run: | sudo apt-get update sudo apt-get install libsqlite3-dev sudo apt-get clean sudo rm -rf /var/lib/apt/lists/* - name: Install Rust uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1 with: toolchain: stable # Cargo config can screw with caching and is only used for alias config # and extra lints, which we don't care about here - name: Delete cargo config run: rm .cargo/config.toml - name: Load cache uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 with: prefix-key: "coverage" save-if: ${{ github.ref == 'refs/heads/main' }} - name: Install nextest and llvm-cov uses: taiki-e/install-action@055f5df8c3f65ea01cd41e9dc855becd88953486 # v 2.75.18 with: tool: nextest,cargo-llvm-cov - name: Get xtask uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: target/debug/xtask key: "${{ needs.xtask.outputs.cachekey-linux }}" fail-on-cache-miss: true - name: Check total disk space before running run: | df -h - name: Create the coverage report run: | target/debug/xtask ci coverage -o codecov env: CARGO_PROFILE_COV_INHERITS: 'dev' CARGO_PROFILE_COV_DEBUG: 1 HOMESERVER_URL: "http://localhost:8008" HOMESERVER_DOMAIN: "synapse" - name: Upload coverage to Codecov uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 with: use_oidc: true - name: Upload test results to Codecov if: ${{ !cancelled() }} uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 with: use_oidc: true report_type: "test_results"