Version bump to 0.2.1. #17
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] | |
paths-ignore: | |
- 'constraints-*.txt' | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ] | |
name: Pre-commit python ${{ matrix.python-version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 100 | |
- uses: actions/setup-python@v5 | |
id: cachepy | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
cache-dependency-path: | | |
requirements.txt | |
mypy-requirements.txt | |
dev-requirements.txt | |
architecture: x64 | |
- name: Changed requirements.txt | |
id: changed-requirements-txt | |
uses: tj-actions/changed-files@v44 | |
with: | |
files: requirements.txt | |
- name: 'Install requirements (standard)' | |
run: | | |
pip install --upgrade pip wheel | |
pip install -r requirements.txt | |
- name: 'Install requirements (standard with freeze) or constraints (Python ${{ matrix.python-version }})' | |
run: | | |
pip install --upgrade pip wheel | |
if [ ${{ steps.changed-requirements-txt.outputs.any_changed }} != 'true' ] && [ -f constraints-${{ matrix.python-version }}.txt ] ; then | |
pip install -r requirements.txt -c constraints-${{ matrix.python-version }}.txt | |
else | |
pip install -r requirements.txt | |
pip freeze > constraints-${{ matrix.python-version }}.txt | |
fi | |
- name: 'Install dev requirements' | |
run: | | |
pip install -r dev-requirements.txt -r mypy-requirements.txt -c constraints-${{ matrix.python-version }}.txt | |
- name: MyPy cache | |
uses: actions/cache@v4 | |
with: | |
path: .mypy_cache/${{ matrix.python-version }} | |
key: mypy-${{ matrix.python-version }} | |
- name: 'pre-commit' | |
uses: pre-commit/[email protected] | |
# 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/[email protected] | |
# 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/[email protected] | |
# continue-on-error: true | |
uses: pilosus/[email protected] | |
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@v4 | |
with: | |
name: constraints-artifacts-${{ matrix.python-version }} | |
retention-days: 2 | |
path: constraints-${{ matrix.python-version }}.txt | |
pre-commit-22_04: | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
python-version: [ "3.7" ] | |
name: Pre-commit python ${{ matrix.python-version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 100 | |
- uses: actions/setup-python@v5 | |
id: cachepy | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
cache-dependency-path: | | |
requirements.txt | |
mypy-requirements.txt | |
dev-requirements.txt | |
architecture: x64 | |
- name: Changed requirements.txt | |
id: changed-requirements-txt | |
uses: tj-actions/changed-files@v44 | |
with: | |
files: requirements.txt | |
- name: 'Install requirements (standard)' | |
run: | | |
pip install --upgrade pip wheel | |
pip install -r requirements.txt | |
- name: 'Install requirements (standard with freeze) or constraints (Python ${{ matrix.python-version }})' | |
run: | | |
pip install --upgrade pip wheel | |
if [ ${{ steps.changed-requirements-txt.outputs.any_changed }} != 'true' ] && [ -f constraints-${{ matrix.python-version }}.txt ] ; then | |
pip install -r requirements.txt -c constraints-${{ matrix.python-version }}.txt | |
else | |
pip install -r requirements.txt | |
pip freeze > constraints-${{ matrix.python-version }}.txt | |
fi | |
- name: 'Install dev requirements' | |
run: | | |
pip install -r dev-requirements.txt -r mypy-requirements.txt -c constraints-${{ matrix.python-version }}.txt | |
- name: MyPy cache | |
uses: actions/cache@v4 | |
with: | |
path: .mypy_cache/${{ matrix.python-version }} | |
key: mypy-${{ matrix.python-version }} | |
- name: 'pre-commit' | |
uses: pre-commit/[email protected] | |
# 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/[email protected] | |
# 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/[email protected] | |
# continue-on-error: true | |
uses: pilosus/[email protected] | |
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@v4 | |
with: | |
name: constraints-artifacts-${{ matrix.python-version }} | |
retention-days: 2 | |
path: constraints-${{ matrix.python-version }}.txt | |
pull_request_changes: | |
runs-on: ubuntu-latest | |
name: Pull request with the newly generated contents | |
needs: | |
- pre-commit | |
- pre-commit-22_04 | |
steps: | |
- name: Get analysis timestamp | |
id: timestamp | |
run: echo "timestamp=$(date -Is)" >> "$GITHUB_OUTPUT" | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
id: download | |
with: | |
pattern: constraints-artifacts-* | |
merge-multiple: true | |
path: changes-dir | |
- name: Move artifacts to their right place | |
id: move | |
run: | | |
skip=true | |
if [ -d "${{steps.download.outputs.download-path}}" ] ; then | |
for con in "${{steps.download.outputs.download-path}}"/constraints-*.txt ; do | |
case "$con" in | |
*/constraints-\*.txt) | |
break | |
;; | |
*) | |
cp -p "$con" . | |
skip=false | |
;; | |
esac | |
done | |
fi | |
echo "skip=$skip" >> "$GITHUB_OUTPUT" | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@v7 | |
if: steps.move.outputs.skip == 'false' | |
with: | |
title: Updated constraints (triggered by ${{ github.sha }}) | |
add-paths: constraints-*.txt | |
delete-branch: true | |
commit-message: "[create-pull-request] Automatically commit updated contents (constraints)" | |
- name: Check outputs | |
if: ${{ steps.cpr.outputs.pull-request-number }} | |
run: | | |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" >> "$GITHUB_STEP_SUMMARY" | |
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" >> "$GITHUB_STEP_SUMMARY" |