Skip to content

Commit b8bf562

Browse files
author
childish-sambino
authored
feat: run tests before deploying (#588)
1 parent 2a4fe16 commit b8bf562

File tree

3 files changed

+33
-55
lines changed

3 files changed

+33
-55
lines changed

.github/workflows/deploy.yml renamed to .github/workflows/test-and-deploy.yml

+32-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
1-
name: Deploy
1+
name: Test and Deploy
22
on:
33
push:
4-
tags:
5-
- '*'
4+
branches: [ '*' ]
5+
tags: [ '*' ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
# Run automatically at 8AM PST Monday-Friday
10+
- cron: '0 15 * * 1-5'
611
workflow_dispatch:
712

813
jobs:
14+
test:
15+
name: Test
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 20
18+
steps:
19+
- name: Checkout twilio-csharp
20+
uses: actions/checkout@v2
21+
22+
- name: Setup .NET Core SDK
23+
uses: actions/[email protected]
24+
with:
25+
dotnet-version: '3.1.x'
26+
27+
- name: Build & Test
28+
run: make test
29+
930
deploy:
1031
name: Deploy
32+
if: success() && github.ref_type == 'tag'
33+
needs: [ test ]
1134
runs-on: ubuntu-latest
1235
steps:
1336
- name: Checkout twilio-csharp
@@ -19,7 +42,7 @@ jobs:
1942
uses: docker/login-action@v1
2043
with:
2144
username: ${{ secrets.DOCKER_USERNAME }}
22-
password: ${{ secrets.DOCKER_TOKEN }}
45+
password: ${{ secrets.DOCKER_AUTH_TOKEN }}
2346

2447
# The expression strips off the shortest match from the front of the string to yield just the tag name as the output
2548
- name: Get tagged version
@@ -40,16 +63,16 @@ jobs:
4063
4164
notify-on-failure:
4265
name: Slack notify on failure
43-
if: ${{ failure() }}
44-
needs: [ deploy ]
66+
if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
67+
needs: [ test, deploy ]
4568
runs-on: ubuntu-latest
4669
steps:
4770
- uses: rtCamp/action-slack-notify@v2
4871
env:
49-
SLACK_COLOR: 'danger'
72+
SLACK_COLOR: failure
5073
SLACK_ICON_EMOJI: ':github:'
51-
SLACK_MESSAGE: ${{ format('Failed to deploy {1}{3} {0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id, ':') }}
52-
SLACK_TITLE: Deployment Failure
74+
SLACK_MESSAGE: ${{ format('Tests *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }}
75+
SLACK_TITLE: Action Failure - ${{ github.repository }}
5376
SLACK_USERNAME: GitHub Actions
5477
SLACK_MSG_AUTHOR: twilio-dx
5578
SLACK_FOOTER: Posted automatically using GitHub Actions

.github/workflows/test.yml

-45
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# twilio-csharp
22

3-
[![Test](https://github.com/twilio/twilio-csharp/actions/workflows/test.yml/badge.svg)](https://github.com/twilio/twilio-csharp/actions/workflows/test.yml)
3+
[![Test](https://github.com/twilio/twilio-csharp/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/twilio/twilio-csharp/actions/workflows/test-and-deploy.yml)
44
[![NuGet](https://img.shields.io/nuget/v/Twilio.svg)](https://www.nuget.org/packages/Twilio)
55
[![Learn with TwilioQuest](https://img.shields.io/static/v1?label=TwilioQuest&message=Learn%20to%20contribute%21&color=F22F46&labelColor=1f243c&style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAASFBMVEUAAAAZGRkcHBwjIyMoKCgAAABgYGBoaGiAgICMjIyzs7PJycnMzMzNzc3UoBfd3d3m5ubqrhfrMEDu7u739/f4vSb/3AD///9tbdyEAAAABXRSTlMAAAAAAMJrBrEAAAKoSURBVHgB7ZrRcuI6EESdyxXGYoNFvMD//+l2bSszRgyUYpFAsXOeiJGmj4NkuWx1Qeh+Ekl9DgEXOBwOx+Px5xyQhDykfgq4wG63M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