mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-24 21:52:34 +02:00
This change will change the pipline to limit duplicat execution of tests and lint actions in pull requests to save computing time.
130 lines
3.3 KiB
YAML
130 lines
3.3 KiB
YAML
name: Test & Build
|
|
|
|
on:
|
|
pull_request:
|
|
types: [reopened, opened, synchronize]
|
|
push:
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
|
|
steps:
|
|
- name: Check out repository code
|
|
uses: actions/checkout@v3
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: 3.11
|
|
- name: Install and configure Poetry
|
|
uses: snok/install-poetry@v1
|
|
with:
|
|
version: 1.4.2
|
|
virtualenvs-path: ~/local/share/virtualenvs
|
|
- id: cache-pipenv
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.local/share/virtualenvs
|
|
key: venv
|
|
- run: poetry install --without develop,doc,lint
|
|
- name: Run test suite
|
|
run: |
|
|
poetry run pytest --junit-xml=unit-test-results.xml --cov-report "xml:coverage.xml" --cov=src tests/
|
|
- name: Archive code coverage results
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: code-coverage-report
|
|
path: |
|
|
coverage.xml
|
|
.coverage
|
|
- name: Archive code coverage results
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: test-report
|
|
path: |
|
|
unit-test-results.xml
|
|
if-no-files-found: error
|
|
|
|
coverage_pull_request:
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
steps:
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: code-coverage-report
|
|
- name: Get Cover
|
|
uses: orgoro/coverage@v3.1
|
|
with:
|
|
coverageFile: coverage.xml
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
thresholdAll: 0.7
|
|
thresholdNew: 0.7
|
|
thresholdModified: 0.7
|
|
|
|
coverage_report:
|
|
if: ${{ github.event_name == 'push' }}
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
steps:
|
|
- name: Check out repository code
|
|
uses: actions/checkout@v3
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: 3.11
|
|
- id: cache-pipenv
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.local/share/virtualenvs
|
|
key: venv
|
|
- name: Install and configure Poetry
|
|
uses: snok/install-poetry@v1
|
|
with:
|
|
version: 1.4.2
|
|
virtualenvs-path: ~/local/share/virtualenvs
|
|
- run: |
|
|
poetry install --only test
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: code-coverage-report
|
|
- name: Make Coverage Report
|
|
run: |
|
|
poetry run coverage html
|
|
- name: Archive builds
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: Coverage Report HTML
|
|
path: htmlcov/
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
if: ${{ github.event_name == 'push' }}
|
|
steps:
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: 3.11
|
|
- name: Install and configure Poetry
|
|
uses: snok/install-poetry@v1
|
|
with:
|
|
version: 1.4.2
|
|
virtualenvs-path: ~/local/share/virtualenvs
|
|
- id: cache-pipenv
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.local/share/virtualenvs
|
|
key: venv
|
|
- name: Check out repository code
|
|
uses: actions/checkout@v3
|
|
- run: |
|
|
poetry install --without develop,doc,lint,test
|
|
poetry build
|
|
- name: Archive builds
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: builds
|
|
path: dist/
|