Skip to content

Commit

Permalink
fix: make turbo-ignore smarter (#1498)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored Sep 18, 2024
1 parent e097823 commit f5587b6
Show file tree
Hide file tree
Showing 28 changed files with 408 additions and 234 deletions.
12 changes: 11 additions & 1 deletion .github/actions/ete-docs-bundle/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ inputs:
deployment_url:
description: "The URL of the deployment to test"
required: true
token:
description: "The Vercel token to use for the deployment"
required: true

runs:
using: "composite"
steps:
- uses: ./.github/actions/install

- shell: bash
name: Fetch domains
run: pnpm vercel-scripts domains.txt ${{ inputs.deployment_url }} --token=${{ inputs.token }}

- name: Install Playwright Browsers
shell: bash
run: pnpm exec playwright install --with-deps
Expand All @@ -17,7 +26,8 @@ runs:
shell: bash
env:
DEPLOYMENT_URL: ${{ inputs.deployment_url }}
run: PLAYWRIGHT_JSON_OUTPUT_NAME=results.json pnpm exec playwright test playwright/smoke --workers 6 --reporter json
PLAYWRIGHT_JSON_OUTPUT_NAME: results.json
run: pnpm exec playwright test playwright/smoke --workers 6 --reporter json

- uses: daun/playwright-report-summary@v3
if: always()
Expand Down
55 changes: 55 additions & 0 deletions .github/actions/turbo-ignore/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Turbo Ignore
description: Ignore unchanged files in a Vercel deployment

inputs:
token:
description: "The Vercel token to use for the deployment"
required: true
project:
description: "The project to check for changes"
required: true
environment:
description: "The environment that turbo-ignore is checking against"
default: "preview"
package:
description: "The package to check for changes"
required: true
branch:
description: "The branch to check for changes"
required: false

outputs:
continue:
value: ${{ steps.ignore.outputs.continue }}
description: "Whether to continue with the deployment or not"

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
fetch-depth: 10

- uses: ./.github/actions/install

- name: Ignore unchanged files
shell: bash
id: ignore
run: |
# if ${{ inputs.branch }} is present, then we change the script to --branch=${{ inputs.branch }}
if [ -n "${{ inputs.branch }}" ]; then
pnpm vercel-scripts last-deploy.txt ${{ inputs.project }} --token=${{ inputs.token }} --environment=${{ inputs.environment }} --branch=${{ inputs.branch }}
else
pnpm vercel-scripts last-deploy.txt ${{ inputs.project }} --token=${{ inputs.token }} --environment=${{ inputs.environment }}
fi
if [ ! -f last-deploy.txt ]; then
echo "continue=1" >> $GITHUB_OUTPUT
exit 0
fi
set +e
pnpx turbo-ignore ${{ inputs.package }} --fallback=$(cat last-deploy.txt)
echo "continue=$?" >> $GITHUB_OUTPUT
21 changes: 9 additions & 12 deletions .github/workflows/deploy-docs-bundle-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ jobs:
continue: ${{ steps.ignore.outputs.continue }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # used for turbo-ignore

- name: Install
uses: ./.github/actions/install
with:
run_install: false

- name: Ignore unchanged files
id: ignore
run: set +e; pnpx turbo-ignore @fern-ui/docs-bundle --fallback=HEAD^1; echo "continue=$?" >> $GITHUB_OUTPUT
uses: ./.github/actions/turbo-ignore
with:
token: ${{ secrets.VERCEL_TOKEN }}
project: "app-dev.buildwithfern.com"
package: "@fern-ui/docs-bundle"
environment: "production"
branch: main

deploy:
needs: ignore
Expand All @@ -44,11 +42,10 @@ jobs:
with:
ref: ${{ github.ref_name || github.ref }}

- name: Install
uses: ./.github/actions/install
- uses: ./.github/actions/install

- name: Build & Deploy to Vercel
id: deploy
run: |
pnpm vercel-scripts deploy app-dev.buildwithfern.com --token=${{ secrets.VERCEL_TOKEN }} --environment=production --force
pnpm vercel-scripts deploy app-dev.buildwithfern.com --token=${{ secrets.VERCEL_TOKEN }} --environment=production
echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT
42 changes: 21 additions & 21 deletions .github/workflows/deploy-docs-bundle-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@ on:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.head.ref || github.ref_name || github.ref }}
cancel-in-progress: true

jobs:
ignore:
runs-on: ubuntu-latest
outputs:
continue: ${{ steps.ignore.outputs.continue }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # used for turbo-ignore

- name: Install
uses: ./.github/actions/install
with:
run_install: false

- name: Ignore unchanged files
id: ignore
run: set +e; pnpx turbo-ignore @fern-ui/docs-bundle --fallback=HEAD^1; echo "continue=$?" >> $GITHUB_OUTPUT
uses: ./.github/actions/turbo-ignore
with:
token: ${{ secrets.VERCEL_TOKEN }}
project: "app.buildwithfern.com"
package: "@fern-ui/docs-bundle"
environment: "preview"
branch: ${{ github.event.pull_request.head.ref || github.ref_name || github.ref }}

deploy:
needs: ignore
Expand All @@ -43,8 +45,7 @@ jobs:
fetch-depth: 2 # used for turbo-ignore
ref: ${{ github.event.pull_request.head.ref || github.ref_name || github.ref }}

- name: Install
uses: ./.github/actions/install
- uses: ./.github/actions/install

- name: Build & Deploy to Vercel
id: deploy
Expand Down Expand Up @@ -108,8 +109,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.ref || github.ref_name || github.ref }}

- name: Install
uses: ./.github/actions/install
- uses: ./.github/actions/install

- name: Build & Deploy to Vercel
id: deploy
Expand All @@ -118,20 +118,20 @@ jobs:
echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT
ete:
needs: deploy # only runs on fern-prod
if: needs.deploy.outputs.deployment_url
needs:
- ignore
- deploy # only runs on fern-prod
if: always()
runs-on: ubuntu-latest
permissions: write-all # required for the playwright-report-summary action
steps:
# if the job is ignored, skip the ETE test and exit 0 so that the this job can be used for merge protection
- uses: actions/checkout@v4

- name: Install
uses: ./.github/actions/install

- name: Fetch domains
run: pnpm vercel-scripts domains.txt ${{ needs.deploy.outputs.deployment_url }} --token=${{ secrets.VERCEL_TOKEN }}
if: needs.deploy.outputs.deployment_url

- name: Run E2E tests
uses: ./.github/actions/ete-docs-bundle
if: needs.deploy.outputs.deployment_url
with:
deployment_url: ${{ needs.deploy.outputs.deployment_url }}
token: ${{ secrets.VERCEL_TOKEN }}
25 changes: 5 additions & 20 deletions .github/workflows/deploy-docs-bundle-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ jobs:
outputs:
deployment_url: ${{ steps.deploy.outputs.deployment_url }}
steps:
# set the ref to a specific branch so that the deployment is scoped to that branch (instead of a headless ref)
- uses: actions/checkout@v4

- name: Install
uses: ./.github/actions/install
- uses: ./.github/actions/install

- name: Build & Deploy to Vercel
id: deploy
Expand All @@ -40,11 +37,8 @@ jobs:
outputs:
deployment_url: ${{ steps.deploy.outputs.deployment_url }}
steps:
# set the ref to a specific branch so that the deployment is scoped to that branch (instead of a headless ref)
- uses: actions/checkout@v4

- name: Install
uses: ./.github/actions/install
- uses: ./.github/actions/install

- name: Build & Deploy to Vercel
id: deploy
Expand All @@ -61,11 +55,9 @@ jobs:
outputs:
deployment_url: ${{ steps.deploy.outputs.deployment_url }}
steps:
# set the ref to a specific branch so that the deployment is scoped to that branch (instead of a headless ref)
- uses: actions/checkout@v4

- name: Install
uses: ./.github/actions/install
- uses: ./.github/actions/install

- name: Build & Deploy to Vercel
id: deploy
Expand All @@ -79,16 +71,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install
uses: ./.github/actions/install

- name: Fetch domains
run: pnpm vercel-scripts domains.txt app.buildwithfern.com --token ${{ secrets.VERCEL_TOKEN }}

- uses: ./github/actions/ete-docs-bundle
with:
deployment_url: ${{ needs.deploy_app_buildwithfern_com.outputs.deployment_url }}
token: ${{ secrets.VERCEL_TOKEN }}

promote:
needs:
Expand All @@ -106,8 +92,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install
uses: ./.github/actions/install
- uses: ./.github/actions/install

- name: Promote Deployment
run: pnpm vercel-scripts promote ${{ matrix.deployment_url }} --token ${{ secrets.VERCEL_TOKEN }}
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/deploy-fern-dashboard-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,25 @@ concurrency:
cancel-in-progress: true

jobs:
ignore:
runs-on: ubuntu-latest
outputs:
continue: ${{ steps.ignore.outputs.continue }}
steps:
- uses: actions/checkout@v4
- name: Ignore unchanged files
id: ignore
uses: ./.github/actions/turbo-ignore
with:
token: ${{ secrets.VERCEL_TOKEN }}
project: "dashboard-dev.buildwithfern.com"
package: "@fern-ui/dashboard"
environment: "production"
branch: main

deploy:
needs: ignore
if: needs.ignore.outputs.continue == 1
runs-on: ubuntu-latest
environment:
name: Production - dashboard-dev.buildwithfern.com
Expand All @@ -28,8 +46,7 @@ jobs:
with:
ref: main

- name: Install
uses: ./.github/actions/install
- uses: ./.github/actions/install

- name: Build & Deploy to Vercel
id: deploy
Expand Down
27 changes: 14 additions & 13 deletions .github/workflows/deploy-fern-dashboard-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,44 @@ on:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.head.ref || github.ref_name || github.ref }}
cancel-in-progress: true

jobs:
ignore:
runs-on: ubuntu-latest
outputs:
continue: ${{ steps.ignore.outputs.continue }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # used for turbo-ignore

- name: Install
uses: ./.github/actions/install
with:
run_install: false

- name: Ignore unchanged files
id: ignore
run: set +e; pnpx turbo-ignore @fern-ui/dashboard --fallback=HEAD^1; echo "continue=$?" >> $GITHUB_OUTPUT
uses: ./.github/actions/turbo-ignore
with:
token: ${{ secrets.VERCEL_TOKEN }}
project: "dashboard-dev.buildwithfern.com"
package: "@fern-ui/dashboard"
environment: "preview"
branch: ${{ github.event.pull_request.head.ref || github.ref_name || github.ref }}

deploy:
needs: ignore
if: needs.ignore.outputs.continue == 1
runs-on: ubuntu-latest
environment:
name: Preview - dashboard.buildwithfern.com
name: Preview - dashboard-dev.buildwithfern.com
url: ${{ steps.deploy.outputs.deployment_url }}
steps:
# set the ref to a specific branch so that the deployment is scoped to that branch (instead of a headless ref)
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref || github.ref_name || github.ref }}

- name: Install
uses: ./.github/actions/install
- uses: ./.github/actions/install

- name: Build & Deploy to Vercel
id: deploy
run: |
pnpm vercel-scripts deploy dashboard.buildwithfern.com --token=${{ secrets.VERCEL_TOKEN }}
pnpm vercel-scripts deploy dashboard-dev.buildwithfern.com --token=${{ secrets.VERCEL_TOKEN }}
echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT
5 changes: 1 addition & 4 deletions .github/workflows/deploy-fern-dashboard-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ jobs:
steps:
# set the ref to a specific branch so that the deployment is scoped to that branch (instead of a headless ref)
- uses: actions/checkout@v4
with:
ref: main

- name: Install
uses: ./.github/actions/install
- uses: ./.github/actions/install

- name: Build & Deploy to Vercel
id: deploy
Expand Down
Loading

0 comments on commit f5587b6

Please sign in to comment.