mirror of
https://github.com/MaxenceG2M/prometheus-immich-exporter.git
synced 2025-12-09 23:15:36 +00:00
Unit tests (#23)
* Added unit tests and linting tools for development * Added pre-commit config file * Added lint github action * Add tests and coverage comments to PRs * Set coverage options * Fixed yaml * Fixed permissions * Omit tests in coverage report * Run linting only on PRs
This commit is contained in:
57
.github/workflows/lint.yml
vendored
Normal file
57
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
name: Run Unit Test via Pytest
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
lint-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
checks: write
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.11"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Setup PDM
|
||||
uses: pdm-project/setup-pdm@v3
|
||||
- name: Install dependencies
|
||||
run: pdm install
|
||||
- name: Lint with black
|
||||
uses: psf/black@stable
|
||||
with:
|
||||
options: "--check --verbose"
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
pdm run pytest --junit-xml=test-results.xml
|
||||
- name: Publish Test Results
|
||||
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||
if: always()
|
||||
with:
|
||||
files: |
|
||||
test-results.xml
|
||||
- name: Test with coverage
|
||||
run: |
|
||||
pdm run coverage run -m pytest -v -s
|
||||
- name: Generate Coverage Report
|
||||
run: |
|
||||
pdm run coverage report -m
|
||||
- name: Coverage comment
|
||||
id: coverage_comment
|
||||
uses: py-cov-action/python-coverage-comment-action@v3
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
- name: Store Pull Request comment to be posted
|
||||
uses: actions/upload-artifact@v3
|
||||
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
|
||||
with:
|
||||
name: python-coverage-comment-action
|
||||
path: python-coverage-comment-action.txt
|
||||
Reference in New Issue
Block a user