Added metrics for test runs

Refs CORE-120

When test runs execute, use the new @tryghost/metrics package to send metrics to configurable backends.

At the moment, we're just sending the test run duration to our metric store in preparation of changes to the test suite.
This commit is contained in:
Sam Lord 2021-10-28 14:15:48 +01:00 committed by GitHub
parent d89b8448ab
commit e9afa6f40f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,6 +105,9 @@ jobs:
mysql root password: 'root' mysql root password: 'root'
- run: yarn - run: yarn
- run: date +%s > ${{ runner.temp }}/startTime # Get start time for test suite
- run: yarn test:e2e - run: yarn test:e2e
env: env:
database__connection__filename: /dev/shm/ghost-test.db database__connection__filename: /dev/shm/ghost-test.db
@ -116,6 +119,38 @@ jobs:
env: env:
database__connection__filename: /dev/shm/ghost-test.db database__connection__filename: /dev/shm/ghost-test.db
# Get runtime in seconds for test suite
- run: |
startTime="$(cat ${{ runner.temp }}/startTime)"
endTime="$(date +%s)"
echo "test_time=$(($endTime-$startTime))" >> $GITHUB_ENV
- name: Tailscale Action
uses: tailscale/github-action@v1
with:
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
# Report time taken to metrics service
- uses: sam-lord/action-trigger-metric@main
with:
metricName: 'test-time'
metricValue: ${{ env.test_time }}
configuration: |
{
"metrics": {
"transports": ["elasticsearch"],
"metadata": {
"database": "${{ matrix.env.DB }}",
"node": "${{ matrix.node }}"
}
},
"elasticsearch": {
"host": "${{ secrets.ELASTICSEARCH_HOST }}",
"username": "${{ secrets.ELASTICSEARCH_USERNAME }}",
"password": "${{ secrets.ELASTICSEARCH_PASSWORD }}"
}
}
- name: Unit test coverage - name: Unit test coverage
run: yarn cov:unit run: yarn cov:unit
- uses: codecov/codecov-action@v2 - uses: codecov/codecov-action@v2