From fe19eb2ee7ba32ad29313ecdffb29806c24bcbf3 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Fri, 17 Nov 2023 14:28:19 +0100 Subject: [PATCH 1/5] Update `core` workflow We can configure a workflow to run based on the what file paths are changed. Here we add `paths` filter under the `pull_request` event to run the `core` workflow only when changes happen in `./core` dir. --- .github/workflows/core.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/core.yaml b/.github/workflows/core.yaml index 7addece4a..5832c1119 100644 --- a/.github/workflows/core.yaml +++ b/.github/workflows/core.yaml @@ -7,6 +7,8 @@ on: paths: - "core/**" pull_request: + paths: + - "core/**" defaults: run: From 635a3cd81bf920d173b366eecdb386be85241d06 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Fri, 17 Nov 2023 14:40:13 +0100 Subject: [PATCH 2/5] Update the `lint.sh` script Because in this script we use bash features, the first line of the file must be `#!/bin/bash`. Otherwise GH actions won't run this script as `bash` and it will fail once problematic line is reached. --- lint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lint.sh b/lint.sh index 60f94544b..bd23a91ce 100755 --- a/lint.sh +++ b/lint.sh @@ -1,3 +1,4 @@ +#!/bin/bash set -euo pipefail # Defaults, can be overwritten by input parameters. From 05a0de3d5362b8c30b325c1fad00c85c668e6cf5 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Fri, 17 Nov 2023 14:48:31 +0100 Subject: [PATCH 3/5] Add new scripts to the `package.json` Here we add `format` and `format:fix` scripts to the root package.json file. We are going to run `format` script in the GH workflows and it will check code format for all supported types in a given workspace. --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 2b7d9115b..c9f9b665f 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,8 @@ "license": "MIT", "private": true, "scripts": { + "format": "./lint.sh", + "format:fix": "npm run format -- -f", "lint:js": "./lint.sh -t js", "lint:js:fix": "npm run lint:js -- -f", "lint:config": "./lint.sh -t config", From 26bf609eab6f5c106640b2c2792aba45aaf1292b Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Fri, 17 Nov 2023 14:52:39 +0100 Subject: [PATCH 4/5] Update `core` workflow Check if the code is correctly formatted in `core` workspace based on the global linting configuration. --- .github/workflows/core.yaml | 19 ++++++++++++++++--- .nvmrc | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 .nvmrc diff --git a/.github/workflows/core.yaml b/.github/workflows/core.yaml index 5832c1119..a3ec992e3 100644 --- a/.github/workflows/core.yaml +++ b/.github/workflows/core.yaml @@ -20,18 +20,31 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Node + - name: Set up Node in root + uses: actions/setup-node@v4 + with: + node-version-file: "./.nvmrc" + cache: "yarn" + cache-dependency-path: "./yarn.lock" + + - name: Install Dependencies in root + run: cd .. && yarn install --prefer-offline --frozen-lockfile + + - name: Set up Node in core package uses: actions/setup-node@v4 with: node-version-file: "core/.nvmrc" cache: "yarn" cache-dependency-path: "core/yarn.lock" - - name: Install Dependencies + - name: Install Dependencies in core package run: yarn install --prefer-offline --frozen-lockfile + - name: Make the script file executable + run: cd .. && chmod +x lint.sh + - name: Format - run: yarn format + run: cd .. && yarn format -w core core-build: runs-on: ubuntu-latest diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..9de225682 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/iron From 0af26734daaf0ea9f5f4c3efd49d01d1800f9fd6 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Fri, 17 Nov 2023 15:00:35 +0100 Subject: [PATCH 5/5] Add basic GH workflow for website workspace This is an initial implementation of the CI process to check formatting in `website` workspace. --- .github/workflows/website.yaml | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 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..101a64f75 --- /dev/null +++ b/.github/workflows/website.yaml @@ -0,0 +1,47 @@ +name: Website + +on: + push: + branches: + - main + paths: + - "website/**" + pull_request: + paths: + - "website/**" + +defaults: + run: + working-directory: ./website + +jobs: + core-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Node in root + uses: actions/setup-node@v4 + with: + node-version-file: "./.nvmrc" + cache: "yarn" + cache-dependency-path: "./yarn.lock" + + - name: Install Dependencies in root + run: cd .. && yarn install --prefer-offline --frozen-lockfile + + - name: Set up Node in website package + uses: actions/setup-node@v4 + with: + node-version-file: "website/.nvmrc" + cache: "yarn" + cache-dependency-path: "website/yarn.lock" + + - name: Install Dependencies in website package + run: yarn install --prefer-offline --frozen-lockfile + + - name: Make the script file executable + run: cd .. && chmod +x lint.sh + + - name: Format + run: cd .. && yarn format -w website