From e5e6390b8e97e36ac42f551ad5c406bcaa21ae2b Mon Sep 17 00:00:00 2001 From: Julia Januchowski <55033207+juliajanu@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:27:04 -0400 Subject: [PATCH] SWI-1694: Update test and deployment workflows (#76) * SWI-1694: Updated test workflows * SWI-1694: Adding feature branch to nightly test * SWI-1694: Update deploy workflow * SWI-1694: Update deploy to handle pre-releases --- .github/workflows/deploy.yml | 131 +++++++++++++++++++++++------ .github/workflows/test-nightly.yml | 86 +++++++++++++++++++ .github/workflows/test-pr.yml | 45 ++++++++++ .github/workflows/test.yml | 53 ------------ 4 files changed, 236 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/test-nightly.yml create mode 100644 .github/workflows/test-pr.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2588f6a..dd1c336 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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/build-notify-slack-action@v1.0.0 + 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: + - 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/build-notify-slack-action@v1.0.0 + if: always() + with: + job-status: ${{ job.status }} + slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} + slack-channel: ${{ secrets.SLACK_CHANNEL }} diff --git a/.github/workflows/test-nightly.yml b/.github/workflows/test-nightly.yml new file mode 100644 index 0000000..6d5260c --- /dev/null +++ b/.github/workflows/test-nightly.yml @@ -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/build-notify-slack-action@v1.0.0 + with: + job-status: failure + slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} + slack-channel: ${{ secrets.SLACK_CHANNEL }} diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml new file mode 100644 index 0000000..764c1df --- /dev/null +++ b/.github/workflows/test-pr.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 07bc97d..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Test -on: - schedule: - - cron: '0 4 * * *' - pull_request: - workflow_dispatch: - -jobs: - test: - name: Test - 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: - 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 }} - # Required for multiple target frameworks in the StandardTests project. - DOTNET: ${{ matrix.dotnet }} - run: dotnet test src/Bandwidth.Standard.Test - - - name: Notify Slack of failures - uses: Bandwidth/build-notify-slack-action@v1.0.0 - if: failure() && !github.event.pull_request.draft - with: - job-status: ${{ job.status }} - slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} - slack-channel: ${{ secrets.SLACK_CHANNEL }}