update workflows

This commit is contained in:
Sina Atalay 2024-02-18 21:40:03 +01:00
parent 140fab5622
commit 7f7fa17f7f
3 changed files with 68 additions and 53 deletions

View File

@ -1,17 +1,18 @@
name: CI name: Continuous integration
# GitHub events that triggers the workflow:
on: on:
push: push:
branches: ["main", "v1"] branches: ["main", "dev", "v1"]
pull_request: pull_request:
branches: ["main", "v1"] branches: ["main", "dev", "v1"]
release: workflow_call:
types: ["published"]
# The workflow:
jobs: jobs:
lint: lint:
runs-on: ubuntu-latest
name: Lint with Ruff (Py${{ matrix.python-version }}) name: Lint with Ruff (Py${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -54,15 +55,12 @@ jobs:
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install pytest python -m pip install pytest
pip install .[testing] pip install .[tests]
- name: Test with pytest - name: Test with pytest
run: | run: |
pip install pytest pytest-cov pip install pytest coverage
touch .coveragerc coverage run -m pytest tests/
echo "[run]" > .coveragerc
echo "relative_files = True" >> .coveragerc
pytest --cov="rendercv" tests/
mv .coverage .coverage.${{ matrix.python-version }}.${{ matrix.os }} mv .coverage .coverage.${{ matrix.python-version }}.${{ matrix.os }}
- name: Store coverage files - name: Store coverage files
@ -72,7 +70,6 @@ jobs:
path: .coverage.${{ matrix.python-version }}.${{ matrix.os }} path: .coverage.${{ matrix.python-version }}.${{ matrix.os }}
report-coverage: report-coverage:
if: github.event_name == 'push'
name: Generate a coverage report name: Generate a coverage report
needs: [test] needs: [test]
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -94,10 +91,6 @@ jobs:
- name: Combine coverage files - name: Combine coverage files
run: | run: |
pip install coverage pip install coverage
ls -la coverage
touch .coveragerc
echo "[run]" > .coveragerc
echo "relative_files = True" >> .coveragerc
coverage combine coverage coverage combine coverage
coverage report coverage report
coverage html --show-contexts --title "RenderCV coverage for ${{ github.sha }}" coverage html --show-contexts --title "RenderCV coverage for ${{ github.sha }}"
@ -108,31 +101,6 @@ jobs:
smokeshow upload ./htmlcov smokeshow upload ./htmlcov
env: env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage} SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 50 SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 97
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
publish:
if: github.event_name == 'release'
name: Publish to PyPI
needs: [test]
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Build
run: |
pip install -U build
python -m build
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

View File

@ -1,25 +1,38 @@
name: Deploy documentation name: Deploy documentation
# GitHub events that triggers the workflow:
on: on:
push: push:
branches: branches: ["main"]
- main pull_request:
branches: ["main"]
permissions: permissions:
contents: write contents: write
jobs: jobs:
deploy: deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with: with:
python-version: 3.11 python-version: ${{ matrix.python-version }}
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v3 - name: Store cache ID
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- name: Create a key
uses: actions/cache@v4
with: with:
key: mkdocs-material-${{ env.cache_id }} key: mkdocs-material-${{ env.cache_id }}
path: .cache path: .cache
restore-keys: | restore-keys: |
mkdocs-material- mkdocs-material-
- run: pip install mkdocs-material
- run: pip install mkdocstrings-python - name: Deploy documentation
- run: mkdocs gh-deploy --force run: |
pip install mkdocs-material
pip install mkdocstrings-python
mkdocs gh-deploy --force

34
.github/workflows/publish.yaml vendored Normal file
View File

@ -0,0 +1,34 @@
name: Publish to PyPI
# GitHub events that triggers the workflow:
on:
release:
types: [released]
jobs:
call_ci_workflow:
name: Continuous integration
uses: ./.github/workflows/ci.yaml
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Build
run: |
pip install -U build
python -m build
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1