From c85c1a36a171172bc928dfec1e48ae022e15460a Mon Sep 17 00:00:00 2001 From: Dennis Kigen Date: Mon, 3 Apr 2023 17:16:12 +0300 Subject: [PATCH 1/2] (chore) Cache tasks in CI using turbo --- .github/workflows/ci.yml | 34 +++++++++++++++++++++++++++++----- package.json | 2 +- turbo.json | 3 +++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6433a8770..f8ac2bfbb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,17 +17,41 @@ env: jobs: build: runs-on: ubuntu-latest + env: + TURBO_API: 'http://127.0.0.1:9080' + TURBO_TOKEN: ${{ secrets.TURBO_SERVER_TOKEN }} + TURBO_TEAM: ${{ github.repository_owner }} steps: - uses: actions/checkout@v3 - - name: Use Node.js + - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '16' - - run: yarn install - - run: yarn lint - - run: yarn run test - - run: yarn build + + - name: Cache dependencies + id: cache + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: yarn + + - name: Setup local cache server for Turborepo + uses: felixmosh/turborepo-gh-artifacts@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + server-token: ${{ secrets.TURBO_SERVER_TOKEN }} + + - name: Run tests, lint and typechecking + run: yarn turbo verify + + - name: Run build + run: yarn turbo build --color --concurrency=5 + - name: Upload Artifacts uses: actions/upload-artifact@v2 with: diff --git a/package.json b/package.json index c8746de3d..6d31e12a4 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "homepage": "https://github.com/openmrs/openmrs-form-engine-lib#readme", "scripts": { "lint": "eslint src --ext tsx --fix", - "verify": "turbo run lint && turbo run typescript && yarn run test", + "verify": "turbo lint typescript", "prettier": "prettier --config prettier.config.js --write \"src/**/*.{ts,tsx}\"", "typescript": "tsc", "test": "jest --config ./jest.config.js --passWithNoTests", diff --git a/turbo.json b/turbo.json index daff48b48..bc810869c 100644 --- a/turbo.json +++ b/turbo.json @@ -23,6 +23,9 @@ "dev": { "cache": false, "persistent": true + }, + "verify": { + "outputs": [] } } } From 0aa0b7d8d21fbc76adb6d2b94f8bfe7903450971 Mon Sep 17 00:00:00 2001 From: Dennis Kigen Date: Mon, 3 Apr 2023 23:02:54 +0300 Subject: [PATCH 2/2] Fixup --- .github/workflows/ci.yml | 3 +-- package.json | 2 +- turbo.json | 21 ++------------------- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8ac2bfbb..c85322565 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,6 @@ on: env: ESM_NAME: "openmrs-form-engine-lib" JS_NAME: "openmrs-form-engine-lib.js" - jobs: build: runs-on: ubuntu-latest @@ -47,7 +46,7 @@ jobs: server-token: ${{ secrets.TURBO_SERVER_TOKEN }} - name: Run tests, lint and typechecking - run: yarn turbo verify + run: yarn verify - name: Run build run: yarn turbo build --color --concurrency=5 diff --git a/package.json b/package.json index 6d31e12a4..036235fd0 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "homepage": "https://github.com/openmrs/openmrs-form-engine-lib#readme", "scripts": { "lint": "eslint src --ext tsx --fix", - "verify": "turbo lint typescript", + "verify": "turbo lint typescript && yarn run test", "prettier": "prettier --config prettier.config.js --write \"src/**/*.{ts,tsx}\"", "typescript": "tsc", "test": "jest --config ./jest.config.js --passWithNoTests", diff --git a/turbo.json b/turbo.json index bc810869c..69747d8ef 100644 --- a/turbo.json +++ b/turbo.json @@ -2,30 +2,13 @@ "$schema": "https://turborepo.org/schema.json", "pipeline": { "build": { - "dependsOn": ["^build"], "outputs": ["dist/**"] }, "test": { "dependsOn": ["build"], - "outputs": [], "inputs": ["src/**/*.tsx", "src/**/*.ts", "test/**/*.ts", "test/**/*.tsx"] }, - "lint": { - "outputs": [] - }, - "typescript": { - "dependsOn": [], - "outputs": [] - }, - "extract-translations": { - "outputs": [] - }, - "dev": { - "cache": false, - "persistent": true - }, - "verify": { - "outputs": [] - } + "lint": {}, + "typescript": {} } }