Skip to content

chore: streamline CI workflows #2875

chore: streamline CI workflows

chore: streamline CI workflows #2875

# The jobs in this workflow are necessary because they are configured as
# required checks on PRs. Github does not currently support configuring required
# checks per workflow. A PR that only triggers codegen-ci.yml jobs will only
# report back with the "Codegen Tests" check. But because there is only a global
# option for required PR checks, that PR would otherwise never satisfy the
# "Typescript/Python/APIX Tests" checks without these noop jobs.
#
# References:
# https://github.yungao-tech.community/t/github-actions-and-required-checks-in-a-monorepo-using-paths-to-limit-execution/16586
# https://github.yungao-tech.community/t/feature-request-conditional-required-checks/16761/6
#
# Each job actually has a corresponding "real" job
# definition in a different workflow file:
#
# codegen-ci.yml: Codegen Tests
# tssdk-ci.yml: Typescript SDK Tests
# python-ci.yml: Python SDK Tests
# apix-ci.yml: APIX Tests
# go-ci.yml: Go SDK Tests
#
name: Required Checks Hack
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
permissions:
checks: write
actions: write
jobs:
satisfy-required-checks:
name: Satisfy Required Checks
runs-on: ubuntu-latest
steps:
- name: Repo Checkout
uses: actions/checkout@v4
- uses: tony84727/changed-file-filter@v0.2.3
id: filter
with:
filters: |
apix:
- 'package.json'
- 'packages/code-editor/**/*'
- 'packages/run-it/**/*'
- 'packages/api-explorer/**/*'
- 'packages/extension-api-explorer/**/*'
- 'packages/extension-utils/**/*'
- '.github/workflows/apix-ci.yml'
codegen:
- 'package.json'
- 'packages/sdk-codegen/**/*'
- 'packages/sdk-codegen-utils/**/*'
- 'packages/sdk-codegen-scripts/**/*'
- '.github/workflows/codegen-ci.yml'
hackathon:
- 'package.json'
- 'packages/wholly-sheet/**/*'
- 'packages/hackathon/**/*'
- '.github/workflows/hackathon-ci.yml'
python:
- 'python/**/*'
- '.github/workflows/python-ci.yml'
resources:
- 'bin/looker-resources-index/**/*'
- 'docs/resources/**/*'
- '.github/workflows/resources-ci.yml'
tssdk:
- 'package.json'
- 'packages/sdk/**/*'
- 'packages/sdk-rtl/**/*'
- 'packages/sdk-node/**/*'
- 'packages/extension-sdk/**/*'
- 'packages/extension-sdk-react/**/*'
- 'packages/extension-utils/**/*'
- '.github/workflows/tssdk-ci.yml'
gosdk:
- 'packages/go/**/*'
- '.github/workflows/go-ci.yml'
- name: Debug info
run: |
echo "${{ toJSON(steps.filter.outputs) }}"
echo "apix: ${{ steps.filter.outputs.apix }}"
echo "codegen: ${{ steps.filter.outputs.codegen }}"
echo "hackathon: ${{ steps.filter.outputs.hackathon }}"
echo "python: ${{ steps.filter.outputs.python }}"
echo "resources: ${{ steps.filter.outputs.resources }}"
echo "tssdk: ${{ steps.filter.outputs.tssdk }}"
echo "gosdk: ${{ steps.filter.outputs.gosdk }}"
echo "ref: ${{ github.ref }}"
- name: Lookup Workflows
id: lookup_workflows
run: |
response=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/looker-open-source/sdk-codegen/actions/workflows)
echo "workflows=$(jq -c '.workflows | map({id: .id,name: .name})' <<< $response)"
echo "workflows=$(jq -c '.workflows | map({id: .id,name: .name})' <<< $response)" >> "$GITHUB_OUTPUT"
- name: Trigger Automation Workflow
uses: benc-uk/workflow-dispatch@v1
if: false
with:
token: ${{ secrets.GITHUB_TOKEN }}
workflow: 'Codegen CI'
ref: ${{ github.event.pull_request.head.ref }}
- name: Create Codegen check
if: steps.filter.outputs.codegen != 'false'
run: |
workflow_id=$(echo '${{ steps.lookup_workflows.outputs.workflows }}' | jq '.[] | select( .name == "Codegen CI" ) .id')
echo "workflow_id: $workflow_id"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/looker-open-source/sdk-codegen/actions/workflows/$workflow_id/dispatches \
-d "{\"ref\": \"${{ github.event.pull_request.head.ref || github.ref }}\"}" \
--fail-with-body
- name: Create No Op Codegen check
if: steps.filter.outputs.codegen == 'false'
run: |
curl --request POST \
--url https://api.github.com/repos/looker-open-source/sdk-codegen/check-runs \
--header "authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--header "content-type: application/json" \
--header "Accept: application/vnd.github.v3+json" \
--data '{
"name": "Codegen Tests",
"head_sha": "${{ github.event.pull_request.head.sha || github.sha }}",
"output": {
"title": "Required Checks Hack / Codegen Tests",
"summary": "Associated files have not been changed so this can be skipped"
},
"conclusion": "success"
}' \
--fail-with-body
- name: Create Typescript check
if: steps.filter.outputs.tssdk != 'false'
run: |
workflow_id=$(echo '${{ steps.lookup_workflows.outputs.workflows }}' | jq '.[] | select( .name == "TypeScript SDK CI" ) .id')
echo "workflow_id: $workflow_id"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/looker-open-source/sdk-codegen/actions/workflows/$workflow_id/dispatches \
-d "{\"ref\": \"${{ github.event.pull_request.head.ref || github.ref }}\"}" \
--fail-with-body
- name: Create No Op Typescript check
if: steps.filter.outputs.tssdk == 'false'
run: |
curl --request POST \
--url https://api.github.com/repos/looker-open-source/sdk-codegen/check-runs \
--header "authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--header "content-type: application/json" \
--header "Accept: application/vnd.github.v3+json" \
--data '{
"name": "Typescript Tests",
"head_sha": "${{ github.event.pull_request.head.sha || github.sha }}",
"output": {
"title": "Required Checks Hack / Typescript Tests",
"summary": "Associated files have not been changed so this can be skipped"
},
"conclusion": "success"
}' \
--fail-with-body
- name: Create Python check
if: steps.filter.outputs.python != 'false'
run: |
workflow_id=$(echo '${{ steps.lookup_workflows.outputs.workflows }}' | jq '.[] | select( .name == "Python CI" ) .id')
echo "workflow_id: $workflow_id"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/looker-open-source/sdk-codegen/actions/workflows/$workflow_id/dispatches \
-d "{\"ref\": \"${{ github.event.pull_request.head.ref || github.ref }}\"}" \
--fail-with-body
- name: Create No Op Python check
if: steps.filter.outputs.python == 'false'
run: |
curl --request POST \
--url https://api.github.com/repos/looker-open-source/sdk-codegen/check-runs \
--header "authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--header "content-type: application/json" \
--header "Accept: application/vnd.github.v3+json" \
--data '{
"name": "Python Tests",
"head_sha": "${{ github.event.pull_request.head.sha || github.sha }}",
"output": {
"title": "Required Checks Hack / Python Tests",
"summary": "Associated files have not been changed so this can be skipped"
},
"conclusion": "success"
}' \
--fail-with-body
- name: Create APIX check
if: steps.filter.outputs.apix != 'false'
run: |
workflow_id=$(echo '${{ steps.lookup_workflows.outputs.workflows }}' | jq '.[] | select( .name == "API Explorer CI" ) .id')
echo "workflow_id: $workflow_id"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/looker-open-source/sdk-codegen/actions/workflows/$workflow_id/dispatches \
-d "{\"ref\": \"${{ github.event.pull_request.head.ref || github.ref }}\"}" \
--fail-with-body
- name: Create No Op APIX check
if: steps.filter.outputs.apix == 'false'
run: |
curl --request POST \
--url https://api.github.com/repos/looker-open-source/sdk-codegen/check-runs \
--header "authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--header "content-type: application/json" \
--header "Accept: application/vnd.github.v3+json" \
--data '{
"name": "APIX Tests",
"head_sha": "${{ github.event.pull_request.head.sha || github.sha }}",
"output": {
"title": "Required Checks Hack / APIX Tests",
"summary": "Associated files have not been changed so this can be skipped"
},
"conclusion": "success"
}' \
--fail-with-body
- name: Create Go check
if: steps.filter.outputs.gosdk != 'false'
run: |
workflow_id=$(echo '${{ steps.lookup_workflows.outputs.workflows }}' | jq '.[] | select( .name == "Go SDK CI" ) .id')
echo "workflow_id: $workflow_id"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/looker-open-source/sdk-codegen/actions/workflows/$workflow_id/dispatches \
-d "{\"ref\": \"${{ github.event.pull_request.head.ref || github.ref }}\"}" \
--fail-with-body
- name: Create No Op Go check
if: steps.filter.outputs.gosdk == 'false'
run: |
curl --request POST \
--url https://api.github.com/repos/looker-open-source/sdk-codegen/check-runs \
--header "authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--header "content-type: application/json" \
--header "Accept: application/vnd.github.v3+json" \
--data '{
"name": "Go Tests",
"head_sha": "${{ github.event.pull_request.head.sha || github.sha }}",
"output": {
"title": "Required Checks Hack / Go Tests",
"summary": "Associated files have not been changed so this can be skipped"
},
"conclusion": "success"
}' \
--fail-with-body