Skip to content

Commit

Permalink
feat: deploy and enable turbo remote cache (#2315)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
JoCa96 authored Dec 13, 2024
1 parent 95b5e1c commit 5e1b90f
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/templates/cf-push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions .github/templates/node-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}-
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -67,3 +70,4 @@ jobs:
screenshots:
name: Component tests
uses: ./.github/workflows/playwright.yml
secrets: inherit
27 changes: 27 additions & 0 deletions .github/workflows/deploy-turbo-remote-cache.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .github/workflows/import-figma-icons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/import-figma.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/playwright-screenshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions apps/turbo-remote-cache/.cloud-foundry/manifest-prod.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 5e1b90f

Please sign in to comment.