Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 109 additions & 54 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,72 +1,127 @@
name: Continuous Integration
on:
pull_request:
push:
branches:
- main

workflow_dispatch:
release:
types: [published]
jobs:
build-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-13, windows-latest, ubuntu-arm]
include:
- os: ubuntu-latest
checkGenCodeTarget: true
cloudTestTarget: true
- os: ubuntu-arm
runsOn: buildjet-4vcpu-ubuntu-2204-arm
runs-on: ${{ matrix.runsOn || matrix.os }}
env:
# We can't check this directly in the cloud test's `if:` condition below,
# so we have to check it here and report it in an env variable.
HAS_SECRETS: ${{ secrets.TEMPORAL_CLIENT_CERT != '' && secrets.TEMPORAL_CLIENT_KEY != '' }}
update:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
repository-projects: write
defaults:
run:
shell: bash
steps:
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }}
private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }}

- name: Checkout repository
uses: actions/checkout@v4
with:
path: cli
submodules: recursive
persist-credentials: true
token: ${{ steps.generate_token.outputs.token }}

- name: Setup Go
uses: actions/setup-go@v5
- name: Checkout docs repo
uses: actions/checkout@v4
with:
go-version-file: 'go.mod'

- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
repository: temporalio/documentation
persist-credentials: true
token: ${{ steps.generate_token.outputs.token }}
path: docs

- name: Create junit-xml directory
run: mkdir junit-xml

- name: Test
run: gotestsum --junitfile junit-xml/${{matrix.os}}.xml -- ./...

- name: 'Upload junit-xml artifacts'
uses: actions/upload-artifact@v4
if: always()
- name: Setup Go
uses: actions/setup-go@v4
with:
name: junit-xml--${{github.run_id}}--${{github.run_attempt}}--${{matrix.os}}
path: junit-xml
retention-days: 14
go-version: '1.22'

- name: Regen code, confirm unchanged
if: ${{ matrix.checkGenCodeTarget }}
- name: Generate CLI docs
run: |
go run ./temporalcli/internal/cmd/gen-commands
git diff --exit-code
cd cli/temporalcli/internal/cmd/gen-docs
go run .

- name: Test cloud
if: ${{ matrix.cloudTestTarget && env.HAS_SECRETS == 'true' }}
- name: Publish generated docs to cli repo
env:
TEMPORAL_ADDRESS: ${{ vars.TEMPORAL_CLIENT_NAMESPACE }}.tmprl.cloud:7233
TEMPORAL_NAMESPACE: ${{ vars.TEMPORAL_CLIENT_NAMESPACE }}
TEMPORAL_TLS_CERT: client.crt
TEMPORAL_TLS_CERT_CONTENT: ${{ secrets.TEMPORAL_CLIENT_CERT }}
TEMPORAL_TLS_KEY: client.key
TEMPORAL_TLS_KEY_CONTENT: ${{ secrets.TEMPORAL_CLIENT_KEY }}
shell: bash
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
set -e
set -x

if [ -z "$GH_TOKEN" ]; then
echo "GH_TOKEN is NOT set"
exit 1
else
echo "GH_TOKEN is set"
fi


curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" https://api.github.com/user

BRANCH_NAME="cli-update-docs-${{ github.ref_name }}"
# Remove the "/merge" suffix if it exists
BRANCH_NAME=${BRANCH_NAME%/merge}

cd cli

# Setup the committers identity.
git config --global user.email "sdk@temporal.io"
git config --global user.name "Temporal CLI"

git checkout -b $BRANCH_NAME
git add .
# TODO: mention CLI release version
git commit -m "CLI docs update, autogenerated on CLI release $LATEST_TAG, ${{ github.ref_name }}"
git push origin "$BRANCH_NAME"

gh pr create \
--body "Autogenerated PR from https://github.com/temporalio/cli" \
--title "CLI docs update $LATEST_TAG" \
--head "$BRANCH_NAME" \
--base "main"

- name: Publish generated docs to documentation repo
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
printf '%s\n' "$TEMPORAL_TLS_CERT_CONTENT" >> client.crt
printf '%s\n' "$TEMPORAL_TLS_KEY_CONTENT" >> client.key
go run ./cmd/temporal workflow list --limit 2
set -e
set -x

if [ -z "$GH_TOKEN" ]; then
echo "GH_TOKEN is NOT set"
exit 1
else
echo "GH_TOKEN is set"
fi

curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" https://api.github.com/user

BRANCH_NAME="cli-update-docs-${{ github.ref_name }}"
# Remove the "/merge" suffix if it exists
BRANCH_NAME=${BRANCH_NAME%/merge}

cd docs

# Setup the committers identity.
git config --global user.email "sdk@temporal.io"
git config --global user.name "Temporal CLI"

git checkout -b $BRANCH_NAME
cp ../cli/temporalcli/docs/*.mdx docs/cli/
git add .
# TODO: mention CLI release version
git commit -m "CLI docs update, autogenerated on CLI release $LATEST_TAG, ${{ github.ref_name }}"
git push origin "$BRANCH_NAME"

gh pr create \
--body "Autogenerated PR from https://github.com/temporalio/cli" \
--title "CLI docs update $LATEST_TAG" \
--head "$BRANCH_NAME" \
--base "main"
Loading
Loading