diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de18cc4d..b3fbc605 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -99,3 +99,20 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} RUNTIME_PARAM: ${{ matrix.runtime-param }} run: ./scripts/run_integration_tests.sh + + - name: Send success metric + env: + DD_API_KEY: ${{ secrets.DD_API_KEY }} + run: ./scripts/send_status_metric.sh 0 $DD_API_KEY + + integration-test-failure: + runs-on: ubuntu-latest + needs: [integration-test] + if: always() && (needs.integration-test.result == 'failure') + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Send a failure metric + env: + DD_API_KEY: ${{ secrets.DD_API_KEY }} + run: ./scripts/send_status_metric.sh 1 $DD_API_KEY \ No newline at end of file diff --git a/scripts/send_status_metric.sh b/scripts/send_status_metric.sh new file mode 100755 index 00000000..0fe9dff3 --- /dev/null +++ b/scripts/send_status_metric.sh @@ -0,0 +1,29 @@ +if [ -z $GITHUB_REF ]; then + echo "GITHUB_REF is not set, not sending the metric" + exit 0 +fi + +if [ "$GITHUB_REF" != "refs/heads/main" ]; then + echo "Not on the main branch, not sending the metric" + exit 0 +fi + +#Retrieve the status +# 0 means success +# 1 means failure +STATUS=$1 + +API_KEY=$2 +CURRENT_TIME=$(date +%s) + +#Send the metric +curl -H "Content-type: application/json" \ +-H "DD-API-KEY: ${API_KEY}" \ +-d "{ \"series\" : + [{\"metric\":\"serverless.integration_test.python.status\", + \"points\":[[$CURRENT_TIME, $STATUS]], + \"type\":\"gauge\", + \"tags\":[\"service:serverless-integration-test\"]} + ] + }" \ +'https://app.datadoghq.com/api/v1/series' \ No newline at end of file