From 5e1b90f37b0ca2aa258c14d5f3d603034214cb15 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 13 Dec 2024 10:28:54 +0100 Subject: [PATCH] feat: deploy and enable turbo remote cache (#2315) - Add deployment pipeline and manifest for [turborepo-remote-cache](https://ducktors.github.io/turborepo-remote-cache/) - Configure all CI pipelines to make use of the remote cache - Add `varArgs` input to GitHub `cf-push` custom action, which allows passing custom vars to be used in the manifest --- .github/templates/cf-push/action.yml | 5 +++- .github/templates/node-setup/action.yml | 3 +-- .github/workflows/check.yml | 4 +++ .../workflows/deploy-turbo-remote-cache.yml | 27 +++++++++++++++++++ .github/workflows/import-figma-icons.yml | 3 +++ .github/workflows/import-figma.yml | 3 +++ .github/workflows/playwright-screenshots.yml | 4 +++ .github/workflows/playwright.yml | 2 ++ .github/workflows/release.yml | 1 + .../.cloud-foundry/manifest-prod.yml | 14 ++++++++++ turbo.json | 5 ++++ 11 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/deploy-turbo-remote-cache.yml create mode 100644 apps/turbo-remote-cache/.cloud-foundry/manifest-prod.yml diff --git a/.github/templates/cf-push/action.yml b/.github/templates/cf-push/action.yml index 5df63eddd9..57150cc8fa 100644 --- a/.github/templates/cf-push/action.yml +++ b/.github/templates/cf-push/action.yml @@ -20,6 +20,9 @@ inputs: working-directory: required: true description: Directory where the push command is executed in (manifest, Staticfile etc. must be placed inside this folder) + varArgs: + default: "" + description: Variables argument strings used for variable substitution file in manifest. Must be provided in the form of `--var KEY1=VALUE1 --var KEY2=VALUE2` runs: using: "composite" @@ -39,7 +42,7 @@ runs: - name: Deploy (${{ inputs.space }}) shell: bash - run: cf push --manifest "./manifest-${{ inputs.space }}.yml" --strategy rolling + run: cf push --manifest "./manifest-${{ inputs.space }}.yml" --strategy rolling ${{ inputs.varArgs }} working-directory: ${{ inputs.working-directory }} - name: Logout from Cloud Foundry diff --git a/.github/templates/node-setup/action.yml b/.github/templates/node-setup/action.yml index a925cbab2d..2105a2f16c 100644 --- a/.github/templates/node-setup/action.yml +++ b/.github/templates/node-setup/action.yml @@ -40,9 +40,8 @@ runs: uses: actions/cache@v4 with: path: | - **/.turbo **/.cache - key: build-caches-${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/.turbo', '**/.cache') }} + key: build-caches-${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/.cache') }} restore-keys: | build-caches-${{ runner.os }}-${{ steps.get-date.outputs.date }}- build-caches-${{ runner.os }}- diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index dbc55e304d..25b527261d 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -9,6 +9,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true +env: + TURBO_TOKEN: ${{ secrets.TURBO_REMOTE_CACHE__TURBO_TOKEN }} + jobs: check: name: Check code quality @@ -67,3 +70,4 @@ jobs: screenshots: name: Component tests uses: ./.github/workflows/playwright.yml + secrets: inherit diff --git a/.github/workflows/deploy-turbo-remote-cache.yml b/.github/workflows/deploy-turbo-remote-cache.yml new file mode 100644 index 0000000000..9420d270b8 --- /dev/null +++ b/.github/workflows/deploy-turbo-remote-cache.yml @@ -0,0 +1,27 @@ +name: Deploy Turbo Remote Cache +on: + push: + branches: + - "main" + paths: + - "apps/turbo-remote-cache/**" + workflow_dispatch: + +jobs: + deploy: + name: Deploy to CloudFoundry + runs-on: ubuntu-latest + environment: prod + steps: + - uses: actions/checkout@v4 + + - name: Deploy to Cloud Foundry + uses: ./.github/templates/cf-push + with: + endpoint: ${{ vars.CF_ENDPOINT }} + org: ${{ vars.CF_ORG }} + username: ${{ vars.CF_USERNAME }} + password: ${{ secrets.CF_PASSWORD }} + space: prod + varArgs: "--var TURBO_TOKEN=${{ secrets.TURBO_REMOTE_CACHE__TURBO_TOKEN }} --var AWS_ACCESS_KEY_ID=${{ secrets.TURBO_REMOTE_CACHE__AWS_ACCESS_KEY_ID }} --var AWS_SECRET_ACCESS_KEY=${{ secrets.TURBO_REMOTE_CACHE__AWS_SECRET_ACCESS_KEY }}" + working-directory: apps/turbo-remote-cache/.cloud-foundry diff --git a/.github/workflows/import-figma-icons.yml b/.github/workflows/import-figma-icons.yml index 1a83bbeba6..d18b3c1e6d 100644 --- a/.github/workflows/import-figma-icons.yml +++ b/.github/workflows/import-figma-icons.yml @@ -4,6 +4,9 @@ on: schedule: - cron: "0 6 * * *" # run daily at 6 am +env: + TURBO_TOKEN: ${{ secrets.TURBO_REMOTE_CACHE__TURBO_TOKEN }} + jobs: import: name: Import Figma icons diff --git a/.github/workflows/import-figma.yml b/.github/workflows/import-figma.yml index be293a7a60..4b91c81ea6 100644 --- a/.github/workflows/import-figma.yml +++ b/.github/workflows/import-figma.yml @@ -2,6 +2,9 @@ name: Import Figma variables on: workflow_dispatch: +env: + TURBO_TOKEN: ${{ secrets.TURBO_REMOTE_CACHE__TURBO_TOKEN }} + jobs: import: name: Import Figma variables diff --git a/.github/workflows/playwright-screenshots.yml b/.github/workflows/playwright-screenshots.yml index d86e5b2124..d1ec2452f7 100644 --- a/.github/workflows/playwright-screenshots.yml +++ b/.github/workflows/playwright-screenshots.yml @@ -2,9 +2,13 @@ name: Update Playwright screenshots on: workflow_dispatch: +env: + TURBO_TOKEN: ${{ secrets.TURBO_REMOTE_CACHE__TURBO_TOKEN }} + jobs: screenshots: uses: ./.github/workflows/playwright.yml + secrets: inherit with: update-snapshots: true diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 0f97e65425..ac75241624 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -20,6 +20,8 @@ jobs: shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] name: Playwright shard runs-on: ubuntu-latest + env: + TURBO_TOKEN: ${{ secrets.TURBO_REMOTE_CACHE__TURBO_TOKEN }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e252207eac..a1406b1dd8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,7 @@ on: env: # The release + deployment will be done on "prod" stage if on main branch, on "dev" stage otherwise STAGE: ${{ github.ref_name == 'main' && 'prod' || 'dev' }} + TURBO_TOKEN: ${{ secrets.TURBO_REMOTE_CACHE__TURBO_TOKEN }} jobs: release: diff --git a/apps/turbo-remote-cache/.cloud-foundry/manifest-prod.yml b/apps/turbo-remote-cache/.cloud-foundry/manifest-prod.yml new file mode 100644 index 0000000000..3ef6c9ccf7 --- /dev/null +++ b/apps/turbo-remote-cache/.cloud-foundry/manifest-prod.yml @@ -0,0 +1,14 @@ +applications: + - name: turbo-remote-cache + instances: 2 + memory: 256MB + disk_quota: 1GB + docker: + image: ducktors/turborepo-remote-cache + env: + TURBO_TOKEN: ((TURBO_TOKEN)) + STORAGE_PROVIDER: s3 + STORAGE_PATH: turbo-remote-cache + AWS_ACCESS_KEY_ID: ((AWS_ACCESS_KEY_ID)) + AWS_SECRET_ACCESS_KEY: ((AWS_SECRET_ACCESS_KEY)) + S3_ENDPOINT: https://object.storage.eu01.onstackit.cloud diff --git a/turbo.json b/turbo.json index f432653e2d..1428acbac0 100644 --- a/turbo.json +++ b/turbo.json @@ -1,5 +1,10 @@ { "$schema": "https://turbo.build/schema.json", + "remoteCache": { + "apiUrl": "https://turbo-remote-cache.apps.01.cf.eu01.stackit.cloud", + "teamSlug": "onyx", + "enabled": true + }, "globalDependencies": ["pnpm-lock.yaml"], "tasks": { "build": {