Skip to content

Action inputs to dispatch n-runs of a single test in CI #9

Action inputs to dispatch n-runs of a single test in CI

Action inputs to dispatch n-runs of a single test in CI #9

Workflow file for this run

name: All Tests
on:
pull_request:
push:
branches:
- main
- release/**
- cloud/**
workflow_dispatch:
inputs:
commit:
description: "Commit SHA"
required: true
run_single_functional_test:
description: "Whether to run a single test. If so, the rest of the input fields are required."
type: boolean
default: false
n_runs:
description: "[Single Test Only] Number of times to repeat the single test per database type"
type: number
default: 1
test_name:
description: "[Single Test Only] Name of the test to run (i.e. 'TestAcquireShard_DeadlineExceededErrorSuite' or 'TestFunctionalSuite/TestUpdateWorkflow')"
type: string
timeout_minutes:
description: "[Single Test Only] Test timeout in minutes"
type: number
default: 120
test_runner:
description: "[Single Test Only] Which runner to use. Choose higher RAM if your n_runs is high."
type: choice
default: "16GB RAM (ubuntu-20.04)"
options:
- "16GB RAM (ubuntu-20.04)"
- "64GB RAM (ubuntu-22.04)"
db:
description: "[Single Test Only] The DB to use for your tests"
type: choice
default: "sqlite"
options:
- cass_es
# - cass_es8
- sqlite
- mysql8
- postgres12
- postgres12_pgx
concurrency: # Auto-cancel existing runs in the PR when a new commit is pushed
group: run-tests-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
# For workflow_dispatch: use the given commit.
# For pull_request: use the head of the PR branch (not the merge branch which is the default!)
# For push: use the pushed commit.
COMMIT: ${{ github.event.inputs.commit || github.event.pull_request.head.sha || github.sha }}
PR_BASE_COMMIT: ${{ github.event.pull_request.base.sha }}
DOCKER_COMPOSE_FILE: ./develop/github/docker-compose.yml
TEMPORAL_VERSION_CHECK_DISABLED: 1
BUILDKITE_ANALYTICS_TOKEN: ${{ secrets.BUILDKITE_ANALYTICS_TOKEN }}
jobs:
set-up-functional-test:
name: Set up functional test
runs-on: ubuntu-20.04
outputs:
shard_indices: ${{ steps.generate_output.outputs.shard_indices }}
total_shards: ${{ steps.generate_output.outputs.shards }}
github_timeout: ${{ steps.generate_output.outputs.github_timeout }}
test_timeout: ${{ steps.generate_output.outputs.test_timeout }}
single_test_args: ${{ steps.generate_output.outputs.single_test_args }}
runs_on: ${{ steps.generate_output.outputs.runs_on }}
steps:
- id: generate_output
run: |
shards=3
timeout=30
runs_on='["ubuntu-20.04"]'
if [[ "${{ inputs.run_single_functional_test }}" == "true" ]]; then
shards=1
timeout=${{ inputs.timeout_minutes }}
single_test_args="-run ${{ inputs.test_name }} -count ${{ inputs.n_runs }}"
if [[ "${{ inputs.test_runner }}" == "64GB RAM (ubuntu-22.04)" ]]; then
runs_on='["ubuntu-latest-16-cores"]'
fi
fi
{
echo "shard_indices=[$(seq -s, 0 $((shards-1)))]"
echo "shards=$shards"
echo "github_timeout=$((timeout+5))"
echo "test_timeout=${timeout}m"
echo "single_test_args=$single_test_args"
echo "runs_on=$runs_on"
} >> "$GITHUB_OUTPUT"
functional-test:
name: Functional test
needs: [set-up-functional-test]
strategy:
fail-fast: false
matrix:
runs-on: ${{ fromJson(needs.set-up-functional-test.outputs.runs_on) }}
shard_index: ${{ fromJson(needs.set-up-functional-test.outputs.shard_indices) }}
name:
- cass_es
# - cass_es8
- sqlite
- mysql8
- postgres12
- postgres12_pgx
include:
- name: cass_es
persistence_type: nosql
persistence_driver: cassandra
containers: [cassandra, elasticsearch]
# - name: cass_es8
# persistence_type: nosql
# persistence_driver: cassandra
# containers: [cassandra, elasticsearch8]
- name: sqlite
persistence_type: sql
persistence_driver: sqlite
containers: []
- name: mysql8
persistence_type: sql
persistence_driver: mysql8
containers: [mysql]
- name: postgres12
persistence_type: sql
persistence_driver: postgres12
containers: [postgresql]
- name: postgres12_pgx
persistence_type: sql
persistence_driver: postgres12_pgx
containers: [postgresql]
runs-on: ${{ matrix.runs-on }}
env:
TEST_TOTAL_SHARDS: ${{ needs.set-up-functional-test.outputs.total_shards }}
TEST_SHARD_INDEX: ${{ matrix.shard_index }}
PERSISTENCE_TYPE: ${{ matrix.persistence_type }}
PERSISTENCE_DRIVER: ${{ matrix.persistence_driver }}
SINGLE_TEST_ARGS: ${{ needs.set-up-functional-test.outputs.single_test_args }}
TEST_TIMEOUT: ${{ needs.set-up-functional-test.outputs.test_timeout }}
BUILDKITE_MESSAGE: "{\"job\": \"functional-test\", \"db\": \"${{ matrix.persistence_driver }}\"}"
steps:
- name: Run functional test
if: ${{ inputs.run_single_functional_test != true || (inputs.run_single_functional_test == true && inputs.db == env.PERSISTENCE_DRIVER) }}
timeout-minutes: ${{ fromJSON(needs.set-up-functional-test.outputs.github_timeout) }} # make sure this is larger than the test timeout in the Makefile
run: echo "make functional-test-coverage ${PERSISTENCE_DRIVER}"