Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWI-1694: Update test and deployment workflows #76

Merged
merged 4 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 105 additions & 26 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,125 @@
name: Deploy
name: Deploy SDK

on:
release:
types:
- published

env:
BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }}
BW_USERNAME: ${{ secrets.BW_USERNAME }}
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}
BW_USERNAME_FORBIDDEN: ${{ secrets.BW_USERNAME_FORBIDDEN}}
BW_PASSWORD_FORBIDDEN: ${{ secrets.BW_PASSWORD_FORBIDDEN}}
BW_VOICE_APPLICATION_ID: ${{ secrets.BW_VOICE_APPLICATION_ID }}
BW_MESSAGING_APPLICATION_ID: ${{ secrets.BW_MESSAGING_APPLICATION_ID }}
BW_NUMBER: ${{ secrets.BW_NUMBER }}
USER_NUMBER: ${{ secrets.USER_NUMBER }}
BASE_CALLBACK_URL: ${{ secrets.BASE_CALLBACK_URL }}
MANTECA_ACTIVE_NUMBER: ${{ secrets.MANTECA_ACTIVE_NUMBER }}
MANTECA_APPLICATION_ID: ${{ secrets.MANTECA_APPLICATION_ID }}
MANTECA_BASE_URL: ${{ secrets.MANTECA_BASE_URL }}
MANTECA_IDLE_NUMBER: ${{ secrets.MANTECA_IDLE_NUMBER }}
OPERATING_SYSTEM: ubuntu-latest
CSHARP_VERSION: 7.0.x

jobs:
publish:
name: Publish
if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'main' }}
env:
BW_PROJECT_NAME: Bandwidth.Standard
BW_PROJECT_TEST_NAME: Bandwidth.StandardTests
deploy_pre_release:
name: Deploy OpenAPI Generator Client Pre-Release
if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'feature/openapi-generator-sdk' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
env:
BW_PROJECT_NAME: src/Bandwidth.Standard
BW_PROJECT_TEST_NAME: src/Bandwidth.Standard.Test
steps:
- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
- uses: actions/setup-dotnet@v1

- name: Check Release Tag Format
run: |
re=[0-9]+\.[0-9]+\.[0-9]+b[0-9]+
if ! [[ $RELEASE_VERSION =~ $re ]]; then
echo 'Tag does not match expected regex pattern for beta releases (v[0-9]+.[0-9]+.[0-9]+b[0-9]+)'
echo $RELEASE_VERSION
echo 'Please update your tag to match the expected regex pattern'
exit 1
fi

- name: Checkout
uses: actions/checkout@v3
with:
ref: feature/openapi-generator-sdk

- name: Setup Dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'

- name: Run integration tests
run: dotnet test $BW_PROJECT_TEST_NAME

- name: Pack NuGet package
run: dotnet pack --configuration Release $BW_PROJECT_NAME -p:PackageVersion=$RELEASE_VERSION

- name: Publish NuGet package
env:
BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }}
BW_USERNAME: ${{ secrets.BW_USERNAME }}
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}
BW_USERNAME_FORBIDDEN: ${{ secrets.BW_USERNAME_FORBIDDEN}}
BW_PASSWORD_FORBIDDEN: ${{ secrets.BW_PASSWORD_FORBIDDEN}}
BW_VOICE_APPLICATION_ID: ${{ secrets.BW_VOICE_APPLICATION_ID }}
BW_MESSAGING_APPLICATION_ID: ${{ secrets.BW_MESSAGING_APPLICATION_ID }}
BW_NUMBER: ${{ secrets.BW_NUMBER }}
USER_NUMBER: ${{ secrets.USER_NUMBER }}
BASE_CALLBACK_URL: ${{ secrets.BASE_CALLBACK_URL }}
MANTECA_ACTIVE_NUMBER: ${{ secrets.MANTECA_ACTIVE_NUMBER }}
MANTECA_APPLICATION_ID: ${{ secrets.MANTECA_APPLICATION_ID }}
MANTECA_BASE_URL: ${{ secrets.MANTECA_BASE_URL }}
MANTECA_IDLE_NUMBER: ${{ secrets.MANTECA_IDLE_NUMBER }}
OPERATING_SYSTEM: ${{ matrix.os }}
CSHARP_VERSION: ${{ matrix.dotnet }}
NUGET_KEY: ${{ secrets.NUGET_KEY }}
NUGET_SOURCE: https://api.nuget.org/v3/index.json
run: dotnet nuget push $BW_PROJECT_NAME/bin/Release/*.nupkg -s $NUGET_SOURCE -k $NUGET_KEY

- name: Notify Slack of build status
uses: Bandwidth/[email protected]
if: always()
with:
job-status: ${{ job.status }}
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel: ${{ secrets.SLACK_CHANNEL }}

deploy:
name: deploy 'main' branch
if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'main' }}
runs-on: ubuntu-latest
env:
BW_PROJECT_NAME: src/Bandwidth.Standard
BW_PROJECT_TEST_NAME: src/Bandwidth.Standard.Test
steps:
Comment on lines +83 to +84
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these gonna be correct with the src in there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was basing this off of the following step

      - name: Run integration tests
        run: dotnet test $BW_PROJECT_TEST_NAME

dotnet test BW_PROJECT_TEST_NAME fails if BW_PROJECT_TEST_NAME=Bandwidth.Standard.Test I figured BW_PROJECT_NAME would be the same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test-pr workflow passed and it has the following step

- name: Run functional tests
        env:
          OPERATING_SYSTEM: ${{ matrix.os }}
          CSHARP_VERSION: ${{ matrix.dotnet }}
          # Required for multiple target frameworks in the StandardTests project.
          DOTNET: ${{ matrix.dotnet }}
        run: dotnet test src/Bandwidth.Standard.Test

so we know that BW_PROJECT_TEST_NAME will work for sure

- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV

- name: Check Release Tag Format
run: |
re=[0-9]+\.[0-9]+\.[0-9]+[0-9]+
if ! [[ $RELEASE_VERSION =~ $re ]]; then
echo 'Tag does not match expected regex pattern for beta releases (v[0-9]+.[0-9]+.[0-9]+[0-9]+)'
echo $RELEASE_VERSION
echo 'Please update your tag to match the expected regex pattern'
exit 1
fi

- name: Checkout
uses: actions/checkout@v3

- name: Setup Dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'

- name: Run integration tests
run: dotnet test $BW_PROJECT_TEST_NAME

- name: Pack NuGet package
run: dotnet pack --configuration Release $BW_PROJECT_NAME -p:PackageVersion=$RELEASE_VERSION

- name: Publish NuGet package
env:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
NUGET_SOURCE: https://api.nuget.org/v3/index.json
run: dotnet nuget push $BW_PROJECT_NAME/bin/Release/*.nupkg -s $NUGET_SOURCE -k $NUGET_KEY

- name: Notify Slack of build status
uses: Bandwidth/[email protected]
if: always()
with:
job-status: ${{ job.status }}
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel: ${{ secrets.SLACK_CHANNEL }}
86 changes: 86 additions & 0 deletions .github/workflows/test-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Test Main Branch Nightly
on:
schedule:
- cron: "0 4 * * *"

env:
BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }}
BW_USERNAME: ${{ secrets.BW_USERNAME }}
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}
BW_USERNAME_FORBIDDEN: ${{ secrets.BW_USERNAME_FORBIDDEN}}
BW_PASSWORD_FORBIDDEN: ${{ secrets.BW_PASSWORD_FORBIDDEN}}
BW_VOICE_APPLICATION_ID: ${{ secrets.BW_VOICE_APPLICATION_ID }}
BW_MESSAGING_APPLICATION_ID: ${{ secrets.BW_MESSAGING_APPLICATION_ID }}
BW_NUMBER: ${{ secrets.BW_NUMBER }}
USER_NUMBER: ${{ secrets.USER_NUMBER }}
BASE_CALLBACK_URL: ${{ secrets.BASE_CALLBACK_URL }}
MANTECA_ACTIVE_NUMBER: ${{ secrets.MANTECA_ACTIVE_NUMBER }}
MANTECA_APPLICATION_ID: ${{ secrets.MANTECA_APPLICATION_ID }}
MANTECA_BASE_URL: ${{ secrets.MANTECA_BASE_URL }}
MANTECA_IDLE_NUMBER: ${{ secrets.MANTECA_IDLE_NUMBER }}

jobs:
test_main:
name: Test Main Branch Nightly
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2022, windows-2019, ubuntu-22.04, ubuntu-20.04]
dotnet: [6.0.x, 7.0.x]
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
ref: "main"

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet }}

- name: Run functional tests
env:
OPERATING_SYSTEM: ${{ matrix.os }}
CSHARP_VERSION: ${{ matrix.dotnet }}
# Required for multiple target frameworks in the StandardTests project.
DOTNET: ${{ matrix.dotnet }}
run: dotnet test src/Bandwidth.Standard.Test

test_feature:
name: Test Feature Branch Nightly
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2022, windows-2019, ubuntu-22.04, ubuntu-20.04]
dotnet: [6.0.x, 7.0.x]
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
ref: "feature/openapi-generator-sdk"

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet }}

- name: Run functional tests
env:
OPERATING_SYSTEM: ${{ matrix.os }}
CSHARP_VERSION: ${{ matrix.dotnet }}
# Required for multiple target frameworks in the StandardTests project.
DOTNET: ${{ matrix.dotnet }}
run: dotnet test src/Bandwidth.Standard.Test

notify_for_failures:
name: Notify for failures
needs: [test_main, test_feature]
if: failure()
runs-on: ubuntu-latest
steps:
- name: Notify Slack of failures
uses: Bandwidth/[email protected]
with:
job-status: failure
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel: ${{ secrets.SLACK_CHANNEL }}
45 changes: 45 additions & 0 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Test PR
on:
pull_request:
workflow_dispatch:

env:
BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }}
BW_USERNAME: ${{ secrets.BW_USERNAME }}
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}
BW_USERNAME_FORBIDDEN: ${{ secrets.BW_USERNAME_FORBIDDEN}}
BW_PASSWORD_FORBIDDEN: ${{ secrets.BW_PASSWORD_FORBIDDEN}}
BW_VOICE_APPLICATION_ID: ${{ secrets.BW_VOICE_APPLICATION_ID }}
BW_MESSAGING_APPLICATION_ID: ${{ secrets.BW_MESSAGING_APPLICATION_ID }}
BW_NUMBER: ${{ secrets.BW_NUMBER }}
USER_NUMBER: ${{ secrets.USER_NUMBER }}
BASE_CALLBACK_URL: ${{ secrets.BASE_CALLBACK_URL }}
MANTECA_ACTIVE_NUMBER: ${{ secrets.MANTECA_ACTIVE_NUMBER }}
MANTECA_APPLICATION_ID: ${{ secrets.MANTECA_APPLICATION_ID }}
MANTECA_BASE_URL: ${{ secrets.MANTECA_BASE_URL }}
MANTECA_IDLE_NUMBER: ${{ secrets.MANTECA_IDLE_NUMBER }}

jobs:
test_pr:
name: Test PR
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2022, windows-2019, ubuntu-22.04, ubuntu-20.04]
dotnet: [6.0.x, 7.0.x]
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet }}

- name: Run functional tests
env:
OPERATING_SYSTEM: ${{ matrix.os }}
CSHARP_VERSION: ${{ matrix.dotnet }}
# Required for multiple target frameworks in the StandardTests project.
DOTNET: ${{ matrix.dotnet }}
run: dotnet test src/Bandwidth.Standard.Test
53 changes: 0 additions & 53 deletions .github/workflows/test.yml

This file was deleted.

Loading