Skip to content

staging-release

staging-release #5424

name: Smoke Test Main
permissions:
actions: read
on:
workflow_dispatch: {}
schedule:
- cron: 0 0/2 * * *
repository_dispatch:
types:
- staging-release
- production-release
jobs:
build_cli:
name: Smoke test ${{ matrix.platform.name }} cli from release
runs-on: ${{ matrix.platform.os }}
outputs:
version-with-sha: ${{ steps.get-sha.outputs.version-with-sha }}
strategy:
matrix:
platform:
- name: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
binary-name: trunk-analytics-cli
- name: darwin
os: macos-latest
target: aarch64-apple-darwin
binary-name: trunk-analytics-cli
- name: windows
os: public-amd64-4xlarge-dind-germany
target: x86_64-pc-windows-gnu
binary-name: trunk-analytics-cli.exe
steps:
- name: Install git-lfs (Windows GNU build)
shell: bash
if: ${{ contains(matrix.platform.name, 'windows') }}
run: |
sudo bash -c 'cat << EOF > /etc/apt/sources.list
deb http://mirror.hetzner.com/ubuntu/packages jammy main restricted universe multiverse
deb http://mirror.hetzner.com/ubuntu/packages jammy-updates main restricted universe multiverse
deb http://mirror.hetzner.com/ubuntu/packages jammy-backports main restricted universe multiverse
deb http://mirror.hetzner.com/ubuntu/packages jammy-security main restricted universe multiverse
EOF'
sudo apt-get update
sudo apt-get install -y git-lfs build-essential
git lfs install
- name: Checkout
uses: actions/checkout@v4
with:
lfs: ${{ contains(matrix.platform.name, 'windows') }}
- name: Get commit SHA
id: get-sha
shell: bash
run: |
COMMIT_SHA=$(git rev-parse --short HEAD)
echo "sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT
echo "version-with-sha=0.0.0-${COMMIT_SHA}" >> $GITHUB_OUTPUT
echo "Setting version to 0.0.0-${COMMIT_SHA}"
- name: Update version with commit SHA
uses: ./.github/actions/update_version
with:
version: 0.0.0-${{ steps.get-sha.outputs.sha }}
file: cli/Cargo.toml
- name: Setup Rust & Cargo
uses: ./.github/actions/setup_rust_cargo
- name: Build darwin target
uses: ./.github/actions/build_cli_macos_target
if: "!cancelled() && contains(matrix.platform.name, 'darwin')"
with:
target: ${{ matrix.platform.target }}
profile: release
- name: Build unix/Windows target
uses: ./.github/actions/build_cli_linux_windows_target
if: "!cancelled() && !contains(matrix.platform.name, 'darwin')"
with:
target: ${{ matrix.platform.target }}
profile: release
- name: Upload CLI binary artifact
uses: actions/upload-artifact@v4
with:
name: cli-binary-${{ matrix.platform.name }}
path: target/${{matrix.platform.target}}/release/${{ matrix.platform.binary-name }}
if-no-files-found: error
retention-days: 1
test_cli:
name: Test ${{ matrix.platform.name }} CLI
runs-on: ${{ matrix.platform.test-os }}
needs: build_cli
strategy:
matrix:
platform:
- name: linux
test-os: ubuntu-latest
artifact-name: cli-binary-linux
binary-name: trunk-analytics-cli
- name: darwin
test-os: macos-latest
artifact-name: cli-binary-darwin
binary-name: trunk-analytics-cli
- name: windows
test-os: windows-latest
artifact-name: cli-binary-windows
binary-name: trunk-analytics-cli.exe
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download CLI binary artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.platform.artifact-name }}
path: .
- name: Setup Run Smoke Tests
uses: ./.github/actions/setup_run_smoke_tests
- name: Run Smoke Tests
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' }}
test-variants: "true"
- name: Run Smoke Tests With Gitlab
uses: ./.github/actions/perform_gitlab_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' }}
build_ruby_gem:
name: Build Ruby gem from main
runs-on: ubuntu-latest
outputs:
version-with-sha: ${{ steps.get-sha.outputs.version-with-sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true
working-directory: rspec-trunk-flaky-tests
- name: Get commit SHA
id: get-sha
shell: bash
run: |
COMMIT_SHA=$(git rev-parse --short HEAD)
echo "sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT
echo "version-with-sha=0.0.0-${COMMIT_SHA}" >> $GITHUB_OUTPUT
echo "Setting version to 0.0.0-${COMMIT_SHA}"
- name: Update version with commit SHA
uses: ./.github/actions/update_version
with:
version: 0.0.0-${{ steps.get-sha.outputs.sha }}
file: cli/Cargo.toml
- name: Update Test Report version
uses: ./.github/actions/update_version
with:
version: 0.0.0-${{ steps.get-sha.outputs.sha }}
file: test_report/Cargo.toml
- name: Update Gem version
uses: ./.github/actions/update_version
with:
version: 0.0.0-${{ steps.get-sha.outputs.sha }}
file: rspec-trunk-flaky-tests/rspec_trunk_flaky_tests.gemspec
- name: Build cross-compiled gem
uses: oxidize-rb/actions/cross-gem@v1
with:
platform: x86_64-linux
working-directory: rspec-trunk-flaky-tests
ruby-versions: "3.4"
- name: Upload gem artifact
uses: actions/upload-artifact@v4
with:
name: ruby-gem-main
path: rspec-trunk-flaky-tests/pkg/*.gem
if-no-files-found: error
retention-days: 1
test_ruby_gem_staging:
name: Test Ruby gem on staging
runs-on: ubuntu-latest
needs: build_ruby_gem
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download gem artifact
uses: actions/download-artifact@v4
with:
name: ruby-gem-main
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: build_ruby_gem
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download gem artifact
uses: actions/download-artifact@v4
with:
name: ruby-gem-main
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.test_cli.result != 'success' || needs.test_ruby_gem_production.result != 'success')
name: Post Production Smoke Test Failure
needs:
- build_cli
- test_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": "The main branch (${{ needs.build_cli.outputs.version-with-sha }}) of the analytics cli is broken on production! CLI test result: ${{ needs.test_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.result != 'success' || needs.test_cli.result != 'success' || needs.test_ruby_gem_staging.result != 'success')
name: Post Staging Smoke Test Failure
needs:
- build_cli
- test_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": "The main branch (${{ needs.build_cli.outputs.version-with-sha }}) of the analytics cli is broken on staging! CLI test result: ${{ needs.test_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"
}
}
]
}