Run pre-commit on build.

This commit is contained in:
Dain Nilsson 2023-11-29 10:41:45 +01:00
parent 83fda9ddf5
commit 1452bc0d70
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8
4 changed files with 39 additions and 45 deletions

View File

@ -34,6 +34,10 @@ jobs:
export PYVERINST=${PYVER_TEMP#* } export PYVERINST=${PYVER_TEMP#* }
echo "PYVERINST=$PYVERINST" >> $GITHUB_ENV echo "PYVERINST=$PYVERINST" >> $GITHUB_ENV
echo "Installed python version: $PYVERINST" echo "Installed python version: $PYVERINST"
python -m ensurepip --user
python -m pip install -U pip pipx
# pipx ensurepath
echo "export PATH=$PATH:$HOME/.local/bin" >> ~/.bashrc
- name: Verify Python version - name: Verify Python version
if: ${{ env.PYVERINST != env.PYVER }} if: ${{ env.PYVERINST != env.PYVER }}
@ -59,21 +63,12 @@ jobs:
assets/licenses/helper.json assets/licenses/helper.json
key: ${{ runner.os }}-py${{ env.PYVER }}-${{ hashFiles('helper/**') }} key: ${{ runner.os }}-py${{ env.PYVER }}-${{ hashFiles('helper/**') }}
- name: Install helper dependencies
if: steps.cache-helper.outputs.cache-hit != 'true'
run: |
apt-get install -qq swig libpcsclite-dev build-essential cmake
python -m ensurepip --user
python -m pip install -U pip pipx
# pipx ensurepath
echo "export PATH=$PATH:$HOME/.local/bin" >> ~/.bashrc
. ~/.bashrc # Needed to ensure poetry on PATH
pipx install poetry
- name: Build the Helper - name: Build the Helper
if: steps.cache-helper.outputs.cache-hit != 'true' if: steps.cache-helper.outputs.cache-hit != 'true'
run: | run: |
. ~/.bashrc # Needed to ensure poetry on PATH apt-get install -qq swig libpcsclite-dev build-essential cmake
export PATH=$PATH:$HOME/.local/bin # Needed to ensure pipx/poetry on PATH
pipx install poetry
./build-helper.sh ./build-helper.sh
- name: Install Flutter dependencies - name: Install Flutter dependencies
@ -91,17 +86,19 @@ jobs:
flutter config --enable-linux-desktop flutter config --enable-linux-desktop
flutter --version flutter --version
- name: Run tests
run: |
flutter test
flutter analyze
- name: Build the app - name: Build the app
run: flutter build linux run: flutter build linux
- name: Check generated files - name: Check generated files
run: git diff --exit-code run: git diff --exit-code
- name: Run lints/tests
run: |
export PATH=$PATH:$HOME/.local/bin # Needed to ensure pip/pre-commit on PATH
pipx install pre-commit
pre-commit run --all-files
flutter test
- name: Embedd appindicator - name: Embedd appindicator
run: | run: |
patchelf --set-rpath '$ORIGIN' build/linux/x64/release/bundle/lib/libtray_manager_plugin.so patchelf --set-rpath '$ORIGIN' build/linux/x64/release/bundle/lib/libtray_manager_plugin.so

View File

@ -18,6 +18,11 @@ jobs:
python3 set-version.py python3 set-version.py
git diff --exit-code git diff --exit-code
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYVER }}
- name: Cache helper - name: Cache helper
id: cache-helper id: cache-helper
uses: actions/cache@v3 uses: actions/cache@v3
@ -27,12 +32,6 @@ jobs:
assets/licenses/helper.json assets/licenses/helper.json
key: ${{ runner.os }}-py${{ env.PYVER }}-${{ hashFiles('helper/**') }} key: ${{ runner.os }}-py${{ env.PYVER }}-${{ hashFiles('helper/**') }}
- name: Set up Python
if: steps.cache-helper.outputs.cache-hit != 'true'
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYVER }}
- name: Install dependencies - name: Install dependencies
if: steps.cache-helper.outputs.cache-hit != 'true' if: steps.cache-helper.outputs.cache-hit != 'true'
run: | run: |
@ -53,10 +52,11 @@ jobs:
- run: flutter config --enable-macos-desktop - run: flutter config --enable-macos-desktop
- run: flutter --version - run: flutter --version
- name: Run tests - name: Run lints/tests
run: | run: |
python -m pip install pre-commit
python -m pre_commit run --all-files
flutter test flutter test
flutter analyze
- name: Build the app - name: Build the app
run: | run: |

View File

@ -19,6 +19,14 @@ jobs:
python set-version.py python set-version.py
git diff --exit-code git diff --exit-code
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYVER }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Cache helper - name: Cache helper
id: cache-helper id: cache-helper
uses: actions/cache@v3 uses: actions/cache@v3
@ -28,21 +36,11 @@ jobs:
assets/licenses/helper.json assets/licenses/helper.json
key: ${{ runner.os }}-py${{ env.PYVER }}-${{ hashFiles('helper/**') }} key: ${{ runner.os }}-py${{ env.PYVER }}-${{ hashFiles('helper/**') }}
- name: Set up Python
if: steps.cache-helper.outputs.cache-hit != 'true'
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYVER }}
- name: Install dependencies
if: steps.cache-helper.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Build the Helper - name: Build the Helper
if: steps.cache-helper.outputs.cache-hit != 'true' if: steps.cache-helper.outputs.cache-hit != 'true'
run: .\build-helper.bat run: |
pip install poetry
.\build-helper.bat
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
@ -51,16 +49,17 @@ jobs:
- run: flutter config --enable-windows-desktop - run: flutter config --enable-windows-desktop
- run: flutter --version - run: flutter --version
- name: Run tests
run: |
flutter test
flutter analyze
- name: Build the app - name: Build the app
run: | run: |
$version = python set-version.py | select-object -first 1 $version = python set-version.py | select-object -first 1
flutter build windows --build-name=$version flutter build windows --build-name=$version
- name: Run lints/tests
run: |
pip install pre-commit
pre-commit run --all-files
flutter test
- name: Check generated files - name: Check generated files
run: git diff -I '.*android.*flutter_plugins.*qrscanner_zxing' --exit-code run: git diff -I '.*android.*flutter_plugins.*qrscanner_zxing' --exit-code

View File

@ -4,9 +4,7 @@ repos:
rev: "4afcaa82fc368d40d486256bf4edba329bf667bb" rev: "4afcaa82fc368d40d486256bf4edba329bf667bb"
hooks: hooks:
- id: flutter-analyze - id: flutter-analyze
args: [lib/*]
- id: dart-format - id: dart-format
args: [lib/*]
# Python # Python
- repo: https://github.com/PyCQA/flake8 - repo: https://github.com/PyCQA/flake8