From 0b23364bbee857f89cbf37d82818c7ea4ba01791 Mon Sep 17 00:00:00 2001 From: Andrew Chou Date: Mon, 1 Apr 2024 13:16:23 -0400 Subject: [PATCH 1/6] add github workflow --- .github/workflows/ci.yml | 53 +++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- src/backend/package.json | 2 +- src/backend/tsconfig.json | 1 - 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..b9951ea99 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,53 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + # By default, a workflow only runs when a pull_request 's activity type is + # opened , synchronize , or reopened. Adding ready_for_review here ensures + # that CI runs when a PR is marked as not a draft, since we skip CI when a + # PR is draft + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + backend: + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: false + defaults: + run: + working-directory: './src/backend' + steps: + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + - name: Install deps + run: | + npm ci --ignore-scripts + npm run postinstall + - name: Check types + run: npm run types + + frontend: + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + - name: Install deps + run: npm ci + - name: Build translations + run: npm run build:translations + - name: Build Intl polyfills + run: npm run build:intl-polyfills + - name: Check types + run: npm run types diff --git a/package.json b/package.json index 5ec032dd8..983cd8411 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "deep-clean": "./scripts/deep-clean.sh", "build:translations": "node ./scripts/build-translations.js ", "build:intl-polyfills": "node ./scripts/build-intl-polyfills.mjs", - "extract-messages": "formatjs extract 'src/frontend/**/*.{ts,tsx}' --ignore='**/*.d.ts' --format crowdin --out-file ./messages/en.json" + "extract-messages": "formatjs extract 'src/frontend/**/*.{ts,tsx}' --ignore='**/*.d.ts' --format crowdin --out-file ./messages/en.json", + "types": "tsc --noEmit" }, "dependencies": { "@bam.tech/react-native-image-resizer": "^3.0.7", diff --git a/src/backend/package.json b/src/backend/package.json index 1c94f99aa..25446793c 100644 --- a/src/backend/package.json +++ b/src/backend/package.json @@ -7,7 +7,7 @@ "main": "index.js", "scripts": { "build": "node ./scripts/bundle-backend.mjs --entry=index.js --output=index.bundle.js", - "lint": "tsc", + "types": "tsc --noEmit", "postinstall": "patch-package" }, "author": "Digital Democracy", diff --git a/src/backend/tsconfig.json b/src/backend/tsconfig.json index a84cf6d25..4b44d9b33 100644 --- a/src/backend/tsconfig.json +++ b/src/backend/tsconfig.json @@ -7,7 +7,6 @@ "./node_modules/@digidem/types/vendor/*/index.d.ts" ] }, - "resolveJsonModule": true, "allowJs": true, "checkJs": true, "noEmit": true, From 3165590c1c637cc0a8beedb0b42d4901c1acfd8e Mon Sep 17 00:00:00 2001 From: Andrew Chou Date: Wed, 10 Apr 2024 11:06:01 -0400 Subject: [PATCH 2/6] update npm command --- .github/workflows/ci.yml | 2 +- package.json | 6 +++--- src/backend/package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9951ea99..90823af99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,4 +50,4 @@ jobs: - name: Build Intl polyfills run: npm run build:intl-polyfills - name: Check types - run: npm run types + run: npm run lint:types diff --git a/package.json b/package.json index 983cd8411..5a77d9ec8 100644 --- a/package.json +++ b/package.json @@ -12,15 +12,15 @@ "test": "jest", "lint:prettier": "prettier \"src/**/*.{js,ts,jsx,tsx}\" --check", "lint:eslint": "eslint . --ext .js,.jsx,.ts,.tsx --cache --ignore-path .gitignore", - "lint": "npm run lint:prettier && npm run lint:eslint", + "lint:types": "tsc --noEmit", + "lint": "npm run lint:prettier && npm run lint:eslint && npm run lint:types", "postinstall": "patch-package", "prepare": "husky install", "format": "prettier \"src/**/*.{js,ts,jsx,tsx}\" --write", "deep-clean": "./scripts/deep-clean.sh", "build:translations": "node ./scripts/build-translations.js ", "build:intl-polyfills": "node ./scripts/build-intl-polyfills.mjs", - "extract-messages": "formatjs extract 'src/frontend/**/*.{ts,tsx}' --ignore='**/*.d.ts' --format crowdin --out-file ./messages/en.json", - "types": "tsc --noEmit" + "extract-messages": "formatjs extract 'src/frontend/**/*.{ts,tsx}' --ignore='**/*.d.ts' --format crowdin --out-file ./messages/en.json" }, "dependencies": { "@bam.tech/react-native-image-resizer": "^3.0.7", diff --git a/src/backend/package.json b/src/backend/package.json index 25446793c..1d0613228 100644 --- a/src/backend/package.json +++ b/src/backend/package.json @@ -7,7 +7,7 @@ "main": "index.js", "scripts": { "build": "node ./scripts/bundle-backend.mjs --entry=index.js --output=index.bundle.js", - "types": "tsc --noEmit", + "lint:types": "tsc --noEmit", "postinstall": "patch-package" }, "author": "Digital Democracy", From e5549d33f8e06c06b4bec663f6e1359a3cdd577c Mon Sep 17 00:00:00 2001 From: Andrew Chou Date: Mon, 22 Apr 2024 13:31:41 -0400 Subject: [PATCH 3/6] Update .github/workflows/ci.yml Co-authored-by: Evan Hahn --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90823af99..b2bb35cbf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,8 +4,8 @@ on: push: branches: [main] pull_request: - # By default, a workflow only runs when a pull_request 's activity type is - # opened , synchronize , or reopened. Adding ready_for_review here ensures + # By default, a workflow only runs when a pull_request's activity type is + # opened, synchronize, or reopened. Adding ready_for_review here ensures # that CI runs when a PR is marked as not a draft, since we skip CI when a # PR is draft types: [opened, synchronize, reopened, ready_for_review] From 4675e08162dec9ad090334eb9880c5f4eeceb7a3 Mon Sep 17 00:00:00 2001 From: Andrew Chou Date: Mon, 22 Apr 2024 13:33:49 -0400 Subject: [PATCH 4/6] run formatting and unit test steps instead of types --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2bb35cbf..f1f9e5ea7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,5 +49,7 @@ jobs: run: npm run build:translations - name: Build Intl polyfills run: npm run build:intl-polyfills - - name: Check types - run: npm run lint:types + - name: Check formatting + run: npm run lint:prettier + - name: Run unit tests + run: npm test From c96b816524c6f26745049baf963dd199ae5ebe8f Mon Sep 17 00:00:00 2001 From: Andrew Chou Date: Mon, 22 Apr 2024 13:39:37 -0400 Subject: [PATCH 5/6] fix types check command for backend job --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1f9e5ea7..4987ef317 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: npm ci --ignore-scripts npm run postinstall - name: Check types - run: npm run types + run: npm run lint:types frontend: runs-on: ubuntu-latest From 7df6f57798a056af106432e7cdea283ec6902687 Mon Sep 17 00:00:00 2001 From: Andrew Chou Date: Mon, 22 Apr 2024 14:54:18 -0400 Subject: [PATCH 6/6] create separate job for shared checks --- .github/workflows/ci.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4987ef317..fea66f732 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,22 @@ on: types: [opened, synchronize, reopened, ready_for_review] jobs: + all: + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + - name: Install deps + run: npm ci + - name: Check formatting + run: npm run lint:prettier + backend: runs-on: ubuntu-latest timeout-minutes: 10 @@ -49,7 +65,5 @@ jobs: run: npm run build:translations - name: Build Intl polyfills run: npm run build:intl-polyfills - - name: Check formatting - run: npm run lint:prettier - name: Run unit tests run: npm test