Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rectified code coverage workflow #42

Merged
merged 8 commits into from
Apr 14, 2024
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
1 change: 1 addition & 0 deletions .github/badges/jacoco.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 17 additions & 10 deletions .github/workflows/codecoverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ on:
workflow_dispatch:
pull_request:

permissions: write-all

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]

permissions:
pull-requests: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}


- name: Set up JDK 17
uses: actions/setup-java@v3
Expand All @@ -38,13 +40,18 @@ jobs:
generate-coverage-badge: true
coverage-badge-filename: jacoco.svg

- name: Check for modified files
id: git-check
run: echo "modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT


- name: Commit the badges (if they changed)
if: steps.git-check.outputs.modified == 'true'
run: |
if [[ `git diff --exit-code .github/badges` ]]; then
git config --global user.name 'qrutyy'
git config --global user.email 'qrutyq@gmail.com'
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add .github/badges/*
git commit -m "ci: autogenerate JaCoCo coverage badge"
git push || true
fi
git commit -am "ci: autogenerate JaCoCo coverage badge"
git push
shell: bash
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Kotlin 1.9.23][kotlin_img]][kotlin_releases_url]
[![Tests passing][tests_passing_img]][tests_workflow_url]
[![Code Coverage][code_coverage_badge_img]][code_coverage_workflow_url]
[![License][license_img]][repo_license_url]
[![CodeFactor][codefactor_img]][codefactor_url]

Expand Down Expand Up @@ -68,13 +69,6 @@ for ((key, value) in myRBTree) {
myRBTree.forEach { println(it) } // prints every pair
```

There are also other helpful methods:

- `clear()`
- `isEmpty()`
- `getMinKey()`
- `getMaxKey()`

## Contributing

If you have found a bug, or want to propose some useful feature for our project, please firstly read our [Contribution Rules][contribute_rules_url] and
Expand Down Expand Up @@ -105,12 +99,14 @@ _______________________________
[tests_passing_img]: https://img.shields.io/badge/tests-Passing-green
[license_img]: https://img.shields.io/badge/license-MIT-blue
[codefactor_img]: https://www.codefactor.io/repository/github/spbu-coding-2023/trees-2/badge
[code_coverage_badge_img]: https://github.com/spbu-coding-2023/trees-2/.github/badges/jacoco.svg

<!-- Inner Links -->

[tests_workflow_url]: https://github.com/spbu-coding-2023/trees-2/actions/workflows/test.yml
[repo_license_url]: https://github.com/spbu-coding-2023/trees-2/blob/main/LICENSE.md
[contribute_rules_url]: https://github.com/spbu-coding-2023/trees-2/blob/main/CONTRIBUTING.md
[code_coverage_workflow_url]: https://github.com/spbu-coding-2023/trees-2/actions/workflows/codecoverage.yml

<!-- Outer Links -->

Expand Down