From c85c1a36a171172bc928dfec1e48ae022e15460a Mon Sep 17 00:00:00 2001 From: Dennis Kigen Date: Mon, 3 Apr 2023 17:16:12 +0300 Subject: [PATCH] (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": [] } } }