diff --git a/.github/workflows/01-steampipe-release.yaml b/.github/workflows/01-steampipe-release.yaml index c161e56dfd..c158dfbff5 100644 --- a/.github/workflows/01-steampipe-release.yaml +++ b/.github/workflows/01-steampipe-release.yaml @@ -196,7 +196,6 @@ jobs: with: repository: turbot/homebrew-tap token: ${{ secrets.GH_ACCESS_TOKEN }} - ref: ${{ github.event.inputs.version }} - name: Update live version if: steps.semver_parser.outputs.prerelease == '' @@ -263,3 +262,60 @@ jobs: git fetch --all gh pr merge $VERSION --squash --delete-branch git push origin --delete bump-brew + + trigger_smoke_tests: + name: Trigger Smoke Tests + if: ${{ github.event.inputs.environment == 'Final (RC and final release)' }} + needs: update_homebrew_tap + runs-on: ubuntu-latest + steps: + - name: Calculate version + id: calculate_version + run: | + echo "VERSION=v${{ github.event.inputs.version }}" >> $GITHUB_ENV + + - name: Parse semver string + id: semver_parser + uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 # v1.4.7 + with: + input_string: ${{ github.event.inputs.version }} + + - name: Trigger smoke test workflow + if: steps.semver_parser.outputs.prerelease == '' + run: | + gh workflow run "12-test-post-release-linux-distros.yaml" \ + --ref ${{ github.ref }} \ + --field version=$VERSION \ + --repo ${{ github.repository }} + env: + GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} + + - name: Get smoke test workflow run URL + if: steps.semver_parser.outputs.prerelease == '' + run: | + echo "Waiting for smoke test workflow to start..." + sleep 10 + + # Get the most recent run of the smoke test workflow + RUN_ID=$(gh run list \ + --workflow="12-test-post-release-linux-distros.yaml" \ + --repo ${{ github.repository }} \ + --limit 1 \ + --json databaseId \ + --jq '.[0].databaseId') + + if [ -n "$RUN_ID" ]; then + WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/$RUN_ID" + echo "āœ… Smoke test workflow triggered successfully!" + echo "šŸ”— Monitor progress at: $WORKFLOW_URL" + echo "" + echo "Workflow details:" + echo " - Version: $VERSION" + echo " - Workflow: 12-test-post-release-linux-distros.yaml" + echo " - Run ID: $RUN_ID" + else + echo "āš ļø Could not retrieve workflow run ID. Check manually at:" + echo "https://github.com/${{ github.repository }}/actions/workflows/12-test-post-release-linux-distros.yaml" + fi + env: + GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} diff --git a/.github/workflows/02-steampipe-db-image-build.yaml b/.github/workflows/02-steampipe-db-image-build.yaml index c35d144af8..7d0c1078b7 100644 --- a/.github/workflows/02-steampipe-db-image-build.yaml +++ b/.github/workflows/02-steampipe-db-image-build.yaml @@ -150,6 +150,7 @@ jobs: - name: Push to Registry run: |- REF="$CORE_REPO/$IMAGE_NAME:$VERSION" + LATEST_REF="$CORE_REPO/$IMAGE_NAME:latest" oras push $REF \ --config config.json:application/vnd.turbot.steampipe.config.v1+json \ @@ -158,3 +159,11 @@ jobs: extracted-darwin-arm64:application/vnd.turbot.steampipe.db.darwin-arm64.layer.v1+tar \ extracted-linux-amd64:application/vnd.turbot.steampipe.db.linux-amd64.layer.v1+tar \ extracted-linux-arm64:application/vnd.turbot.steampipe.db.linux-arm64.layer.v1+tar + + # check if the version is NOT an rc version before tagging as latest + if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Tagging as latest: $LATEST_REF" + oras tag $REF latest + else + echo "Skipping latest tag for rc version: $VERSION" + fi diff --git a/.github/workflows/02-steampipe-smoke-tests.yaml b/.github/workflows/12-test-post-release-linux-distros.yaml similarity index 71% rename from .github/workflows/02-steampipe-smoke-tests.yaml rename to .github/workflows/12-test-post-release-linux-distros.yaml index d3d8dd2329..0e27110bfa 100644 --- a/.github/workflows/02-steampipe-smoke-tests.yaml +++ b/.github/workflows/12-test-post-release-linux-distros.yaml @@ -1,4 +1,4 @@ -name: "02 - Steampipe: Smoke Tests" +name: "12 - Test: Linux Distros (Post-release)" on: workflow_dispatch: @@ -13,6 +13,8 @@ env: VERSION: ${{ github.event.inputs.version }} # Disable update checks during smoke tests STEAMPIPE_UPDATE_CHECK: false + # Slack webhook URL for notifications + SLACK_WEBHOOK_URL: ${{ secrets.PIPELING_RELEASE_BOT_WEBHOOK_URL }} jobs: smoke_test_ubuntu_24: @@ -153,40 +155,81 @@ jobs: docker stop amazonlinux-2023-test docker rm amazonlinux-2023-test - smoke_test_darwin_arm64: - name: Smoke test (macOS 14, ARM64) - runs-on: macos-latest + smoke_test_linux_arm64: + name: Smoke test (Ubuntu 24, ARM64) + runs-on: ubuntu-24.04-arm steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Download Darwin Release Artifact + - name: Download Linux Release Artifact run: | mkdir -p ./artifacts gh release download ${{ env.VERSION }} \ - --pattern "*darwin_arm64.zip" \ + --pattern "*linux_arm64.tar.gz" \ --dir ./artifacts \ --repo ${{ github.repository }} # Rename to expected format - mv ./artifacts/*darwin_arm64.zip ./artifacts/darwin.zip + mv ./artifacts/*linux_arm64.tar.gz ./artifacts/linux.tar.gz env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Extract Darwin Artifacts and Install Binary + - name: Extract Linux Artifacts and Install Binary run: | - sudo unzip ./artifacts/darwin.zip -d /usr/local/bin + sudo tar -xzf ./artifacts/linux.tar.gz -C /usr/local/bin sudo chmod +x /usr/local/bin/steampipe - name: Install jq run: | - brew install jq + sudo apt-get update + sudo apt-get install -y jq + + - name: Create steampipe user and setup environment + run: | + sudo useradd -m steampipe + sudo mkdir -p /home/steampipe/.steampipe/logs + sudo chown -R steampipe:steampipe /home/steampipe - name: Get runner/container info run: | uname -a - sw_vers + cat /etc/os-release - name: Run smoke tests run: | chmod +x $GITHUB_WORKSPACE/scripts/smoke_test.sh - $GITHUB_WORKSPACE/scripts/smoke_test.sh \ No newline at end of file + sudo cp $GITHUB_WORKSPACE/scripts/smoke_test.sh /home/steampipe/smoke_test.sh + sudo chown steampipe:steampipe /home/steampipe/smoke_test.sh + sudo -u steampipe /home/steampipe/smoke_test.sh + + notify_completion: + name: Notify completion + runs-on: ubuntu-latest + needs: + [ + smoke_test_ubuntu_24, + smoke_test_centos_9, + smoke_test_amazonlinux, + smoke_test_linux_arm64, + ] + if: always() + steps: + - name: Check results and notify + run: | + # Check if all jobs succeeded + UBUNTU_24_RESULT="${{ needs.smoke_test_ubuntu_24.result }}" + CENTOS_9_RESULT="${{ needs.smoke_test_centos_9.result }}" + AMAZONLINUX_RESULT="${{ needs.smoke_test_amazonlinux.result }}" + ARM64_RESULT="${{ needs.smoke_test_linux_arm64.result }}" + + WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + + if [ "$UBUNTU_24_RESULT" = "success" ] && [ "$CENTOS_9_RESULT" = "success" ] && [ "$AMAZONLINUX_RESULT" = "success" ] && [ "$ARM64_RESULT" = "success" ]; then + MESSAGE="āœ… Steampipe ${{ env.VERSION }} smoke tests passed!\n\nšŸ”— View details: $WORKFLOW_URL" + else + MESSAGE="āŒ Steampipe ${{ env.VERSION }} smoke tests failed!\n\nšŸ”— View details: $WORKFLOW_URL" + fi + + curl -X POST -H 'Content-type: application/json' \ + --data "{\"text\":\"$MESSAGE\"}" \ + ${{ env.SLACK_WEBHOOK_URL }} diff --git a/pkg/cmdconfig/cmd_hooks.go b/pkg/cmdconfig/cmd_hooks.go index 9d1b6e4f57..fd7ff4162d 100644 --- a/pkg/cmdconfig/cmd_hooks.go +++ b/pkg/cmdconfig/cmd_hooks.go @@ -12,8 +12,6 @@ import ( "strings" "time" - pfilepaths "github.com/turbot/pipe-fittings/v2/filepaths" - "github.com/fatih/color" "github.com/hashicorp/go-hclog" "github.com/mattn/go-isatty" @@ -24,6 +22,7 @@ import ( "github.com/turbot/pipe-fittings/v2/app_specific" pconstants "github.com/turbot/pipe-fittings/v2/constants" perror_helpers "github.com/turbot/pipe-fittings/v2/error_helpers" + pfilepaths "github.com/turbot/pipe-fittings/v2/filepaths" "github.com/turbot/pipe-fittings/v2/parse" "github.com/turbot/pipe-fittings/v2/pipes" "github.com/turbot/pipe-fittings/v2/utils" @@ -243,6 +242,9 @@ func initGlobalConfig() perror_helpers.ErrorAndWarnings { SetDefaultsFromConfig(loader.ConfiguredProfile.ConfigMap(cmd)) } + // now env vars have been processed, set PipesInstallDir + pfilepaths.PipesInstallDir = viper.GetString(pconstants.ArgPipesInstallDir) + // NOTE: we need to resolve the token separately // - that is because we need the resolved value of ArgPipesHost in order to load any saved token // and we cannot get this until the other config has been resolved @@ -392,7 +394,6 @@ func createLogger(logBuffer *bytes.Buffer, cmd *cobra.Command) { } func ensureInstallDir() { - pipesInstallDir := viper.GetString(pconstants.ArgPipesInstallDir) installDir := viper.GetString(pconstants.ArgInstallDir) log.Printf("[TRACE] ensureInstallDir %s", installDir) @@ -402,15 +403,8 @@ func ensureInstallDir() { error_helpers.FailOnErrorWithMessage(err, fmt.Sprintf("could not create installation directory: %s", installDir)) } - if _, err := os.Stat(pipesInstallDir); os.IsNotExist(err) { - log.Printf("[TRACE] creating install dir") - err = os.MkdirAll(pipesInstallDir, 0755) - error_helpers.FailOnErrorWithMessage(err, fmt.Sprintf("could not create pipes installation directory: %s", pipesInstallDir)) - } - - // store as app_specific.InstallDir and PipesInstallDir + // store as app_specific.InstallDir app_specific.InstallDir = installDir - pfilepaths.PipesInstallDir = pipesInstallDir } // displayDeprecationWarnings shows the deprecated warnings in a formatted way diff --git a/pkg/cmdconfig/viper.go b/pkg/cmdconfig/viper.go index 3049395dcb..bf0eb48f04 100644 --- a/pkg/cmdconfig/viper.go +++ b/pkg/cmdconfig/viper.go @@ -152,6 +152,7 @@ func setDefaultsFromEnv() { constants.EnvUpdateCheck: {[]string{pconstants.ArgUpdateCheck}, Bool}, constants.EnvPipesHost: {[]string{pconstants.ArgPipesHost}, String}, constants.EnvPipesToken: {[]string{pconstants.ArgPipesToken}, String}, + constants.EnvPipesInstallDir: {[]string{pconstants.ArgPipesInstallDir}, String}, constants.EnvSnapshotLocation: {[]string{pconstants.ArgSnapshotLocation}, String}, constants.EnvWorkspaceDatabase: {[]string{pconstants.ArgWorkspaceDatabase}, String}, constants.EnvServicePassword: {[]string{pconstants.ArgServicePassword}, String}, diff --git a/pkg/constants/env.go b/pkg/constants/env.go index 35ce793f01..2b270f8679 100644 --- a/pkg/constants/env.go +++ b/pkg/constants/env.go @@ -16,8 +16,9 @@ const ( EnvWorkspaceDatabase = "STEAMPIPE_WORKSPACE_DATABASE" EnvWorkspaceProfile = "STEAMPIPE_WORKSPACE" - EnvPipesHost = "PIPES_HOST" - EnvPipesToken = "PIPES_TOKEN" + EnvPipesHost = "PIPES_HOST" + EnvPipesToken = "PIPES_TOKEN" + EnvPipesInstallDir = "PIPES_INSTALL_DIR" EnvDisplayWidth = "STEAMPIPE_DISPLAY_WIDTH" EnvCacheEnabled = "STEAMPIPE_CACHE" diff --git a/pkg/db/db_local/stop_services.go b/pkg/db/db_local/stop_services.go index e02adc2efb..ed1a620da9 100644 --- a/pkg/db/db_local/stop_services.go +++ b/pkg/db/db_local/stop_services.go @@ -18,7 +18,6 @@ import ( "github.com/turbot/steampipe/v2/pkg/filepaths" "github.com/turbot/steampipe/v2/pkg/pluginmanager" "github.com/turbot/steampipe/v2/pkg/statushooks" - "github.com/turbot/steampipe/v2/pkg/utils" ) // StopStatus is a pseudoEnum for service stop result @@ -304,7 +303,7 @@ func waitForProcessExit(process *psutils.Process, waitFor time.Duration) bool { for { select { case <-checkTimer.C: - pEx, _ := utils.PidExists(int(process.Pid)) + pEx, _ := putils.PidExists(int(process.Pid)) if pEx { continue }