Skip to content

Commit

Permalink
docs: 改善 README 顯示方式,新增 test coverage badge (#42)
Browse files Browse the repository at this point in the history
* chore(actions): 改善 actions 流程

* docs(README): 提高 README 可讀性

* chore(sonarcloud): 新增 test coverage
  • Loading branch information
l7wei authored Dec 11, 2023
1 parent 87572d3 commit a6daa27
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 42 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ jobs:
linter_name:
name: Code formatter
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
fail-fast: true
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: pip install black isort
- name: Format code with black and isort
run: |
pip install black isort
isort .
black .
- name: Commit changes
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/smokeshow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ jobs:
Smokeshow:
needs: Context
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.11"]
fail-fast: true
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/setup-python@v5
with:
python-version: '3.11'

python-version: ${{ matrix.python-version }}
- run: pip install smokeshow

- uses: dawidd6/action-download-artifact@v2.28.0
with:
workflow: tests.yml
commit: ${{ github.event.workflow_run.head_sha }}

- run: smokeshow upload coverage
env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: SonarCloud Scan
on:
workflow_run:
workflows: [Test]
types: [completed]

jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: actions/download-artifact@master
with:
name: coverage
path: coverage
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
pip install -r requirements.txt
pip install -r requirements-tests.txt
- name: Test
run: python -m pytest -n auto tests --cov=src --cov=tests --cov-report=html:coverage --cov-fail-under=85
run: python -m pytest -n auto tests --cov=src --cov=tests --cov-report=xml --cov-report=html:coverage --cov-fail-under=85
- name: Store coverage files
uses: actions/upload-artifact@v3
with:
Expand Down
95 changes: 60 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,77 @@
# NTHU-Data-API
[![CodeFactor](https://www.codefactor.io/repository/github/nthu-sa/nthu-data-api/badge)](https://www.codefactor.io/repository/github/nthu-sa/nthu-data-api) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Smokeshow coverage](https://coverage-badge.samuelcolvin.workers.dev/NTHU-SA/NTHU-Data-API.svg)](https://coverage-badge.samuelcolvin.workers.dev/redirect/NTHU-SA/NTHU-Data-API)
<p align="center">
<em>NTHU-Data-API is a project designed for NTHU developers.</em>
<br>
<em>It provides an easy way to fetch data from the NTHU website.</em>
</p>
<p align="center">
<a href="https://www.codefactor.io/repository/github/nthu-sa/nthu-data-api" target="_blank">
<img src="https://www.codefactor.io/repository/github/nthu-sa/nthu-data-api/badge" alt="Codefactor Score">
</a>
<a href="https://github.com/psf/black" target="_blank">
<img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/NTHU-SA/NTHU-Data-API" target="_blank">
<img src="https://coverage-badge.samuelcolvin.workers.dev/NTHU-SA/NTHU-Data-API.svg" alt="Test Coverage">
</a>
<br>
<a href="https://sonarcloud.io/summary/new_code?id=NTHU-SA_NTHU-Data-API" target="_blank">
<img src="https://sonarcloud.io/api/project_badges/measure?project=NTHU-SA_NTHU-Data-API&metric=ncloc" alt="Lines of Code">
</a>
<a href="https://sonarcloud.io/summary/new_code?id=NTHU-SA_NTHU-Data-API" target="_blank">
<img src="https://sonarcloud.io/api/project_badges/measure?project=NTHU-SA_NTHU-Data-API&metric=sqale_index" alt="Technical Debt">
</a>
</p>

## Introduction
This is a project for NTHU students to get data from NTHU website.
NTHU-Data-API is a project designed for NTHU developers. It provides an easy way to fetch data from the NTHU website.

## Usage
### Install
## Getting Started
### Prerequisites
Ensure you have Python 3 installed on your machine. You can verify this by running `python3 --version` in your terminal. If you don't have Python 3 installed, you can download it [here](https://www.python.org/downloads/).
### Installation
1. Clone the repository:
```sh
pip3 install -r requirements.txt
git clone https://github.com/NTHU-SA/NTHU-Data-API.git
```
### Config
2. Navigate to the project directory:
```sh
cp .env.template .env
cd NTHU-Data-API
```
### Run
3. Install the required dependencies:
```sh
python3 main.py
pip3 install -r requirements.txt
```

## Notes
### Commit:
#### Type:
- feat: 新增/修改功能 (feature)。
- fix: 修補 bug (bug fix)。
- docs: 文件 (documentation)。
- style: 格式 (不影響程式碼運行的變動 white-space, formatting, missing semi colons, etc)。
- refactor: 重構 (既不是新增功能,也不是修補 bug 的程式碼變動)。
- perf: 改善效能 (A code change that improves performance)。
- test: 增加測試 (when adding missing tests)。
- chore: 建構程序或輔助工具的變動 (maintain)。
- revert: 撤銷回覆先前的 commit 例如:revert: type(scope): subject (回覆版本:xxxx)。
#### Message Format:
### Configuration
Copy the environment template file and fill in your details:
```sh
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
cp .env.template .env
```
#### Message Example:
### Running the Application
```sh
feat(README.md): add commit type and commit message format
python3 main.py
```
#### Reference
- [Git Commit Message Convention](https://gist.github.com/stephenparish/9941e89d80e2bc58a153)
- [Git Commit Message 這樣寫會更好,替專案引入規範與範例](https://wadehuanglearning.blogspot.com/2019/05/commit-commit-commit-why-what-commit.html)

## Contributing
We follow certain guidelines for contributing. Here are the types of commits we accept:

- feat: Add or modify features.
- fix: Bug fixes.
- docs: Documentation changes.
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi colons, etc).
- refactor: Code changes that neither fixes a bug nor adds a feature.
- perf: Code changes that improve performance.
- test: Adding missing tests.
- chore: Changes to the build process or auxiliary tools and libraries.
- revert: Reverts a previous commit.

## Credit
- NTHUSA 32nd
This project is maintained by NTHUSA 32nd.

## License
[MIT](https://choosealicense.com/licenses/mit/)
This project is licensed under the [MIT License](https://choosealicense.com/licenses/mit/).

## Acknowledgements
Thanks to SonarCloud for providing code quality metrics:

[![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-white.svg)](https://sonarcloud.io/summary/new_code?id=NTHU-SA_NTHU-Data-API)
14 changes: 14 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=NTHU-SA_NTHU-Data-API
sonar.organization=nthu-sa
sonar.python.coverage.reportPaths=coverage/coverage.xml

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=NTHU-Data-API
#sonar.projectVersion=1.0


# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

0 comments on commit a6daa27

Please sign in to comment.