Speakeasy Logo
Skip to Content

Testing in GitHub Actions

Automatically run Speakeasy tests on SDK pull requests or other events in a GitHub repository via GitHub Actions.

github.com
A screenshot of a successful test check
github.com
A screenshot of a successful test comment

Setting up a Github Actions Check

This requires previously completing the Github Setup. After completing the setup, navigate to the SDK repository and run the following command:

This command enables both generateTests and generateNewTests settings in your gen.yaml configuration file and produces a Github Actions workflow like the following that enables running SDK tests as a Github check on Pull Requests.

Ensuring Tests Run on Automated PR Creation

To ensure that testing checks run by default when an SDK PR is created, implement one of the following options.

Installing the Speakeasy Github App

Installing the Speakeasy Github App and granting the App access to the SDK repository enables triggering testing runs after a PR is created. To install the app, visit this link  or follow instructions in the CLI or dashboard.

Setting up your own Github PAT

Another option is to create a Github Personal Access Token (PAT) that will be used to create PRs in the SDK repository. This is a workaround recommended  by Github.

  1. Create a fine-grained  PAT with Pull requests Read/Write permissions. Ensure it has access to the SDK repository. Setting this to no expiration is recommended.
github.com
Setting up the PAT
github.com
Providing access to a specific repo
github.com
Pull request permissions
  1. In all SDK repositories, navigate to Settings > Secrets and variables > Actions and save the PAT as a Repository secret under the name PR_CREATION_PAT.
github.com
Providing access to a specific repo
  1. In all sdk_generation.yaml workflows, add the pr-creation-token as a provided secret at the bottom.

Running in Direct mode

If your generation action is running in direct mode where SDK updates get immediately pushed to main, testing will run as part of the generation action. If tests fail, the generation action will fail and not push your SDK changes to main.

Last updated on