-
Notifications
You must be signed in to change notification settings - Fork 7
52 lines (52 loc) · 1.9 KB
/
coverage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
permissions:
contents: write
pull-requests: write
on:
pull_request:
name: coverage
jobs:
coverage:
runs-on: ubuntu-latest
name: ubuntu / nightly / coverage
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools-preview,rust-src
- name: cargo install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: cargo llvm-cov
id: gen-coverage
run: |
mkdir -p coverage/coverage
RUSTFLAGS="--cfg NO_UI_TESTS" cargo llvm-cov --locked --all-features --examples --tests --html
mv "target/llvm-cov/html" "coverage/coverage/${{ github.sha }}"
- name: Upload to gh-pages
run: |
cd coverage
git config --global init.defaultBranch gh-pages
git init
git remote add origin "https://github.com/$GITHUB_REPOSITORY"
git fetch origin
git pull origin gh-pages
git config user.name CI
git config user.email ""
git add .
git commit -m "Create coverage of PR #${{ github.event.number }} \`\"${{ github.head_ref }}\"\` (${{ github.sha }})"
git push "https://x-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY" HEAD:gh-pages
- uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '[Coverage](https://rust-for-linux.github.io/pinned-init/coverage/${{ github.sha }}) for ${{ github.sha }}'
})