Merge pull request #43 from inab/create-pull-request/patch #177
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pre-commit | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ] | |
name: Pre-commit python ${{ matrix.python-version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
cache-dependency-path: | | |
requirements.txt | |
mypy-requirements.txt | |
dev-requirements.txt | |
architecture: x64 | |
- name: 'Install requirements (standard)' | |
if: ${{ matrix.python-version != '3.6' }} | |
run: | | |
pip install --upgrade pip wheel | |
pip install -r requirements.txt | |
- name: 'Install requirements (custom Python ${{ matrix.python-version }})' | |
if: ${{ matrix.python-version == '3.6' }} | |
run: | | |
pip install wheel | |
pip install -r requirements.txt -r requirements-additional-${{ matrix.python-version }}.txt | |
- name: 'Freeze Python ${{ matrix.python-version }} constraints' | |
run: | | |
pip freeze > constraints-${{ matrix.python-version }}.txt | |
- run: pip install -r dev-requirements.txt -r mypy-requirements.txt | |
- name: MyPy cache | |
uses: actions/cache@v3 | |
with: | |
path: .mypy_cache/${{ matrix.python-version }} | |
key: mypy-${{ matrix.python-version }} | |
- name: 'pre-commit' | |
uses: pre-commit/action@v3.0.0 | |
# if: ${{ matrix.python-version != '3.6' }} | |
with: | |
extra_args: --all -c .pre-commit-config.yaml | |
# - name: 'pre-commit (custom Python ${{ matrix.python-version }})' | |
# uses: pre-commit/action@v3.0.0 | |
# if: ${{ matrix.python-version == '3.6' }} | |
# with: | |
# extra_args: --all -c .pre-commit-config-gh-${{ matrix.python-version }}.yaml | |
- name: Check transitive dependencies licences | |
id: license_check_report | |
# uses: pilosus/action-pip-license-checker@v1.0.0 | |
# continue-on-error: true | |
uses: pilosus/action-pip-license-checker@v2.0.0 | |
with: | |
requirements: constraints-${{ matrix.python-version }}.txt | |
fail: 'StrongCopyleft' | |
exclude: 'pylint.*' | |
- name: Print licences report | |
if: ${{ always() }} | |
run: echo "${{ steps.license_check_report.outputs.report }}" | |
- uses: actions/upload-artifact@v3 | |
with: | |
retention-days: 2 | |
path: constraints-${{ matrix.python-version }}.txt | |
update_docs: | |
runs-on: ubuntu-latest | |
name: Update documentation if all worked properly | |
needs: | |
- pre-commit | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Changes at WfExS-backend internal JSON Schemas | |
id: changed_schemas | |
uses: tj-actions/changed-files@v34 | |
with: | |
files: | | |
wfexs_backend/schemas/*.json | |
- name: Install documentation generator | |
if: steps.changed_schemas.outputs.any_changed == 'true' | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.8" | |
cache: 'pip' | |
architecture: x64 | |
cache-dependency-path: 'dev-requirements.txt' | |
- name: Install development dependencies | |
run: | | |
pip install -r dev-requirements.txt | |
- name: Generate HTML documentation from internal JSON Schemas | |
id: doc-generate-html-if-changed | |
if: steps.changed_schemas.outputs.any_changed == 'true' | |
run: | | |
development-scripts/regenerate_schema_docs_html.bash wfexs_backend/schemas development-docs/schemas | |
- uses: actions/upload-artifact@v3 | |
if: steps.doc-generate-html-if-changed.outcome == 'success' | |
with: | |
retention-days: 2 | |
path: | | |
development-docs/schemas/*.html | |
development-docs/schemas/*.css | |
development-docs/schemas/*.js | |
- name: Generate MD documentation from internal JSON Schemas | |
id: doc-generate-md-if-changed | |
if: steps.changed_schemas.outputs.any_changed == 'true' | |
run: | | |
development-scripts/regenerate_schema_docs_md.bash wfexs_backend/schemas development-docs/schemas | |
- uses: actions/upload-artifact@v3 | |
if: steps.doc-generate-md-if-changed.outcome == 'success' | |
with: | |
retention-days: 2 | |
path: | | |
development-docs/schemas/*.md | |
pull_request_changes: | |
runs-on: ubuntu-latest | |
name: Pull request with the newly generated contents | |
needs: | |
- pre-commit | |
- update_docs | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
path: changes-dir | |
- name: Move artifacts to their right place | |
run: | | |
cp -dpr changes-dir/artifact/* . | |
rm -r changes-dir/artifact | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
title: Updated constraints (triggered by ${{ github.sha }}) | |
delete-branch: true | |
commit-message: "[create-pull-request] Automatically commit updated contents (constraints, generated documentation)" | |
- name: Check outputs | |
if: ${{ steps.cpr.outputs.pull-request-number }} | |
run: | | |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | |
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |