GitHub Actions β
GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. You can create workflows that build and test every pull request to your repository, or deploy merged pull requests to production.
Example β
TestBeats can be integrated with GitHub Actions in following ways:
Using testbeats cli in custom GitHub workflow β
Letβs look at an example of workflow using testbeats
cli.
yml
name: Test
on:
pull_request:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
# intermediary steps to run tests
- run: npx testbeats publish -c path/to/report.json
if: ${{ always() }}
env:
SLACK_URL: ${{ secrets.SLACK_URL }}
Using TestBeats Publish GitHub Action β
Letβs look at an example of workflow using TestBeats GitHub Actions.
TIP
Always choose the latest version of GitHub Action. Head over to TestBeats GitHub Action at marketplace for more details.
yml
# .github/workflows/testbeats.yml
# This workflow will publish test results to slack
name: Test
on:
pull_request:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Install Dependencies
id: npm-ci
run: npm ci
- name: Test
id: npm-ci-test
run: npm run test
- name: TestBeats Publish
uses: test-results-reporter/publish@v1
with:
config: .testbeats.json # TestBeats configuration file path
Another example
yml
# .github/workflows/testbeats.yml
# This workflow will publish test results to slack including CI info and chart test summary
name: Test
on:
pull_request:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Install Dependencies
id: npm-ci
run: npm ci
- name: Test
id: npm-ci-test
run: npm run test
- name: TestBeats Publish
uses: test-results-reporter/publish@v1
with:
slack: ${{ secrets.SLACK_WEBHOOK_URL }}
mocha: ./test/mocha/results.xml
ci-info: true
chart-test-summary: true
π Yet another example, why not? the more the better isn't it π
yml
# .github/workflows/testbeats.yml
# This workflow will publish test results to TestBeats
name: Test
on:
pull_request:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Install Dependencies
id: npm-ci
run: npm ci
- name: Test
id: npm-ci-test
run: npm run test
- name: TestBeats Publish
uses: test-results-reporter/publish@v1
with:
slack: ${{ secrets.SLACK_WEBHOOK_URL }}
mocha: ./test/mocha/results.xml
api-key: ${{ secrets.TESTBEATS_API_KEY }}