Smoke Test #5508
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Smoke Test | |
| permissions: | |
| actions: read | |
| on: | |
| workflow_dispatch: {} | |
| schedule: | |
| - cron: 0 0/2 * * * | |
| repository_dispatch: | |
| types: | |
| - staging-release | |
| - production-release | |
| env: | |
| RELEASE: 0.10.10 | |
| RSPEC_RELEASE: 0.11.8 | |
| jobs: | |
| build_cli: | |
| name: Smoke test ${{ matrix.platform.name }} cli from release | |
| runs-on: ${{ matrix.platform.os }} | |
| outputs: | |
| production-success: ${{ steps.run-tests.outputs.production-success }} | |
| staging-success: ${{ steps.run-tests.outputs.staging-success }} | |
| strategy: | |
| matrix: | |
| platform: | |
| - name: linux | |
| os: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| download-target: x86_64-unknown-linux | |
| binary-name: trunk-analytics-cli | |
| - name: macos | |
| os: macos-latest | |
| target: arm64-apple-darwin | |
| download-target: aarch64-apple-darwin | |
| binary-name: trunk-analytics-cli | |
| #TODO ENABLE WINDOWS TESTS WHEN WE HAVE A WINDOWS RELEASE | |
| # - name: windows | |
| # os: windows-latest | |
| # target: x86_64-pc-windows-gnu | |
| # download-target: x86_64-pc-windows-gnu | |
| # binary-name: trunk-analytics-cli.exe | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Cache CLI release binary | |
| uses: actions/cache@v4 | |
| id: cache-cli-release | |
| with: | |
| path: | | |
| trunk-analytics-cli | |
| trunk-analytics-cli.exe | |
| trunk-analytics-cli-*.tar.gz | |
| trunk-analytics-cli-*.zip | |
| key: cli-release-${{ env.RELEASE }}-${{ matrix.platform.download-target }} | |
| - name: Get Release | |
| shell: bash | |
| if: steps.cache-cli-release.outputs.cache-hit != 'true' | |
| run: | | |
| if [[ "${{ matrix.platform.name }}" == "windows" ]]; then | |
| curl -fsSLO --retry 5 --retry-all-errors --retry-delay 2 https://github.com/trunk-io/analytics-cli/releases/download/${{ env.RELEASE }}/trunk-analytics-cli-${{ matrix.platform.download-target }}.zip | |
| unzip -q trunk-analytics-cli-${{ matrix.platform.download-target }}-experimental.zip | |
| else | |
| curl -fsSLO --retry 5 --retry-all-errors --retry-delay 2 https://github.com/trunk-io/analytics-cli/releases/download/${{ env.RELEASE }}/trunk-analytics-cli-${{ matrix.platform.download-target }}.tar.gz | |
| tar -zxf trunk-analytics-cli-${{ matrix.platform.download-target }}.tar.gz | |
| chmod +x trunk-analytics-cli | |
| fi | |
| - name: Setup Run Smoke Tests - ${{ matrix.platform.name }} | |
| uses: ./.github/actions/setup_run_smoke_tests | |
| - name: Run Smoke Tests - ${{ matrix.platform.name }} | |
| id: run-tests | |
| uses: ./.github/actions/perform_smoke_test | |
| with: | |
| cli-binary-location: ${{ matrix.platform.binary-name }} | |
| staging-api-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} | |
| production-api-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }} | |
| environment-type: ${{ (github.event.action == 'production-release' && 'production') || (github.event.action == 'staging-release' && 'staging') || 'both' }} | |
| download_ruby_gem: | |
| name: Download Ruby gem from release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.4" | |
| - name: Download gem from RubyGems | |
| run: | | |
| gem fetch rspec_trunk_flaky_tests -v ${{ env.RSPEC_RELEASE }} | |
| mkdir -p gems | |
| mv rspec_trunk_flaky_tests-*.gem gems/ | |
| - name: Upload gem artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ruby-gem-release | |
| path: gems/*.gem | |
| retention-days: 1 | |
| test_ruby_gem_staging: | |
| name: Test Ruby gem on staging | |
| runs-on: ubuntu-latest | |
| needs: download_ruby_gem | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download gem artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ruby-gem-release | |
| path: .github/actions/test_ruby_gem_uploads/ | |
| - name: Run Ruby gem smoke tests | |
| uses: ./.github/actions/test_ruby_gem_uploads | |
| with: | |
| ruby-version: "3.4" | |
| trunk-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} | |
| trunk-public-api-address: https://api.trunk-staging.io | |
| trunk-org-slug: trunk-staging-org | |
| platform: x86_64-linux | |
| artifact-pattern: "" | |
| test_ruby_gem_production: | |
| name: Test Ruby gem on production | |
| runs-on: ubuntu-latest | |
| needs: download_ruby_gem | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download gem artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ruby-gem-release | |
| path: .github/actions/test_ruby_gem_uploads/ | |
| - name: Run Ruby gem smoke tests | |
| uses: ./.github/actions/test_ruby_gem_uploads | |
| with: | |
| ruby-version: "3.4" | |
| trunk-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }} | |
| trunk-public-api-address: https://api.trunk.io | |
| trunk-org-slug: trunk | |
| platform: x86_64-linux | |
| artifact-pattern: "" | |
| production-slack-workflow-status: | |
| if: always() && github.ref == 'refs/heads/main' && (needs.build_cli.outputs.production-success != 'true' || needs.test_ruby_gem_production.result != 'success') | |
| name: Post Production Smoke Test Failure | |
| needs: | |
| - build_cli | |
| - test_ruby_gem_production | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| env: | |
| SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }} | |
| steps: | |
| - name: Analytics Cli Smoke Test Failure | |
| uses: slackapi/slack-github-action@v1 | |
| with: | |
| channel-id: production-notifications | |
| payload: | | |
| { | |
| "blocks": [ | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "Release ${{ env.RELEASE }} of the analytics cli is broken on production! CLI test result: ${{ needs.build_cli.result }}, Ruby gem test result: ${{ needs.test_ruby_gem_production.result }}. Failed workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}. Details on responding to this can be found at https://trunk.slite.com/app/docs/zQ99Scfw1VgDSO/Analytics-CLI-Smoke-Tests-Are-Broken" | |
| } | |
| } | |
| ] | |
| } | |
| staging-slack-workflow-status: | |
| if: always() && github.ref == 'refs/heads/main' && (needs.build_cli.outputs.staging-success != 'true' || needs.test_ruby_gem_staging.result != 'success') | |
| name: Post Staging Smoke Test Failure | |
| needs: | |
| - build_cli | |
| - test_ruby_gem_staging | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| env: | |
| SLACK_BOT_TOKEN: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }} | |
| steps: | |
| - name: Analytics Cli Smoke Test Failure | |
| uses: slackapi/slack-github-action@v1 | |
| with: | |
| channel-id: staging-notifications | |
| payload: | | |
| { | |
| "blocks": [ | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "Release ${{ env.RELEASE }} of the analytics cli is broken on staging! CLI test result: ${{ needs.build_cli.result }}, Ruby gem test result: ${{ needs.test_ruby_gem_staging.result }}. Failed workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}. Details on responding to this can be found at https://trunk.slite.com/app/docs/zQ99Scfw1VgDSO/Analytics-CLI-Smoke-Tests-Are-Broken" | |
| } | |
| } | |
| ] | |
| } |