Skip to content

Commit 58617b9

Browse files
committed
GHA: Move lint and docs to external wf definition
1 parent fdd47d5 commit 58617b9

File tree

4 files changed

+163
-179
lines changed

4 files changed

+163
-179
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ on:
99

1010
env:
1111
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12-
IS_OFFICIAL_REPO: ${{ github.repository == 'temporalio/sdk-typescript' }}
1312
# Is it the official main branch, or an official release branches?
13+
#
14+
# Variable IS_TEMPORALIO_SDK_TYPESCRIPT_REPO is configured to true on the official repo.
15+
# It can be used to determine if the present execution has access to secrets or not.
16+
#
1417
# AFAIK there's no way to break that line w/o introducing a trailing LF that breaks usage. Sorry.
15-
IS_MAIN_OR_RELEASE: ${{ github.repository == 'temporalio/sdk-typescript' && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/releases')) && github.event_name != 'pull_request' }}
18+
IS_MAIN_OR_RELEASE: ${{ vars.IS_TEMPORALIO_SDK_TYPESCRIPT_REPO == 'true' && github.event_name != 'pull_request' && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/releases')) }}
1619

1720
# Use these variables to force specific version of CLI/Time Skipping Server for SDK tests
1821
# TESTS_CLI_VERSION: 'v0.13.2'
@@ -448,123 +451,12 @@ jobs:
448451
test-timeout-minutes: 20
449452
reuse-v8-context: true
450453

451-
# Run TS linting and ts-prune to find unused code
452-
lint-and-prune:
453-
name: Lint and Prune
454-
strategy:
455-
# Using a matrix here ensure that Rust-related actions below can be easily be copied from the
456-
# compile-binairies job and that the Rust build cache will be usable
457-
matrix:
458-
include:
459-
- platform: linux-x64
460-
runner: ubuntu-latest-4-cores
461-
target: x86_64-unknown-linux-gnu
462-
runs-on: ${{ matrix.runner }}
463-
steps:
464-
- name: Checkout code
465-
uses: actions/checkout@v4
466-
with:
467-
submodules: recursive
468-
469-
- name: Install Node
470-
uses: actions/setup-node@v4
471-
with:
472-
node-version: 20
473-
474-
- name: Get NPM cache directory
475-
id: npm-cache-dir
476-
shell: bash
477-
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
478-
479-
- name: Restore NPM cache
480-
uses: actions/cache/restore@v4
481-
with:
482-
path: ${{ steps.npm-cache-dir.outputs.dir }}
483-
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
484-
restore-keys: |
485-
npm-main-${{ matrix.platform }}-
486-
487-
- name: Install Rust
488-
uses: dtolnay/rust-toolchain@stable
489-
with:
490-
target: ${{ matrix.target }}
491-
492-
- name: Install protoc
493-
uses: arduino/setup-protoc@v3
494-
with:
495-
# TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
496-
version: '23.x'
497-
repo-token: ${{ secrets.GITHUB_TOKEN }}
498-
499-
- name: Rust Cargo and Build cache
500-
uses: Swatinem/rust-cache@v2
501-
with:
502-
workspaces: packages/core-bridge -> target
503-
prefix-key: corebridge-buildcache
504-
shared-key: ${{ matrix.platform }}
505-
env-vars: ''
506-
save-if: false
507-
508-
- name: Download dependencies
509-
run: |
510-
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
511-
512-
# eslint-import-resolver-typescript requires packages to be built
513-
- name: Compile all non-rust code
514-
run: npm run build -- --ignore @temporalio/core-bridge
515-
516-
- run: npm run lint.check
517-
- run: npm run lint.prune
518-
519-
build-docs:
454+
docs:
520455
name: Build Docs
521-
strategy:
522-
# Using a matrix here ensure that Rust-related actions below can be easily be copied from the
523-
# compile-binairies job and that the Rust build cache will be usable
524-
matrix:
525-
include:
526-
- platform: linux-x64
527-
runner: ubuntu-latest-4-cores
528-
target: x86_64-unknown-linux-gnu
529-
runs-on: ${{ matrix.runner }}
530-
steps:
531-
- name: Checkout code
532-
uses: actions/checkout@v4
533-
with:
534-
submodules: recursive
535-
536-
- name: Install Node
537-
uses: actions/setup-node@v4
538-
with:
539-
node-version: 20
540-
541-
- name: Get NPM cache directory
542-
id: npm-cache-dir
543-
shell: bash
544-
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
545-
546-
- name: Restore NPM cache
547-
uses: actions/cache/restore@v4
548-
with:
549-
path: ${{ steps.npm-cache-dir.outputs.dir }}
550-
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
551-
restore-keys: |
552-
npm-main-${{ matrix.platform }}-
553-
554-
# Don't build during install phase since we're going to explicitly build
555-
- name: Download dependencies
556-
# Make up to 3 attempts to install NPM dependencies, to work around transient NPM errors
557-
run: |
558-
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
559-
560-
- run: npm run build -- --ignore @temporalio/core-bridge
561-
562-
- name: Build docs
563-
run: npm run docs
564-
env:
565-
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
566-
567-
- name: Deploy draft docs
568-
# Can't run on forks, since secrets won't be available, and command will fail
569-
if: ${{ env.IS_OFFICIAL_REPO == 'true'}}
570-
run: npx vercel deploy packages/docs/build -t ${{ secrets.VERCEL_TOKEN }} --name typescript --scope temporal --yes
456+
uses: ./.github/workflows/docs.yml
457+
with:
458+
# Can't publish from forks, as secrets won't be available
459+
publish_target: ${{ vars.IS_TEMPORALIO_SDK_TYPESCRIPT_REPO == 'true' && 'draft' || '' }}
460+
secrets:
461+
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
462+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}

.github/workflows/conventions.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Conventions
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- releases/*
9+
10+
env:
11+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
13+
jobs:
14+
lint-and-prune:
15+
name: Lint and Prune
16+
runs-on: ubuntu-latest-4-cores
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
23+
- name: Install Node
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
28+
- name: Get NPM cache directory
29+
id: npm-cache-dir
30+
shell: bash
31+
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
32+
33+
- name: Restore NPM cache
34+
uses: actions/cache/restore@v4
35+
with:
36+
path: ${{ steps.npm-cache-dir.outputs.dir }}
37+
key: npm-main-linux-x64-${{ hashFiles('./package-lock.json') }}
38+
restore-keys: |
39+
npm-main-linux-x64-
40+
41+
- name: Install Rust
42+
uses: dtolnay/rust-toolchain@stable
43+
with:
44+
target: x86_64-unknown-linux-gnu
45+
46+
- name: Install protoc
47+
uses: arduino/setup-protoc@v3
48+
with:
49+
version: '23.x'
50+
repo-token: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Rust Cargo and Build cache
53+
uses: Swatinem/rust-cache@v2
54+
with:
55+
workspaces: packages/core-bridge -> target
56+
prefix-key: corebridge-buildcache
57+
shared-key: linux-x64
58+
env-vars: ''
59+
save-if: false
60+
61+
- name: Download dependencies
62+
run: |
63+
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
64+
65+
# eslint-import-resolver-typescript requires packages to be built
66+
- name: Compile all non-rust code
67+
run: npm run build -- --ignore @temporalio/core-bridge
68+
69+
- run: npm run lint.check
70+
- run: npm run lint.prune

.github/workflows/docs.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Docs
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
publish_target:
7+
required: true
8+
type: string
9+
description: |
10+
Whether to publish the docs. Set to either 'prod' or 'draft', or leave unset to skip publishing.
11+
secrets:
12+
ALGOLIA_API_KEY:
13+
required: false
14+
description: The Algolia API key. Required if 'publish_target' is set.
15+
VERCEL_TOKEN:
16+
required: false
17+
description: The Vercel token. Required if 'publish_target' is set.
18+
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
22+
jobs:
23+
build-docs:
24+
name: Build Docs
25+
runs-on: ubuntu-latest-4-cores
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
with:
30+
submodules: recursive
31+
32+
- name: Install Node
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: 20
36+
37+
- name: Get NPM cache directory
38+
id: npm-cache-dir
39+
shell: bash
40+
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
41+
42+
- name: Restore NPM cache
43+
uses: actions/cache/restore@v4
44+
with:
45+
path: ${{ steps.npm-cache-dir.outputs.dir }}
46+
key: npm-main-linux-x64-${{ hashFiles('./package-lock.json') }}
47+
restore-keys: |
48+
npm-main-linux-x64-
49+
50+
- name: Download dependencies
51+
# Make up to 3 attempts to install NPM dependencies, to work around transient NPM errors
52+
# Don't build during install phase since we're going to explicitly build anyway
53+
run: |
54+
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
55+
56+
- run: npm run build -- --ignore @temporalio/core-bridge
57+
58+
- name: Build docs
59+
run: npm run docs
60+
env:
61+
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
62+
63+
- name: Publish docs
64+
if: ${{ inputs.publish_target }}
65+
run: |
66+
npx vercel deploy packages/docs/build \
67+
-t '${{ secrets.VERCEL_TOKEN }}' \
68+
--name typescript \
69+
--scope temporal \
70+
--yes \
71+
${{ inputs.publish_target == 'prod' && '--prod' || '' }}

.github/workflows/release.yml

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ on:
99

1010
env:
1111
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12-
IS_OFFICIAL_REPO: ${{ github.repository == 'temporalio/sdk-typescript' }}
1312
# Is it the official main branch, or an official release branches?
1413
# AFAIK there's no way to break that line w/o introducing a trailing LF that breaks usage. Sorry.
15-
IS_MAIN_OR_RELEASE: ${{ github.repository == 'temporalio/sdk-typescript' && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/releases')) && github.event_name != 'pull_request' }}
14+
IS_MAIN_OR_RELEASE: ${{ vars.IS_TEMPORALIO_SDK_TYPESCRIPT_REPO == 'true' && github.event_name != 'pull_request' && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/releases')) }}
1615

1716
# Use these variables to force specific version of CLI/Time Skipping Server for SDK tests
1817
# TESTS_CLI_VERSION: 'v0.13.2'
@@ -337,60 +336,12 @@ jobs:
337336
run: rm -rf ${{ runner.temp }}/certs
338337
continue-on-error: true
339338

340-
build-docs:
339+
docs:
341340
name: Build Docs
342-
strategy:
343-
# Using a matrix here ensure that Rust-related actions below can be easily be copied from the
344-
# compile-binairies job and that the Rust build cache will be usable
345-
matrix:
346-
include:
347-
- platform: linux-x64
348-
runner: ubuntu-latest-4-cores
349-
runs-on: ${{ matrix.runner }}
350-
steps:
351-
- name: Checkout code
352-
uses: actions/checkout@v4
353-
with:
354-
submodules: recursive
355-
356-
- name: Install Node
357-
uses: actions/setup-node@v4
358-
with:
359-
node-version: 20
360-
361-
- name: Get NPM cache directory
362-
id: npm-cache-dir
363-
shell: bash
364-
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
365-
366-
- name: Restore NPM cache
367-
uses: actions/cache/restore@v4
368-
with:
369-
path: ${{ steps.npm-cache-dir.outputs.dir }}
370-
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
371-
restore-keys: |
372-
npm-main-${{ matrix.platform }}-
373-
374-
# Don't build during install phase since we're going to explicitly build
375-
- name: Download dependencies
376-
# Make up to 3 attempts to install NPM dependencies, to work around transient NPM errors
377-
run: |
378-
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
379-
380-
- run: npm run build -- --ignore @temporalio/core-bridge
381-
382-
# Do docs stuff (only on one host)
383-
- name: Build docs
384-
run: npm run docs
385-
env:
386-
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
387-
388-
- name: Deploy draft docs
389-
# Can't run on forks, since secrets won't be available, and command will fail
390-
if: ${{ env.IS_OFFICIAL_REPO == 'true'}}
391-
run: npx vercel deploy packages/docs/build -t ${{ secrets.VERCEL_TOKEN }} --name typescript --scope temporal --yes
392-
393-
# FIXME: Only run this on release
394-
- name: Deploy prod docs # TODO: only deploy prod docs when we publish a new version
395-
if: ${{ env.IS_MAIN_OR_RELEASE == 'true' }}
396-
run: npx vercel deploy packages/docs/build -t ${{ secrets.VERCEL_TOKEN }} --name typescript --scope temporal --prod --yes
341+
uses: ./.github/workflows/docs.yml
342+
with:
343+
# Can't publish from forks, as secrets won't be available
344+
publish_target: prod
345+
secrets:
346+
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
347+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}

0 commit comments

Comments
 (0)