From 767c9a8ed69f8bb1f246652736cfd5bba2f673af Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 28 Sep 2023 15:28:42 +0300 Subject: [PATCH 1/3] Run prettier --- .github/workflows/build.yml | 84 ++++++++++++++++++------------------- .pre-commit-config.yaml | 4 ++ .prettierignore | 2 + analysaattori/index.html | 12 ++++-- analysaattori/src/App.tsx | 13 +++--- analysaattori/src/index.tsx | 8 ++-- analysaattori/tsconfig.json | 10 +---- template/style.css | 77 ++++++++++++++++++++-------------- 8 files changed, 115 insertions(+), 95 deletions(-) create mode 100644 .prettierignore diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 84e2965..62ccb0c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,51 +2,51 @@ name: Build on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] #schedule: - # Update automatically on weekdays during work hours - #- cron: '0 10,13,16 * * 1-5' - # ... and every night - #- cron: '0 0 * * *' + # Update automatically on weekdays during work hours + #- cron: '0 10,13,16 * * 1-5' + # ... and every night + #- cron: '0 0 * * *' jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.11 - uses: actions/setup-python@v4 - with: - python-version: "3.11" - cache: pip - - name: Install dependencies - run: python -m pip install -r requirements.txt - - name: Build - run: make -j3 - - uses: actions/setup-node@v3 - with: - node-version: "20" - cache: yarn - cache-dependency-path: analysaattori/yarn.lock - - run: yarn - working-directory: analysaattori - - run: yarn build -- --base=/palkkakysely/analysaattori/ - working-directory: analysaattori - env: - GENERATE_SOURCEMAP: 'false' - - run: cp -a analysaattori/dist ./out/analysaattori - - run: ls -laR out - - run: touch out/.nojekyll - - name: Deploy - uses: JamesIves/github-pages-deploy-action@v4 - with: - branch: gh-pages - folder: out - clean: false - if: ${{ github.event_name == 'push' }} - env: - GIT_AUTHOR_EMAIL: "koodiklinikka-robot@example.com" - GIT_AUTHOR_NAME: "Koodiklinikka Robot" - GIT_COMMITTER_EMAIL: "koodiklinikka-robot@example.com" - GIT_COMMITTER_NAME: "Koodiklinikka Robot" + - uses: actions/checkout@v3 + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: "3.11" + cache: pip + - name: Install dependencies + run: python -m pip install -r requirements.txt + - name: Build + run: make -j3 + - uses: actions/setup-node@v3 + with: + node-version: "20" + cache: yarn + cache-dependency-path: analysaattori/yarn.lock + - run: yarn + working-directory: analysaattori + - run: yarn build -- --base=/palkkakysely/analysaattori/ + working-directory: analysaattori + env: + GENERATE_SOURCEMAP: "false" + - run: cp -a analysaattori/dist ./out/analysaattori + - run: ls -laR out + - run: touch out/.nojekyll + - name: Deploy + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: out + clean: false + if: ${{ github.event_name == 'push' }} + env: + GIT_AUTHOR_EMAIL: "koodiklinikka-robot@example.com" + GIT_AUTHOR_NAME: "Koodiklinikka Robot" + GIT_COMMITTER_EMAIL: "koodiklinikka-robot@example.com" + GIT_COMMITTER_NAME: "Koodiklinikka Robot" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a59bf70..04ab6f7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,3 +12,7 @@ repos: rev: 23.9.1 hooks: - id: black + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.0.3 + hooks: + - id: prettier diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..99e0d75 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +# prettier doesn't understand jinja, the poor thing +template/*.html diff --git a/analysaattori/index.html b/analysaattori/index.html index f5a0f48..3082342 100644 --- a/analysaattori/index.html +++ b/analysaattori/index.html @@ -1,11 +1,17 @@ - + - - + + Palkka-analysaattori diff --git a/analysaattori/src/App.tsx b/analysaattori/src/App.tsx index 527253e..7a60ea6 100644 --- a/analysaattori/src/App.tsx +++ b/analysaattori/src/App.tsx @@ -1,16 +1,15 @@ -import React from 'react'; -import PivotTableUI from 'react-pivottable/PivotTableUI'; -import 'react-pivottable/pivottable.css'; -import TableRenderers from 'react-pivottable/TableRenderers'; -import createPlotlyComponent from 'react-plotly.js/factory'; -import createPlotlyRenderers from 'react-pivottable/PlotlyRenderers'; +import React from "react"; +import PivotTableUI from "react-pivottable/PivotTableUI"; +import "react-pivottable/pivottable.css"; +import TableRenderers from "react-pivottable/TableRenderers"; +import createPlotlyComponent from "react-plotly.js/factory"; +import createPlotlyRenderers from "react-pivottable/PlotlyRenderers"; import useSWR from "swr/esm"; const Plot = createPlotlyComponent(window.Plotly); const PlotlyRenderers = createPlotlyRenderers(Plot); const renderers = Object.assign({}, TableRenderers, PlotlyRenderers); - function App() { const qs = new URLSearchParams(window.location.search); const [pivotState, setPivotState] = React.useState({}); diff --git a/analysaattori/src/index.tsx b/analysaattori/src/index.tsx index c1f31c5..6548659 100644 --- a/analysaattori/src/index.tsx +++ b/analysaattori/src/index.tsx @@ -1,10 +1,10 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import App from './App'; +import React from "react"; +import ReactDOM from "react-dom"; +import App from "./App"; ReactDOM.render( , - document.getElementById('root') + document.getElementById("root"), ); diff --git a/analysaattori/tsconfig.json b/analysaattori/tsconfig.json index a273b0c..9d379a3 100644 --- a/analysaattori/tsconfig.json +++ b/analysaattori/tsconfig.json @@ -1,11 +1,7 @@ { "compilerOptions": { "target": "es5", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], + "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, @@ -20,7 +16,5 @@ "noEmit": true, "jsx": "react-jsx" }, - "include": [ - "src" - ] + "include": ["src"] } diff --git a/template/style.css b/template/style.css index 9150db3..9db54d8 100644 --- a/template/style.css +++ b/template/style.css @@ -1,63 +1,78 @@ body { - padding: 1em; - font: 18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; + padding: 1em; + font: + 18px/1.5 -apple-system, + BlinkMacSystemFont, + "Segoe UI", + Roboto, + "Helvetica Neue", + Arial, + "Noto Sans", + sans-serif, + "Apple Color Emoji", + "Segoe UI Emoji", + "Segoe UI Symbol", + "Noto Color Emoji"; } body.static-body { - max-width: 650px; - margin: auto; + max-width: 650px; + margin: auto; } body.table-body { - font-size: 14px; - line-height: 1.3; + font-size: 14px; + line-height: 1.3; } body.table-body table { - border-collapse: collapse; + border-collapse: collapse; } -body.table-body td, body.table-body th { - padding: 0.3em; - border: 1px solid #999; +body.table-body td, +body.table-body th { + padding: 0.3em; + border: 1px solid #999; } -h1, h2, h3 { - line-height: 1.2; +h1, +h2, +h3 { + line-height: 1.2; } a:link { - color: #2181b7; + color: #2181b7; } a:visited { - color: #4e1ecb; + color: #4e1ecb; } @media (prefers-color-scheme: dark) { - body { - color: white; - background: #444 - } + body { + color: white; + background: #444; + } - a:link { - color: #5bf - } + a:link { + color: #5bf; + } - a:visited { - color: #ccf - } + a:visited { + color: #ccf; + } } header { - border-bottom: 2px solid #2a6180; - padding-bottom: 1em; - line-height: 1; + border-bottom: 2px solid #2a6180; + padding-bottom: 1em; + line-height: 1; } footer { - border-top: 2px solid #2a6180; - padding: 1em; - margin-top: 1em; - text-align: center; + border-top: 2px solid #2a6180; + padding: 1em; + margin-top: 1em; + text-align: center; } From fe06cc38bc98ef827e168225459380d206373b1f Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 28 Sep 2023 15:30:25 +0300 Subject: [PATCH 2/3] Ruffify --- pulkka/data_ingest.py | 1 - ruff.toml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/pulkka/data_ingest.py b/pulkka/data_ingest.py index 0743458..2fbfcfa 100644 --- a/pulkka/data_ingest.py +++ b/pulkka/data_ingest.py @@ -33,7 +33,6 @@ OTHER_GENDER_VALUES, TYOKOKEMUS_COL, ROOLI_NORM_COL, - PALAUTE_COL, TIMESTAMPS_TO_DROP, ) diff --git a/ruff.toml b/ruff.toml index 06bb0ba..ccbc2ae 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,5 +1,6 @@ ignore = [ "E501", + "PD901", # I know "df" isn't the best name ] extend-select = [ "COM", From 4907cd3792c4fca14d761073983f449d5cdd12ff Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 28 Sep 2023 15:29:30 +0300 Subject: [PATCH 3/3] Run pre-commit in CI --- .github/workflows/build.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 62ccb0c..a67e7a6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,15 @@ on: # ... and every night #- cron: '0 0 * * *' jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.11" + cache: pip + - uses: pre-commit/action@v3.0.0 build: runs-on: ubuntu-latest steps: