From c207ecef985bff94800649766021521515c8b170 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Wed, 15 Nov 2023 21:24:45 +0100 Subject: [PATCH 1/9] Update pre-commit hooks for `core` workspace Define pre-commit hooks for core package. Co-authored-by: Rafal Czajkowski --- .pre-commit-config.yaml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c700c60d4..a08515b37 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,21 +1,25 @@ repos: - repo: local hooks: - - id: lint-sol + # Core + - id: core-lint-sol name: "lint core sol" - entry: /usr/bin/env bash -c "cd core/ && npm run lint:sol" - files: '\.sol$' + entry: /usr/bin/env bash -c "npm --prefix ./core/ run lint:sol" + files: ^core/ + types: [solidity] language: script description: "Checks solidity code according to the package's linter configuration" - - id: lint-js + - id: core-lint-js name: "lint core ts/js" - entry: /usr/bin/env bash -c "cd core/ && npm run lint:js" - files: '\.(ts|js)$' + entry: /usr/bin/env bash -c "npm --prefix ./core/ run lint:js" + files: ^core/ + types_or: [ts, javascript] language: script description: "Checks TS/JS code according to the package's linter configuration" - - id: lint-config + - id: core-lint-config name: "lint core json/yaml" - entry: /usr/bin/env bash -c "cd core/ && npm run lint:config" - files: '\.(json|yaml)$' + entry: /usr/bin/env bash -c "npm --prefix ./core/ run lint:config" + files: ^core/ + types_or: [json, yaml] language: script description: "Checks JSON/YAML code according to the package's linter configuration" From 2d26889063c0ccfd931ca391386e37a40348b726 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Wed, 15 Nov 2023 21:29:22 +0100 Subject: [PATCH 2/9] Add pre-commit hooks for website workspace Co-authored-by: Rafal Czajkowski --- .pre-commit-config.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a08515b37..7e0cf2b8f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,3 +23,18 @@ repos: types_or: [json, yaml] language: script description: "Checks JSON/YAML code according to the package's linter configuration" + # Website + - id: website-lint-js + name: "lint website ts/js" + entry: /usr/bin/env bash -c "npm --prefix ./website/ run lint:js" + files: ^website/ + types_or: [ts, tsx, javascript, jsx] + language: script + description: "Checks TS/JS code according to the package's linter configuration" + - id: website-lint-config + name: "lint website json/yaml" + entry: /usr/bin/env bash -c "npm --prefix ./website/ run lint:config" + files: ^website/ + types_or: [json, yaml] + language: script + description: "Checks JSON/YAML code according to the package's linter configuration" From e62d6bcd7db860bf49a350e0e5938d4d98d105ef Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 23 Nov 2023 12:09:53 +0100 Subject: [PATCH 3/9] Add pre-commit hooks for dapp workspace --- .pre-commit-config.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7e0cf2b8f..e55db32ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,6 +23,21 @@ repos: types_or: [json, yaml] language: script description: "Checks JSON/YAML code according to the package's linter configuration" + # dApp + - id: dapp-lint-js + name: "lint dapp ts/js" + entry: /usr/bin/env bash -c "npm --prefix ./dapp/ run lint:js" + files: ^dapp/ + types_or: [ts, tsx, javascript, jsx] + language: script + description: "Checks TS/JS code according to the package's linter configuration" + - id: dapp-lint-config + name: "lint dapp json/yaml" + entry: /usr/bin/env bash -c "npm --prefix ./dapp/ run lint:config" + files: ^dapp/ + types_or: [json, yaml] + language: script + description: "Checks JSON/YAML code according to the package's linter configuration" # Website - id: website-lint-js name: "lint website ts/js" From d2a058fe6cfbab6f82d0d977d1b2d8bd9f494df1 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 23 Nov 2023 12:11:17 +0100 Subject: [PATCH 4/9] Auto-fix dapp files formatting --- dapp/manifest-ledger-live-app.json | 47 +++++++++++++----------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/dapp/manifest-ledger-live-app.json b/dapp/manifest-ledger-live-app.json index a6ed3d306..a03b1bb09 100644 --- a/dapp/manifest-ledger-live-app.json +++ b/dapp/manifest-ledger-live-app.json @@ -1,30 +1,23 @@ { - "id": "acre", - "name": "ACRE", - "url": "http://localhost:5173/", - "homepageUrl": "http://localhost:5173/", - "icon": "http://localhost:5173/acre.svg", - "platform": "all", - "apiVersion": "2.0.0", - "manifestVersion": "1", - "branch": "stable", - "categories": [ - "buy" - ], - "currencies": [ - "bitcoin", - "bitcoin_testnet" - ], - "content": { - "shortDescription": { - "en": "Bitcoin Liquid Staking" - }, - "description": { - "en": "Bitcoin Liquid Staking" - } + "id": "acre", + "name": "ACRE", + "url": "http://localhost:5173/", + "homepageUrl": "http://localhost:5173/", + "icon": "http://localhost:5173/acre.svg", + "platform": "all", + "apiVersion": "2.0.0", + "manifestVersion": "1", + "branch": "stable", + "categories": ["buy"], + "currencies": ["bitcoin", "bitcoin_testnet"], + "content": { + "shortDescription": { + "en": "Bitcoin Liquid Staking" }, - "permissions": [], - "domains": [ - "http://*" - ] + "description": { + "en": "Bitcoin Liquid Staking" + } + }, + "permissions": [], + "domains": ["http://*"] } From 214a6b4db4d6ab3b495ecec6aa09b79a00f2e36b Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 23 Nov 2023 12:13:36 +0100 Subject: [PATCH 5/9] Add auto-fix commit to git blame ignore revs --- .git-blame-ignore-revs | 2 ++ core/.git-blame-ignore-revs | 0 2 files changed, 2 insertions(+) create mode 100644 .git-blame-ignore-revs delete mode 100644 core/.git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 000000000..b4f1cac41 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Auto-fix linting +d2a058fe6cfbab6f82d0d977d1b2d8bd9f494df1 diff --git a/core/.git-blame-ignore-revs b/core/.git-blame-ignore-revs deleted file mode 100644 index e69de29bb..000000000 From a4a2b8511994206ed3cb8f8ea48da3c41eccff91 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 23 Nov 2023 12:20:59 +0100 Subject: [PATCH 6/9] Add info about testing pre-commit hooks config When configuring the hooks we may want to test them before pushing. --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 431a793c6..de2f62834 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,15 @@ To setup the hooks follow the steps: ```sh pre-commit install ``` + +#### Testing + +To test the pre-commit hooks configuration you can invoke them with one of the +commands: +```sh +# Execute hooks for all files: +pre-commit run --all-files + +# Execute hooks for specific files (e.g. Acre.sol): +pre-commit run --files ./core/contracts/Acre.sol +``` From feb21f18d22201b2e8a381155095d57308cd7ec2 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Fri, 17 Nov 2023 15:00:35 +0100 Subject: [PATCH 7/9] Add basic GH workflow for website workspace This is an initial implementation of the CI process to check formatting in `website` workspace. Co-authored-by: Rafal Czajkowski --- .github/workflows/website.yaml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/website.yaml diff --git a/.github/workflows/website.yaml b/.github/workflows/website.yaml new file mode 100644 index 000000000..e1b62779d --- /dev/null +++ b/.github/workflows/website.yaml @@ -0,0 +1,32 @@ +name: Website + +on: + push: + branches: + - main + paths: + - "website/**" + pull_request: + +defaults: + run: + working-directory: ./website + +jobs: + website-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version-file: "website/.nvmrc" + cache: "yarn" + cache-dependency-path: "website/yarn.lock" + + - name: Install Dependencies + run: yarn install --prefer-offline --frozen-lockfile + + - name: Format + run: yarn format From 4f0a6e68034498b2084f7fa48b54216db16abb52 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 23 Nov 2023 12:27:23 +0100 Subject: [PATCH 8/9] Add basic GH workflow for dapp workspace This is an initial implementation of the CI process to check formatting in `dapp` workspace. --- .github/workflows/dapp.yaml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/dapp.yaml diff --git a/.github/workflows/dapp.yaml b/.github/workflows/dapp.yaml new file mode 100644 index 000000000..a06389992 --- /dev/null +++ b/.github/workflows/dapp.yaml @@ -0,0 +1,32 @@ +name: dApp + +on: + push: + branches: + - main + paths: + - "dapp/**" + pull_request: + +defaults: + run: + working-directory: ./dapp + +jobs: + dapp-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version-file: "dapp/.nvmrc" + cache: "yarn" + cache-dependency-path: "dapp/yarn.lock" + + - name: Install Dependencies + run: yarn install --prefer-offline --frozen-lockfile + + - name: Format + run: yarn format From 530bb8644bdbafb5723e92bf8ac5bb71b412adf1 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 23 Nov 2023 12:34:04 +0100 Subject: [PATCH 9/9] Add build execution in dapp and website CI --- .github/workflows/dapp.yaml | 18 ++++++++++++++++++ .github/workflows/website.yaml | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/.github/workflows/dapp.yaml b/.github/workflows/dapp.yaml index a06389992..81dc9c31c 100644 --- a/.github/workflows/dapp.yaml +++ b/.github/workflows/dapp.yaml @@ -30,3 +30,21 @@ jobs: - name: Format run: yarn format + + dapp-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version-file: "dapp/.nvmrc" + cache: "yarn" + cache-dependency-path: "dapp/yarn.lock" + + - name: Install Dependencies + run: yarn install --prefer-offline --frozen-lockfile + + - name: Build + run: yarn build diff --git a/.github/workflows/website.yaml b/.github/workflows/website.yaml index e1b62779d..89583fbb3 100644 --- a/.github/workflows/website.yaml +++ b/.github/workflows/website.yaml @@ -30,3 +30,21 @@ jobs: - name: Format run: yarn format + + website-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version-file: "website/.nvmrc" + cache: "yarn" + cache-dependency-path: "website/yarn.lock" + + - name: Install Dependencies + run: yarn install --prefer-offline --frozen-lockfile + + - name: Build + run: yarn build