GitHub Actions need no introduction — it is a powerful, flexible CI/CD service that empowers developers to automate all of their software workflows. Over time, it has enabled developers to build amazing things, and significantly improved developers’ productivity. What’s great is that anyone can discover and utilize over 8,500 actions in the GitHub Marketplace.
Automated Testing is a critical step in ensuring the integrity of CI/CD workflows, helping to validate the quality of software being developed. What’s more, automation reduces the amount of time and effort required to run tests efficiently. With automated testing added into your CI/CD workflow you can ensure that all of the changes made to your code are tested before hitting production.
In our view, the API level is the optimal layer to perform automated testing. Unlike a back-end or UI-layer, APIs and their behavior are generally very well defined; brokering a contract between the front-end and back-end systems. Additionally, APIs tend to change less frequently, making it cheaper to maintain these tests. Therefore, testing an API is an easier and more efficient means of achieving a high level of test coverage. This is why we built RapidAPI Testing — a powerful, easy-to-use API Testing tool that allows you to build complex, automated tests using an easy-to-understand, drag-and-drop UI.
A Powerful Combination
Convenience and ease-of-use are always top priorities when we build functionalities in RapidAPI Testing, and we know that software applications are not built in silos, but rather require multiple components to work together. With that in mind, one of the first capabilities that we built into RapidAPI Testing is the ability to easily trigger your tests remotely through a GitHub Action. With this action, you can include comprehensive tests built with RapidAPI Testing in your automated CI/CD pipeline managed through the simplicity of GitHub Actions.
How to Get Started
Step 1: Sign up for a free account at RapidAPI Testing
First, you will need to sign up for a free account at RapidAPI Testing.
Step 2: Create tests for your API
Creating tests for your APIs in RapidAPI Testing is very easy, especially if you have a standard definition (Open API Spec) for your APIs. You can follow the steps outlined in this blog post.
Step 3: Find the IDs of the tests you want to add to your workflow
Each of the tests you create in RapidAPI Testing comes with its own unique identifier. You can find this ID on the Settings page of your tests. Copy this ID – we will need to use it in a later step.
Step 4: Add RapidAPI Test Triggers into your workflow definition file
Once you have created your API tests in RapidAPI, executing them as part of your workflow is pretty simple. Below is a complete example of how you can add them into your workflow. You can also refer to the GitHub Action’s documentation in the GitHub Marketplace.
on: [push] jobs: run_api_test: runs-on: ubuntu-latest name: Execute RapidAPI API Tests steps: - name: Execute Tests id: tstExec uses: RapidAPI/gh-api-testing-trigger@v0.0.3 with: test: 'YOUR_TEST_ID' location: 'AWS-US-WEST-2' environment: 'ENV_ID(OPTIONAL; CAN BE LEFT BLANK)' - name: Show Results run: echo "The test took ${{ steps.tstExec.outputs.time }}ms to run"; echo "The test result was ${{ steps.tstExec.outputs.computedStatus }}"; echo "View Report - ${{ steps.tstExec.outputs.reportUrl }}"
There are a few input parameters:
- Test (required): this is the Test ID that you wish to execute. It is the same ID as what we retrieved in Step 3. If you wish to store your Test IDs more securely, you can leverage GitHub’s Encrypted Secrets, and use the secrets context to access them here.
- Location (required): this is the location in which the test will be executed. The options are below.
- AWS-US-EAST-1: N. Virginia
- AWS-US-WEST-2: Oregon
- AWS-AP-EAST-1: Hong Kong
- AWS-AP-SOUTH-1: Mumbai
- AWS-AP-SOUTHEAST-1: Singapore
- AWS-AP-NORTHEAST-1: Tokyo
- AWS-EU-CENTRAL-1: Frankfurt
- AWS-EU-WEST-3: Paris
- AWS-SA-EAST-1: São Paulo
- Environment ID (optional): include this if you wish to execute the tests in a specific environment that you defined. You can find the ID of the environment on the same page as the Test ID. If you do not wish to specify the environment, you can leave this field blank.
The Test Trigger GitHub Action will return a few parameters:
- time: this is the time it took to execute the test in milliseconds.
- successful: true/false based on the results of the test execution.
- reportUrl: URL of a human readable report of the test execution.
- computedStatus: A human-readable test status that matches the status values on the test dashboard in the UI.
Once you have added the above steps to your workflow definition file, you should be good to go. Happy testing!
RapidAPI Testing provides a comprehensive API testing solution with native integration to GitHub Actions. Sign up for free to get started or if you want to learn more, click here to Contact Us. If you are interested in submitting issues or a pull request to this action’s source code, you can go to the GitHub Action’s documentation.
Leave a Reply