From d0107f7830f93d854dc7be13fb1bd0e413a1d6ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Tue, 28 Nov 2023 10:39:21 +0100 Subject: [PATCH] ci: workflow to check bundle files (#2126) fail if `bundle.min.css` or `bundle.min.js` differes from a `make bundle` output Co-authored-by: Pavol Rusnak --- .github/workflows/lint.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/make.yml | 9 ++++++--- .gitignore | 2 ++ Makefile | 10 ++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 53cbad1c4..722222113 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,25 +3,53 @@ on: workflow_call: jobs: + black: uses: ./.github/workflows/make.yml + strategy: + matrix: + python-version: ["3.9", "3.10"] with: make: checkblack + python-version: ${{ matrix.python-version }} + ruff: uses: ./.github/workflows/make.yml + strategy: + matrix: + python-version: ["3.9", "3.10"] with: make: checkruff + python-version: ${{ matrix.python-version }} + mypy: uses: ./.github/workflows/make.yml + strategy: + matrix: + python-version: ["3.9", "3.10"] with: make: mypy + python-version: ${{ matrix.python-version }} + pyright: uses: ./.github/workflows/make.yml + strategy: + matrix: + python-version: ["3.9", "3.10"] with: make: pyright + python-version: ${{ matrix.python-version }} npm: true + + prettier: uses: ./.github/workflows/make.yml with: make: checkprettier npm: true + + bundle: + uses: ./.github/workflows/make.yml + with: + make: checkbundle + npm: true diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index 21dec850b..4a71de525 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -11,21 +11,24 @@ on: description: "use npm install" default: false type: boolean + python-version: + description: "python version" + type: string + default: "3.10" jobs: make: - name: ${{ inputs.make }} (${{ matrix.python-version }}) + name: ${{ inputs.make }} (${{ inputs.python-version }}) strategy: matrix: os-version: ["ubuntu-latest"] - python-version: ["3.9", "3.10"] node-version: ["18.x"] runs-on: ${{ matrix.os-version }} steps: - uses: actions/checkout@v3 - uses: ./.github/actions/prepare with: - python-version: ${{ matrix.python-version }} + python-version: ${{ inputs.python-version }} node-version: ${{ matrix.node-version }} npm: ${{ inputs.npm }} - run: make ${{ inputs.make }} diff --git a/.gitignore b/.gitignore index 5b3ab4252..b0e08c4a3 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,8 @@ coverage.xml node_modules lnbits/static/bundle.js lnbits/static/bundle.css +lnbits/static/bundle.min.js.old +lnbits/static/bundle.min.css.old docker # Nix diff --git a/Makefile b/Makefile index 0bc340421..889ce3e7d 100644 --- a/Makefile +++ b/Makefile @@ -100,6 +100,16 @@ bundle: sed -i -e "s/CACHE_VERSION =.*/CACHE_VERSION = $$(awk '/CACHE_VERSION =/ { print 1+$$4 }' lnbits/static/js/service-worker.js)/" \ lnbits/static/js/service-worker.js +checkbundle: + cp lnbits/static/bundle.min.js lnbits/static/bundle.min.js.old + cp lnbits/static/bundle.min.css lnbits/static/bundle.min.css.old + make bundle + diff -q lnbits/static/bundle.min.js lnbits/static/bundle.min.js.old || exit 1 + diff -q lnbits/static/bundle.min.css lnbits/static/bundle.min.css.old || exit 1 + @echo "Bundle is OK" + rm lnbits/static/bundle.min.js.old + rm lnbits/static/bundle.min.css.old + install-pre-commit-hook: @echo "Installing pre-commit hook to git" @echo "Uninstall the hook with poetry run pre-commit uninstall"