From b84037b3cf88bc074aae41e75ede25425f3cc6ca Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Thu, 28 Nov 2024 12:26:48 +0530 Subject: [PATCH 01/32] Add github action for hab pkg and publish Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 103 +++++++++++++++++++++++ .github/workflows/habitat-publish.yml | 113 ++++++++++++++++++++++++++ 2 files changed, 216 insertions(+) create mode 100644 .github/workflows/habitat-build.yml create mode 100644 .github/workflows/habitat-publish.yml diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml new file mode 100644 index 00000000..d3683854 --- /dev/null +++ b/.github/workflows/habitat-build.yml @@ -0,0 +1,103 @@ +name: Build Habitat packages + +on: + push: + branches: + - workstation-LTS + pull_request: + branches: + - workstation-LTS + +env: + # BLDR URL Defined as: 'https://bldr.habitat.sh/' but as an env var in workspace settings. + BLDR_URL: ${{vars.BLDR_URL}} + # HAB_ORIGIN Defined as: 'chef' defined in workspace settings. + HAB_ORIGIN: ${{vars.HAB_ORIGIN}} + # BLDR_CHANNEL defaulted to unstable, but can be switched to stable, it is defined via the environment setting https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment + BLDR_CHANNEL: ${{ vars.BLDR_CHANNEL }} + # HABITAT_VERSION_SET this is the version of habitat CLI you are using, defaults to latest. + HABITAT_VERSION_SET: ${{vars.HABITAT_VERSION_SET}} + # HAB_AUTH_TOKEN your orgs/projects auth token value + HAB_AUTH_TOKEN: ${{ secrets.HAB_AUTH_TOKEN }} + # HABITAT_TARGET this is the CPU arch for the linux CLI tool, its defaulted to x86_64 + #HABITAT_TARGET: $#{{vars.HABITAT_TARGET}} + HAB_FALLBACK_CHANNEL: ${{vars.HAB_FALLBACK_CHANNEL}} + +permissions: + contents: write + +jobs: + pre-build: + name: Setup before building packages + runs-on: ubuntu-latest + outputs: + app_version: ${{ steps.app_version.outputs.APP_VERSION }} + steps: + - name: Get branch name + id: get_branch_name + run: | + echo "BRANCH_NAME=${GITHUB_REF_NAME//\//-}" >> "$GITHUB_OUTPUT" + - name: Get version from tag + id: app_version + run: | + echo "APP_VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('{0}-{1}', steps.get_branch_name.outputs.BRANCH_NAME, github.sha) }}" >> "$GITHUB_OUTPUT" + agent-matrix: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + # matrix strategy is described at https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs + + runs-on: ${{ matrix.os }} + # free runner types are https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners + # from macos-latest, windows-latest, ubuntu-latest, ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-2019, windows-2016 + # included software packages on runners are at https://github.com/actions/runner-images#available-images + # defaulted to unstable, but can be switched to stable, it is defined via the environment setting https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment + # environment: unstable + steps: + - name: print OS + run: echo "--- ${{ matrix.os }}" + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + + - name: install habitat on Linux + if: ${{ matrix.os == 'ubuntu-latest' }} + shell: bash + run: | + echo "--- STARTING HAB INSTALL ON ${{ matrix.os }} UBUNTU with habitat version:${{vars.HABITAT_VERSION_SET}}" + export HABITAT_VERSION="${{vars.HABITAT_VERSION_SET}}" + export HAB_FALLBACK_CHANNEL="${{vars.HAB_FALLBACK_CHANNEL}}" + HABITAT_VERSION="${HABITAT_VERSION:?HABITAT_VERSION must be set}" + HABITAT_TARGET="${HABITAT_TARGET:-x86_64-linux}" + curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo bash -s -- -v "$HABITAT_VERSION" -t "$HABITAT_TARGET" + - name: run Habitat packaging (linux) + if: ${{ matrix.os == 'ubuntu-latest' }} + shell: bash + run: | + hab license accept + hab origin key download $HAB_ORIGIN + hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN + echo "--- running linux hab build" + hab pkg build . + - name: Install Habitat on Windows + if: ${{ matrix.os == 'windows-latest' }} + shell: pwsh + run: | + write-output "--- STARTING HAB INSTALL ON ${{ matrix.os }} WINDOWS with habitat version:${{vars.HABITAT_VERSION_SET}}" + $env:HAB_LICENSE = "accept-no-persist" + $env:HAB_FALLBACK_CHANNEL= "${{vars.HAB_FALLBACK_CHANNEL}}" + Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.ps1) } -Version ${{vars.HABITAT_VERSION_SET}}" + - name: run habitat packaging windows + if: ${{ matrix.os == 'windows-latest' }} + shell: pwsh + run: | + $env:Path += ";C:\ProgramData\Habitat" + + hab license accept + hab origin key download ${{ env.HAB_ORIGIN }} + hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} + write-output "--- running windows hab build" + hab pkg build . \ No newline at end of file diff --git a/.github/workflows/habitat-publish.yml b/.github/workflows/habitat-publish.yml new file mode 100644 index 00000000..33b9549f --- /dev/null +++ b/.github/workflows/habitat-publish.yml @@ -0,0 +1,113 @@ +name: Publish Habitat packages + +on: + push: + branches: + - workstation-LTS + release: + types: + - created + +env: + # BLDR URL Defined as: 'https://bldr.habitat.sh/' but as an env var in workspace settings. + BLDR_URL: ${{vars.BLDR_URL}} + # HAB_ORIGIN Defined as: 'chef' defined in workspace settings. + HAB_ORIGIN: ${{vars.HAB_ORIGIN}} + # BLDR_CHANNEL defaulted to unstable, but can be switched to stable, it is defined via the environment setting https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment + BLDR_CHANNEL: ${{ vars.BLDR_CHANNEL }} + # HABITAT_VERSION_SET this is the version of habitat CLI you are using, defaults to latest. + HABITAT_VERSION_SET: ${{vars.HABITAT_VERSION_SET}} + # HAB_PACKAGE is the name of the project you are on, IE: node-management-agent + HAB_PACKAGE: ${{vars.HAB_PACKAGE}} + # HAB_AUTH_TOKEN your orgs/projects auth token value + HAB_AUTH_TOKEN: ${{ secrets.HAB_AUTH_TOKEN }} + HAB_FALLBACK_CHANNEL: ${{vars.HAB_FALLBACK_CHANNEL}} + # HABITAT_TARGET this is the CPU arch for the linux CLI tool, its defaulted to x86_64 + #HABITAT_TARGET: $#{{vars.HABITAT_TARGET}} + # org-wide access token on https://github.com/organizations/progress-platform-services/settings/secrets/actions + +permissions: + contents: write + +jobs: + pre-build: + name: Setup before building packages + runs-on: ubuntu-latest + outputs: + app_version: ${{ steps.app_version.outputs.APP_VERSION }} + steps: + - name: Get branch name + id: get_branch_name + run: | + echo "BRANCH_NAME=${GITHUB_REF_NAME//\//-}" >> "$GITHUB_OUTPUT" + - name: Get version from tag + id: app_version + run: | + echo "APP_VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('{0}-{1}', steps.get_branch_name.outputs.BRANCH_NAME, github.sha) }}" >> "$GITHUB_OUTPUT" + agent-matrix: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + # matrix strategy is described at https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs + + runs-on: ${{ matrix.os }} + # free runner types are https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners + # from macos-latest, windows-latest, ubuntu-latest, ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-2019, windows-2016 + # included software packages on runners are at https://github.com/actions/runner-images#available-images + # environment: unstable + steps: + - name: print OS + run: echo "--- ${{ matrix.os }}" + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + + - name: install habitat on Linux + if: ${{ matrix.os == 'ubuntu-latest' }} + shell: bash + run: | + echo "--- STARTING HAB INSTALL ON ${{ matrix.os }} UBUNTU with habitat version:${{vars.HABITAT_VERSION_SET}}" + export HABITAT_VERSION="${{vars.HABITAT_VERSION_SET}}" + HABITAT_VERSION="${HABITAT_VERSION:?HABITAT_VERSION must be set}" + HABITAT_TARGET="${HABITAT_TARGET:-x86_64-linux}" + export HAB_FALLBACK_CHANNEL="${{vars.HAB_FALLBACK_CHANNEL}}" + curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo bash -s -- -v "$HABITAT_VERSION" -t "$HABITAT_TARGET" + - name: run Habitat packaging (linux) + if: ${{ matrix.os == 'ubuntu-latest' }} + shell: bash + run: | + hab license accept + hab origin key download $HAB_ORIGIN + hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN + echo "--- running linux hab build" + hab pkg build . + echo "--- pushing to ${{ env.BLDR_URL }}/#/${{ env.HAB_ORIGIN }}/${{ env.HAB_PACKAGE }}..." + source results/last_build.env + hab pkg upload --auth $HAB_AUTH_TOKEN results/$pkg_artifact + echo "--- push complete!!" + - name: Install Habitat on Windows + if: ${{ matrix.os == 'windows-latest' }} + shell: pwsh + run: | + write-output "--- STARTING HAB INSTALL ON ${{ matrix.os }} WINDOWS with habitat version:${{vars.HABITAT_VERSION_SET}}" + $env:HAB_LICENSE = "accept-no-persist" + $env:HAB_FALLBACK_CHANNEL= "${{vars.HAB_FALLBACK_CHANNEL}}" + Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.ps1) } -Version ${{vars.HABITAT_VERSION_SET}}" + - name: run habitat packaging windows + if: ${{ matrix.os == 'windows-latest' }} + shell: pwsh + run: | + $env:Path += ";C:\ProgramData\Habitat" + hab license accept + hab origin key download ${{ env.HAB_ORIGIN }} + hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} + write-output "--- running windows hab build" + hab pkg build . + write-output "--- pushing hab to unstable channel" + . results\last_build.ps1 + hab pkg upload results\$pkg_artifact --auth ${{ secrets.HAB_AUTH_TOKEN }} + write-output "--- push complete!!" + outreach \ No newline at end of file From b28202eea0ecef24b3a2c9ecc3ec6fc8f5e7d019 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 12:56:59 +0530 Subject: [PATCH 02/32] Added version check on new hab pkg Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 5 ++++- habitat/tests/test.pester.ps1 | 33 +++++++++++++++++++++++++++++ habitat/tests/test.ps1 | 19 +++++++++++++++++ habitat/tests/test.sh | 29 +++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 habitat/tests/test.pester.ps1 create mode 100644 habitat/tests/test.ps1 create mode 100755 habitat/tests/test.sh diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index d3683854..72b0f89b 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -82,6 +82,8 @@ jobs: hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN echo "--- running linux hab build" hab pkg build . + chmod +x habitat/tests/test.sh + habitat/tests/test.sh - name: Install Habitat on Windows if: ${{ matrix.os == 'windows-latest' }} shell: pwsh @@ -100,4 +102,5 @@ jobs: hab origin key download ${{ env.HAB_ORIGIN }} hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} write-output "--- running windows hab build" - hab pkg build . \ No newline at end of file + hab pkg build . + habitat/tests/test.ps1 \ No newline at end of file diff --git a/habitat/tests/test.pester.ps1 b/habitat/tests/test.pester.ps1 new file mode 100644 index 00000000..4ffdd762 --- /dev/null +++ b/habitat/tests/test.pester.ps1 @@ -0,0 +1,33 @@ +param( + [Parameter()] + [string]$PackageIdentifier = $(throw "Usage: test.ps1 [test_pkg_ident] e.g. test.ps1 ci/user-windows-default/1.0.0/20190812103929") +) + +$PackageVersion = $PackageIdentifier.split('/')[2] + +Describe "chef-cli" { + Context "chef-cli" { + It "is an executable" { + hab pkg exec $PackageIdentifier chef-cli.bat --version + $? | Should be $true + } + + <# + At some point hab's argument parsing changed and it started interpreting the trailing `--version` as being + an argument passed to hab instead of an argument to the command passed to `hab pkg exec`. + + Powershell 5.1 and 7 appear to differ in how they treat following arguments as well, such that these two + versions of the command fail in powershell 5.1 (which is currently what is running in the windows machines + in Buildkite) but pass in powershell 7 (which is currently what is running in a stock Windows 10 VM). + + $the_version = (hab pkg exec $PackageIdentifier chef-client.bat '--version' | Out-String).split(':')[1].Trim() + $the_version = (hab pkg exec $PackageIdentifier chef-client.bat --version | Out-String).split(':')[1].Trim() + + This version of the command passes in powershell 5.1 but fails in powershell 7. + #> + It "is the expected version" { + $the_version = (hab pkg exec $PackageIdentifier chef-cli.bat -- --version | Out-String).split(':')[1].Trim() + $the_version | Should be $PackageVersion + } + } +} diff --git a/habitat/tests/test.ps1 b/habitat/tests/test.ps1 new file mode 100644 index 00000000..70ce5a04 --- /dev/null +++ b/habitat/tests/test.ps1 @@ -0,0 +1,19 @@ +param ( + [Parameter()] + [string]$PackageIdentifier = $(throw "Usage: test.ps1 [test_pkg_ident] e.g. test.ps1 ci/user-windows/1.0.0/20190812103929") +) + +# ensure Pester is available for test use +if (-Not (Get-Module -ListAvailable -Name Pester)){ + hab pkg install core/pester + Import-Module "$(hab pkg path core/pester)\module\pester.psd1" +} + +Write-Host "--- :fire: Smokish Pestering" +# Pester the Package +$__dir=(Get-Item $PSScriptRoot) +$test_result = Invoke-Pester -Strict -PassThru -Script @{ + Path = "$__dir/test.pester.ps1"; + Parameters = @{PackageIdentifier=$PackageIdentifier} +} +if ($test_result.FailedCount -ne 0) { Exit $test_result.FailedCount } diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh new file mode 100755 index 00000000..c9e19f5a --- /dev/null +++ b/habitat/tests/test.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -euo pipefail + + +project_root="$(git rev-parse --show-toplevel)" +pkg_ident="$1" + +# print error message followed by usage and exit +error () { + local message="$1" + + echo -e "\nERROR: ${message}\n" >&2 + + exit 1 +} + +[[ -n "$pkg_ident" ]] || error 'no hab package identity provided' + +package_version=$(awk -F / '{print $3}' <<<"$pkg_ident") + +cd "${project_root}" + +echo "--- :mag_right: Testing ${pkg_ident} executables" +actual_version=$(hab pkg exec "${pkg_ident}" chef-cli -- -v | sed -E 's/.*Version ([0-9]+\.[0-9]+\.[0-9]+).*/\1/') +[[ "$package_version" = "$actual_version" ]] || error "chef-cli is not the expected version. Expected '$package_version', got '$actual_version'" + +echo "--- :Running rake" +hab pkg exec "${pkg_ident}" rake unit \ No newline at end of file From f8ec8a619b896f2e10b0975c3e739a675f756a1b Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 13:07:02 +0530 Subject: [PATCH 03/32] removed extra keyword for triggering pipeline Signed-off-by: nitin sanghi --- .github/workflows/habitat-publish.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/habitat-publish.yml b/.github/workflows/habitat-publish.yml index 33b9549f..956eb132 100644 --- a/.github/workflows/habitat-publish.yml +++ b/.github/workflows/habitat-publish.yml @@ -109,5 +109,4 @@ jobs: write-output "--- pushing hab to unstable channel" . results\last_build.ps1 hab pkg upload results\$pkg_artifact --auth ${{ secrets.HAB_AUTH_TOKEN }} - write-output "--- push complete!!" - outreach \ No newline at end of file + write-output "--- push complete!!" \ No newline at end of file From a6efdb6e7d6442780d2eefa5750ce020202985ac Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 13:18:26 +0530 Subject: [PATCH 04/32] pkg iden added using vars Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 4 ++-- habitat/tests/test.sh | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index 72b0f89b..61c4b019 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -83,7 +83,7 @@ jobs: echo "--- running linux hab build" hab pkg build . chmod +x habitat/tests/test.sh - habitat/tests/test.sh + habitat/tests/test.sh "${{vars.PKG_IDENT}}" - name: Install Habitat on Windows if: ${{ matrix.os == 'windows-latest' }} shell: pwsh @@ -103,4 +103,4 @@ jobs: hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} write-output "--- running windows hab build" hab pkg build . - habitat/tests/test.ps1 \ No newline at end of file + habitat/tests/test.ps1 "${{vars.PKG_IDENT}}" \ No newline at end of file diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh index c9e19f5a..06e05c56 100755 --- a/habitat/tests/test.sh +++ b/habitat/tests/test.sh @@ -1,4 +1,3 @@ -#!/usr/bin/env bash set -euo pipefail @@ -26,4 +25,4 @@ actual_version=$(hab pkg exec "${pkg_ident}" chef-cli -- -v | sed -E 's/.*Versio [[ "$package_version" = "$actual_version" ]] || error "chef-cli is not the expected version. Expected '$package_version', got '$actual_version'" echo "--- :Running rake" -hab pkg exec "${pkg_ident}" rake unit \ No newline at end of file +hab pkg exec "${pkg_ident}" rake unit From 79a96828f4f7ae991a626e4ec7ee65302c78e2c8 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 13:26:42 +0530 Subject: [PATCH 05/32] list all pkg to verify pkg installed Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 1 + habitat/tests/test.ps1 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index 61c4b019..36e28eef 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -103,4 +103,5 @@ jobs: hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} write-output "--- running windows hab build" hab pkg build . + hab pkg list --all habitat/tests/test.ps1 "${{vars.PKG_IDENT}}" \ No newline at end of file diff --git a/habitat/tests/test.ps1 b/habitat/tests/test.ps1 index 70ce5a04..a0df7c70 100644 --- a/habitat/tests/test.ps1 +++ b/habitat/tests/test.ps1 @@ -13,7 +13,7 @@ Write-Host "--- :fire: Smokish Pestering" # Pester the Package $__dir=(Get-Item $PSScriptRoot) $test_result = Invoke-Pester -Strict -PassThru -Script @{ - Path = "$__dir/test.pester.ps1"; + Path = "habitat/tests/test.pester.ps1"; Parameters = @{PackageIdentifier=$PackageIdentifier} } if ($test_result.FailedCount -ne 0) { Exit $test_result.FailedCount } From 1e23969aaab15d520b49cd840cbcd40dfa4e03c8 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 14:01:02 +0530 Subject: [PATCH 06/32] Installing hab build using hart file Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index 36e28eef..4f48761a 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -82,6 +82,9 @@ jobs: hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN echo "--- running linux hab build" hab pkg build . + hartfile=$(ls /src/result *.hart | grep "chef-cli" | tail -n 1) + hab pkg install hartfile + hab pkg list --all chmod +x habitat/tests/test.sh habitat/tests/test.sh "${{vars.PKG_IDENT}}" - name: Install Habitat on Windows From 837c975ae745701a034234a2b8aec015186c3df0 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 14:05:12 +0530 Subject: [PATCH 07/32] Installing hab build using hart file Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index 4f48761a..aaa36808 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -82,8 +82,8 @@ jobs: hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN echo "--- running linux hab build" hab pkg build . - hartfile=$(ls /src/result *.hart | grep "chef-cli" | tail -n 1) - hab pkg install hartfile + hartfile=$(ls /src/results *.hart | grep "chef-cli" | tail -n 1) + hab pkg install $hartfile hab pkg list --all chmod +x habitat/tests/test.sh habitat/tests/test.sh "${{vars.PKG_IDENT}}" From f0c4fd4843496f575837957ae7fbf3f5d08b338e Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 14:08:56 +0530 Subject: [PATCH 08/32] Installing hab build using hart file Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index aaa36808..fa2db1a5 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -82,7 +82,7 @@ jobs: hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN echo "--- running linux hab build" hab pkg build . - hartfile=$(ls /src/results *.hart | grep "chef-cli" | tail -n 1) + hartfile=$(ls /hab/cache/artifacts/ *.hart | grep "chef-cli" | tail -n 1) hab pkg install $hartfile hab pkg list --all chmod +x habitat/tests/test.sh From 77a5436fd9905233d2243fa7ad3b79df193df7d1 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 14:14:01 +0530 Subject: [PATCH 09/32] pipeline test commit Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index fa2db1a5..0f1f1b96 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -82,6 +82,8 @@ jobs: hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN echo "--- running linux hab build" hab pkg build . + ls /hab/cache/artifacts/ + ls /src/results hartfile=$(ls /hab/cache/artifacts/ *.hart | grep "chef-cli" | tail -n 1) hab pkg install $hartfile hab pkg list --all From f31c62406bad27628d1c4cfad5c6155020400e06 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 14:18:03 +0530 Subject: [PATCH 10/32] pipeline test commit Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index 0f1f1b96..6655bdc7 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -83,7 +83,7 @@ jobs: echo "--- running linux hab build" hab pkg build . ls /hab/cache/artifacts/ - ls /src/results + ls ./results hartfile=$(ls /hab/cache/artifacts/ *.hart | grep "chef-cli" | tail -n 1) hab pkg install $hartfile hab pkg list --all From ed2cc27e2e466ed9c34d804827cd48c1387efd6b Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 14:21:24 +0530 Subject: [PATCH 11/32] pipeline test commit Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index 6655bdc7..ea56ccbf 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -82,9 +82,7 @@ jobs: hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN echo "--- running linux hab build" hab pkg build . - ls /hab/cache/artifacts/ - ls ./results - hartfile=$(ls /hab/cache/artifacts/ *.hart | grep "chef-cli" | tail -n 1) + hartfile=$(ls ./results *.hart | grep "chef-cli" | tail -n 1) hab pkg install $hartfile hab pkg list --all chmod +x habitat/tests/test.sh From 831f6479ee290b8b520106036c24a594c1311759 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 14:26:37 +0530 Subject: [PATCH 12/32] pipeline test commit Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index ea56ccbf..43a910f1 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -82,7 +82,7 @@ jobs: hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN echo "--- running linux hab build" hab pkg build . - hartfile=$(ls ./results *.hart | grep "chef-cli" | tail -n 1) + hartfile=$(ls ./results | grep "chef-cli" | tail -n 1) hab pkg install $hartfile hab pkg list --all chmod +x habitat/tests/test.sh From e5133b3b087e8cdda21a28f56b81e90ee3e49be1 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 14:29:47 +0530 Subject: [PATCH 13/32] pipeline test commit Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index 43a910f1..e2349f59 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -83,7 +83,7 @@ jobs: echo "--- running linux hab build" hab pkg build . hartfile=$(ls ./results | grep "chef-cli" | tail -n 1) - hab pkg install $hartfile + hab pkg install ./results/$hartfile hab pkg list --all chmod +x habitat/tests/test.sh habitat/tests/test.sh "${{vars.PKG_IDENT}}" From 8164c5a260b571f73e9ef2e17b0f75f5be2877cd Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 14:35:02 +0530 Subject: [PATCH 14/32] sudo for installing hab pkg Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index e2349f59..0194a41c 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -83,7 +83,7 @@ jobs: echo "--- running linux hab build" hab pkg build . hartfile=$(ls ./results | grep "chef-cli" | tail -n 1) - hab pkg install ./results/$hartfile + sudo hab pkg install ./results/$hartfile hab pkg list --all chmod +x habitat/tests/test.sh habitat/tests/test.sh "${{vars.PKG_IDENT}}" From f015165103039f68b68f8caf2bd857ad9e6ee164 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 14:40:56 +0530 Subject: [PATCH 15/32] sudo for installing hab pkg Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index 0194a41c..fc64d9d4 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -72,6 +72,8 @@ jobs: export HAB_FALLBACK_CHANNEL="${{vars.HAB_FALLBACK_CHANNEL}}" HABITAT_VERSION="${HABITAT_VERSION:?HABITAT_VERSION must be set}" HABITAT_TARGET="${HABITAT_TARGET:-x86_64-linux}" + CHEF_LICENSE="accept-no-persist" + HAB_LICENSE="accept-no-persist" curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo bash -s -- -v "$HABITAT_VERSION" -t "$HABITAT_TARGET" - name: run Habitat packaging (linux) if: ${{ matrix.os == 'ubuntu-latest' }} From 2677bea87cd4e25ffc8d1c26fe89e0700e539388 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 14:46:10 +0530 Subject: [PATCH 16/32] sudo for installing hab pkg Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index fc64d9d4..8f73487a 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -72,8 +72,6 @@ jobs: export HAB_FALLBACK_CHANNEL="${{vars.HAB_FALLBACK_CHANNEL}}" HABITAT_VERSION="${HABITAT_VERSION:?HABITAT_VERSION must be set}" HABITAT_TARGET="${HABITAT_TARGET:-x86_64-linux}" - CHEF_LICENSE="accept-no-persist" - HAB_LICENSE="accept-no-persist" curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo bash -s -- -v "$HABITAT_VERSION" -t "$HABITAT_TARGET" - name: run Habitat packaging (linux) if: ${{ matrix.os == 'ubuntu-latest' }} @@ -85,7 +83,12 @@ jobs: echo "--- running linux hab build" hab pkg build . hartfile=$(ls ./results | grep "chef-cli" | tail -n 1) + sudo hab license accept + export CHEF_LICENSE="accept-no-persist" + export HAB_LICENSE="accept-no-persist" + export HAB_NONINTERACTIVE="true" sudo hab pkg install ./results/$hartfile + hab pkg list --all chmod +x habitat/tests/test.sh habitat/tests/test.sh "${{vars.PKG_IDENT}}" From 409d9e74608ed92de4bf9c056420bbd1e9359a6f Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 14:55:43 +0530 Subject: [PATCH 17/32] sudo for installing hab pkg Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 4 ++-- habitat/tests/test.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index 8f73487a..6a13a4e1 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -91,7 +91,7 @@ jobs: hab pkg list --all chmod +x habitat/tests/test.sh - habitat/tests/test.sh "${{vars.PKG_IDENT}}" + habitat/tests/test.sh $hartfile - name: Install Habitat on Windows if: ${{ matrix.os == 'windows-latest' }} shell: pwsh @@ -112,4 +112,4 @@ jobs: write-output "--- running windows hab build" hab pkg build . hab pkg list --all - habitat/tests/test.ps1 "${{vars.PKG_IDENT}}" \ No newline at end of file + habitat/tests/test.ps1 \ No newline at end of file diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh index 06e05c56..e0b87773 100755 --- a/habitat/tests/test.sh +++ b/habitat/tests/test.sh @@ -21,7 +21,7 @@ package_version=$(awk -F / '{print $3}' <<<"$pkg_ident") cd "${project_root}" echo "--- :mag_right: Testing ${pkg_ident} executables" -actual_version=$(hab pkg exec "${pkg_ident}" chef-cli -- -v | sed -E 's/.*Version ([0-9]+\.[0-9]+\.[0-9]+).*/\1/') +actual_version=$(hab pkg exec "${pkg_ident}" chef-cli -v | sed -E 's/.*Version ([0-9]+\.[0-9]+\.[0-9]+).*/\1/') [[ "$package_version" = "$actual_version" ]] || error "chef-cli is not the expected version. Expected '$package_version', got '$actual_version'" echo "--- :Running rake" From a5713556ea8456aef38ae1905e2bda240a2cf817 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 15:06:55 +0530 Subject: [PATCH 18/32] hart file version change Signed-off-by: nitin sanghi --- habitat/tests/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh index e0b87773..e6593094 100755 --- a/habitat/tests/test.sh +++ b/habitat/tests/test.sh @@ -16,7 +16,7 @@ error () { [[ -n "$pkg_ident" ]] || error 'no hab package identity provided' -package_version=$(awk -F / '{print $3}' <<<"$pkg_ident") +package_version=$(awk -F - '{print $4}' <<<"$pkg_ident") cd "${project_root}" From 440380d6fd764f281067b41e32770a4c9d3e9863 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 15:20:39 +0530 Subject: [PATCH 19/32] Change pkg_indent Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 6 +++--- habitat/tests/test.sh | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index 6a13a4e1..a3206605 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -88,10 +88,10 @@ jobs: export HAB_LICENSE="accept-no-persist" export HAB_NONINTERACTIVE="true" sudo hab pkg install ./results/$hartfile - - hab pkg list --all + . ./results/last_build.env + export pkg_ident chmod +x habitat/tests/test.sh - habitat/tests/test.sh $hartfile + habitat/tests/test.sh - name: Install Habitat on Windows if: ${{ matrix.os == 'windows-latest' }} shell: pwsh diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh index e6593094..0dbf423f 100755 --- a/habitat/tests/test.sh +++ b/habitat/tests/test.sh @@ -3,7 +3,6 @@ set -euo pipefail project_root="$(git rev-parse --show-toplevel)" -pkg_ident="$1" # print error message followed by usage and exit error () { @@ -16,7 +15,7 @@ error () { [[ -n "$pkg_ident" ]] || error 'no hab package identity provided' -package_version=$(awk -F - '{print $4}' <<<"$pkg_ident") +package_version=$(awk -F '{print $4}' <<<"$pkg_ident") cd "${project_root}" From 8982668dd130ccf802e6611abc55bf2d26d18186 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 15:37:48 +0530 Subject: [PATCH 20/32] Change pkg_indent Signed-off-by: nitin sanghi --- habitat/tests/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh index 0dbf423f..60860574 100755 --- a/habitat/tests/test.sh +++ b/habitat/tests/test.sh @@ -15,7 +15,7 @@ error () { [[ -n "$pkg_ident" ]] || error 'no hab package identity provided' -package_version=$(awk -F '{print $4}' <<<"$pkg_ident") +package_version=$(awk -F / '{print $3}' <<<"$pkg_ident") cd "${project_root}" From b9c9f6ed1388593ab5b725a27e25816524a64baa Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 15:48:50 +0530 Subject: [PATCH 21/32] version regex changed Signed-off-by: nitin sanghi --- habitat/tests/test.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh index 60860574..4ce9d81d 100755 --- a/habitat/tests/test.sh +++ b/habitat/tests/test.sh @@ -20,8 +20,7 @@ package_version=$(awk -F / '{print $3}' <<<"$pkg_ident") cd "${project_root}" echo "--- :mag_right: Testing ${pkg_ident} executables" -actual_version=$(hab pkg exec "${pkg_ident}" chef-cli -v | sed -E 's/.*Version ([0-9]+\.[0-9]+\.[0-9]+).*/\1/') -[[ "$package_version" = "$actual_version" ]] || error "chef-cli is not the expected version. Expected '$package_version', got '$actual_version'" +actual_version=$(hab pkg exec "${pkg_ident}" chef-cli -v | sed -E 's/.*version: ([0-9]+\.[0-9]+\.[0-9]+).*/\1/') +[[ "$package_version" = "$actual_version" ]] || error "chef-cli version is not the expected version. Expected '$package_version', got '$actual_version'" + -echo "--- :Running rake" -hab pkg exec "${pkg_ident}" rake unit From 43350d484344104af751d242ab68f974d369b6d0 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 15:53:49 +0530 Subject: [PATCH 22/32] windows pipeline change Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index a3206605..63415e3d 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -105,11 +105,12 @@ jobs: shell: pwsh run: | $env:Path += ";C:\ProgramData\Habitat" - hab license accept hab origin key download ${{ env.HAB_ORIGIN }} hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} write-output "--- running windows hab build" hab pkg build . - hab pkg list --all + hartfile=$(ls ./results | grep "chef-cli" | tail -n 1) + hab pkg install ./results/$hartfile + . ./results/last_build.env habitat/tests/test.ps1 \ No newline at end of file From ca7fce090cc83fb4b793dba1d05cfc8d10b281b2 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 16:48:56 +0530 Subject: [PATCH 23/32] windows pipeline change Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index 63415e3d..2403ed50 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -98,6 +98,7 @@ jobs: run: | write-output "--- STARTING HAB INSTALL ON ${{ matrix.os }} WINDOWS with habitat version:${{vars.HABITAT_VERSION_SET}}" $env:HAB_LICENSE = "accept-no-persist" + $env:HAB_NONINTERACTIVE = "true" $env:HAB_FALLBACK_CHANNEL= "${{vars.HAB_FALLBACK_CHANNEL}}" Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.ps1) } -Version ${{vars.HABITAT_VERSION_SET}}" - name: run habitat packaging windows @@ -110,7 +111,7 @@ jobs: hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} write-output "--- running windows hab build" hab pkg build . - hartfile=$(ls ./results | grep "chef-cli" | tail -n 1) + hartfile=$(ls ./results | findstr "chef-cli") hab pkg install ./results/$hartfile - . ./results/last_build.env - habitat/tests/test.ps1 \ No newline at end of file + . ./results/last_build.ps1 + habitat/tests/test.ps1 $pkg_ident \ No newline at end of file From 7c25c1a03606dd9e475c7c3483ff965feecab2d6 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 16:55:23 +0530 Subject: [PATCH 24/32] windows pipeline change Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index 2403ed50..eadbc122 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -111,7 +111,7 @@ jobs: hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} write-output "--- running windows hab build" hab pkg build . - hartfile=$(ls ./results | findstr "chef-cli") + $hartfile=(ls ./results | findstr "chef-cli") hab pkg install ./results/$hartfile . ./results/last_build.ps1 habitat/tests/test.ps1 $pkg_ident \ No newline at end of file From cb338d54b577f97f73ac089ccb0ae335fb523958 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 17:01:54 +0530 Subject: [PATCH 25/32] windows pipeline change Signed-off-by: nitin sanghi --- .github/workflows/habitat-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml index eadbc122..3dfc1441 100644 --- a/.github/workflows/habitat-build.yml +++ b/.github/workflows/habitat-build.yml @@ -111,7 +111,7 @@ jobs: hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} write-output "--- running windows hab build" hab pkg build . - $hartfile=(ls ./results | findstr "chef-cli") + $hartfile=(ls ./results -Name | findstr "chef-cli") hab pkg install ./results/$hartfile . ./results/last_build.ps1 habitat/tests/test.ps1 $pkg_ident \ No newline at end of file From 0bc10546b63b7b772958f7bd82d070edd4e54601 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 17:33:39 +0530 Subject: [PATCH 26/32] Windows chef-cli hab version check Signed-off-by: nitin sanghi --- habitat/tests/test.pester.ps1 | 33 --------------------------------- habitat/tests/test.ps1 | 14 +++++++++----- 2 files changed, 9 insertions(+), 38 deletions(-) delete mode 100644 habitat/tests/test.pester.ps1 diff --git a/habitat/tests/test.pester.ps1 b/habitat/tests/test.pester.ps1 deleted file mode 100644 index 4ffdd762..00000000 --- a/habitat/tests/test.pester.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -param( - [Parameter()] - [string]$PackageIdentifier = $(throw "Usage: test.ps1 [test_pkg_ident] e.g. test.ps1 ci/user-windows-default/1.0.0/20190812103929") -) - -$PackageVersion = $PackageIdentifier.split('/')[2] - -Describe "chef-cli" { - Context "chef-cli" { - It "is an executable" { - hab pkg exec $PackageIdentifier chef-cli.bat --version - $? | Should be $true - } - - <# - At some point hab's argument parsing changed and it started interpreting the trailing `--version` as being - an argument passed to hab instead of an argument to the command passed to `hab pkg exec`. - - Powershell 5.1 and 7 appear to differ in how they treat following arguments as well, such that these two - versions of the command fail in powershell 5.1 (which is currently what is running in the windows machines - in Buildkite) but pass in powershell 7 (which is currently what is running in a stock Windows 10 VM). - - $the_version = (hab pkg exec $PackageIdentifier chef-client.bat '--version' | Out-String).split(':')[1].Trim() - $the_version = (hab pkg exec $PackageIdentifier chef-client.bat --version | Out-String).split(':')[1].Trim() - - This version of the command passes in powershell 5.1 but fails in powershell 7. - #> - It "is the expected version" { - $the_version = (hab pkg exec $PackageIdentifier chef-cli.bat -- --version | Out-String).split(':')[1].Trim() - $the_version | Should be $PackageVersion - } - } -} diff --git a/habitat/tests/test.ps1 b/habitat/tests/test.ps1 index a0df7c70..31897373 100644 --- a/habitat/tests/test.ps1 +++ b/habitat/tests/test.ps1 @@ -11,9 +11,13 @@ if (-Not (Get-Module -ListAvailable -Name Pester)){ Write-Host "--- :fire: Smokish Pestering" # Pester the Package -$__dir=(Get-Item $PSScriptRoot) -$test_result = Invoke-Pester -Strict -PassThru -Script @{ - Path = "habitat/tests/test.pester.ps1"; - Parameters = @{PackageIdentifier=$PackageIdentifier} +$version=hab pkg exec "${pkg_ident}" chef-cli -v +$actual_version=[Regex]::Match($version,"([0-9]+.[0-9]+.[0-9]+)").Value +$package_version=$PackageIdentifier.split("/",4)[2] +if ($package_version -eq $actual_version) +{ + Write "Chef-cli working fine" } -if ($test_result.FailedCount -ne 0) { Exit $test_result.FailedCount } +else { + Write-Error "chef-cli version not met expected $package_version actual version $actual_version " +} \ No newline at end of file From 10689fa2376288e2f3c0f7ec60a621b7f108577d Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 17:46:00 +0530 Subject: [PATCH 27/32] Windows chef-cli hab version check Signed-off-by: nitin sanghi --- habitat/tests/test.ps1 | 5 ----- 1 file changed, 5 deletions(-) diff --git a/habitat/tests/test.ps1 b/habitat/tests/test.ps1 index 31897373..fcc5d85d 100644 --- a/habitat/tests/test.ps1 +++ b/habitat/tests/test.ps1 @@ -3,11 +3,6 @@ param ( [string]$PackageIdentifier = $(throw "Usage: test.ps1 [test_pkg_ident] e.g. test.ps1 ci/user-windows/1.0.0/20190812103929") ) -# ensure Pester is available for test use -if (-Not (Get-Module -ListAvailable -Name Pester)){ - hab pkg install core/pester - Import-Module "$(hab pkg path core/pester)\module\pester.psd1" -} Write-Host "--- :fire: Smokish Pestering" # Pester the Package From 4c028bb5c070644029c314a953d406264d1dc6a4 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 17:46:36 +0530 Subject: [PATCH 28/32] Windows chef-cli hab version check Signed-off-by: nitin sanghi --- habitat/tests/test.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/habitat/tests/test.ps1 b/habitat/tests/test.ps1 index fcc5d85d..2e14c130 100644 --- a/habitat/tests/test.ps1 +++ b/habitat/tests/test.ps1 @@ -4,7 +4,7 @@ param ( ) -Write-Host "--- :fire: Smokish Pestering" +Write-Host "--- :fire: Smokish test" # Pester the Package $version=hab pkg exec "${pkg_ident}" chef-cli -v $actual_version=[Regex]::Match($version,"([0-9]+.[0-9]+.[0-9]+)").Value From 0924d5de174d3e81da5e2c6ef470dd69eff48174 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 19:48:48 +0530 Subject: [PATCH 29/32] Change the message in test phase and throw error Signed-off-by: nitin sanghi --- habitat/tests/test.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/habitat/tests/test.ps1 b/habitat/tests/test.ps1 index 2e14c130..aa11370d 100644 --- a/habitat/tests/test.ps1 +++ b/habitat/tests/test.ps1 @@ -9,10 +9,12 @@ Write-Host "--- :fire: Smokish test" $version=hab pkg exec "${pkg_ident}" chef-cli -v $actual_version=[Regex]::Match($version,"([0-9]+.[0-9]+.[0-9]+)").Value $package_version=$PackageIdentifier.split("/",4)[2] +Write-BuildLine "package_version $package_version actual version $actual_version" if ($package_version -eq $actual_version) { Write "Chef-cli working fine" } else { Write-Error "chef-cli version not met expected $package_version actual version $actual_version " + throw "Chef cli windows pipeline not working for hab pkg" } \ No newline at end of file From 9e3e65165d0de18474e2b86525fbc7c4f1f9679e Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Mon, 2 Dec 2024 20:07:35 +0530 Subject: [PATCH 30/32] Change the message in test phase and throw error Signed-off-by: nitin sanghi --- habitat/tests/test.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/habitat/tests/test.ps1 b/habitat/tests/test.ps1 index aa11370d..a712fea5 100644 --- a/habitat/tests/test.ps1 +++ b/habitat/tests/test.ps1 @@ -9,7 +9,8 @@ Write-Host "--- :fire: Smokish test" $version=hab pkg exec "${pkg_ident}" chef-cli -v $actual_version=[Regex]::Match($version,"([0-9]+.[0-9]+.[0-9]+)").Value $package_version=$PackageIdentifier.split("/",4)[2] -Write-BuildLine "package_version $package_version actual version $actual_version" + +Write-Host "package_version $package_version actual version $actual_version" if ($package_version -eq $actual_version) { Write "Chef-cli working fine" From 2befa02c7e7016b2e7daf2892816a2939309d0f1 Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Thu, 5 Dec 2024 12:40:46 +0530 Subject: [PATCH 31/32] Hab pipeline using buildkite Signed-off-by: nitin sanghi --- .../buildkite/artifact.habitat.test.ps1 | 86 +++++++++++++ .expeditor/buildkite/artifact.habitat.test.sh | 71 +++++++++++ .expeditor/config.yml | 35 +++++- .expeditor/habitat-test.pipeline.yml | 35 ++++++ .github/workflows/habitat-build.yml | 117 ------------------ .github/workflows/habitat-publish.yml | 112 ----------------- habitat/tests/test.sh | 2 +- 7 files changed, 227 insertions(+), 231 deletions(-) create mode 100755 .expeditor/buildkite/artifact.habitat.test.ps1 create mode 100755 .expeditor/buildkite/artifact.habitat.test.sh create mode 100644 .expeditor/habitat-test.pipeline.yml delete mode 100644 .github/workflows/habitat-build.yml delete mode 100644 .github/workflows/habitat-publish.yml diff --git a/.expeditor/buildkite/artifact.habitat.test.ps1 b/.expeditor/buildkite/artifact.habitat.test.ps1 new file mode 100755 index 00000000..adeb59f6 --- /dev/null +++ b/.expeditor/buildkite/artifact.habitat.test.ps1 @@ -0,0 +1,86 @@ +#!/usr/bin/env powershell + +#Requires -Version 5 +# https://stackoverflow.com/questions/9948517 +# TODO: Set-StrictMode -Version Latest +$PSDefaultParameterValues['*:ErrorAction']='Stop' +$ErrorActionPreference = 'Stop' +$env:HAB_BLDR_CHANNEL = "LTS-2024" +$env:HAB_ORIGIN = 'ci' +$env:CHEF_LICENSE = 'accept-no-persist' +$env:HAB_LICENSE = 'accept-no-persist' +$Plan = 'chef-cli' + +Write-Host "--- system details" +$Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture' +Get-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table -AutoSize + +Write-Host "--- Installing the version of Habitat required" + +function Stop-HabProcess { + $habProcess = Get-Process hab -ErrorAction SilentlyContinue + if ($habProcess) { + Write-Host "Stopping hab process..." + Stop-Process -Name hab -Force + } +} + +# Installing Habitat +function Install-Habitat { + Write-Host "Downloading and installing Habitat..." + Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.ps1')) +} + +try { + hab --version +} +catch { + Set-ExecutionPolicy Bypass -Scope Process -Force + + Stop-HabProcess + + # Remove the existing hab.exe if it exists and if you have permissions + $habPath = "C:\ProgramData\Habitat\hab.exe" + if (Test-Path $habPath) { + Write-Host "Attempting to remove existing hab.exe..." + Remove-Item $habPath -Force -ErrorAction SilentlyContinue + if (Test-Path $habPath) { + Write-Host "Failed to remove hab.exe, re-running script with elevated permissions." + Start-Process powershell -Verb runAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" + exit + } + } + + Install-Habitat +} +finally { + Write-Host ":habicat: I think I have the version I need to build." +} + + +Write-Host "--- Generating fake origin key" +hab origin key generate $env:HAB_ORIGIN + +Write-Host "--- Building $Plan" +$project_root = "$(git rev-parse --show-toplevel)" +Set-Location $project_root + +$env:DO_CHECK=$true; hab pkg build . + +. $project_root/results/last_build.ps1 + +Write-Host "--- Installing $pkg_ident/$pkg_artifact" +hab pkg install -b $project_root/results/$pkg_artifact + +Write-Host "+++ Testing $Plan" + +Push-Location $project_root + +try { + Write-Host "Running unit tests..." + /habitat/tests/test.ps1 $pkg_ident +} +finally { + # Ensure we always return to the original directory + Pop-Location +} \ No newline at end of file diff --git a/.expeditor/buildkite/artifact.habitat.test.sh b/.expeditor/buildkite/artifact.habitat.test.sh new file mode 100755 index 00000000..6ded1be3 --- /dev/null +++ b/.expeditor/buildkite/artifact.habitat.test.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +set -eo pipefail + +export HAB_ORIGIN='ci' +export PLAN='chef-cli' +export CHEF_LICENSE="accept-no-persist" +export HAB_LICENSE="accept-no-persist" +export HAB_BLDR_CHANNEL="LTS-2024" + +echo "--- checking if git is installed" +if ! command -v git &> /dev/null; then + echo "Git is not installed. Installing Git..." + sudo yum install -y git +else + echo "Git is already installed." + git --version +fi + +echo "--- add an exception for this directory since detected dubious ownership in repository at /workdir" +git config --global --add safe.directory /workdir + +echo "--- git status for this workdir" +git status + +echo "--- ruby version" +ruby -v + +export project_root="$(git rev-parse --show-toplevel)" +echo "The value for project_root is: $project_root" + +export HAB_NONINTERACTIVE=true +export HAB_NOCOLORING=true +export HAB_STUDIO_SECRET_HAB_NONINTERACTIVE=true + +echo "--- system details" +uname -a + +echo "--- Installing Habitat" +id -a +curl https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh | bash + +echo "--- :key: Generating fake origin key" +hab origin key generate "$HAB_ORIGIN" + + +echo "--- Building $PLAN" +cd "$project_root" +DO_CHECK=true hab pkg build . + +echo "--- Sourcing 'results/last_build.sh'" +if [ -f ./results/last_build.env ]; then + cat ./results/last_build.env + . ./results/last_build.env + export pkg_artifact +fi + +echo "+++ Installing ${pkg_ident:?is undefined}" +echo "++++" +echo $project_root +echo "+++" +hab pkg install -b "${project_root:?is undefined}/results/${pkg_artifact:?is undefined}" + +echo "+++ Testing $PLAN" + +PATH="$(hab pkg path ci/chef-cli)/bin:$PATH" +export PATH +echo "PATH is $PATH" + +echo "--- :mag_right: Testing $PLAN" +${project_root}/habitat/tests/test.sh "$pkg_ident" || error 'failures during test of executables' \ No newline at end of file diff --git a/.expeditor/config.yml b/.expeditor/config.yml index b51f2c1b..29da699e 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -9,6 +9,9 @@ slack: rubygems: - chef-cli +release_branches: + - workstation-LTS: + version_constraint: 5.* github: # This deletes the GitHub PR branch after successfully merged into the release branch delete_branch_on_merge: true @@ -28,6 +31,19 @@ pipelines: - verify: description: Pull Request validation tests public: true + - habitat/build: + env: + - HAB_NONINTERACTIVE: "true" + - HAB_NOCOLORING: "true" + - HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true" + - habitat/test: + description: Execute tests against the habitat artifact + definition: .expeditor/habitat-test.pipeline.yml + env: + - HAB_NONINTERACTIVE: "true" + - HAB_NOCOLORING: "true" + - HAB_STUDIO_SECRET_HAB_NONINTERACTIVE: "true" + trigger: pull_request subscriptions: # These actions are taken, in order they are specified, anytime a Pull Request is merged. @@ -45,7 +61,24 @@ subscriptions: - "Expeditor: Skip All" - built_in:build_gem: only_if: built_in:bump_version + - trigger_pipeline:habitat/test: + only_if: built_in:bump_version + ignore_labels: + - "Expeditor: Skip Habitat" + - "Expeditor: Skip All" + - trigger_pipeline:habitat/build: + only_if: built_in:bump_version + ignore_labels: + - "Expeditor: Skip Habitat" + - "Expeditor: Skip All" + - workload: project_promoted:{{agent_id}}:* actions: - built_in:rollover_changelog - - built_in:publish_rubygems \ No newline at end of file + - built_in:publish_rubygems + # the habitat chain + - workload: buildkite_hab_build_group_published:{{agent_id}}:* + actions: + # when all of the hab package publish to the unstable channel, test and promote them + - trigger_pipeline:habitat/test + \ No newline at end of file diff --git a/.expeditor/habitat-test.pipeline.yml b/.expeditor/habitat-test.pipeline.yml new file mode 100644 index 00000000..98d8b936 --- /dev/null +++ b/.expeditor/habitat-test.pipeline.yml @@ -0,0 +1,35 @@ +--- +expeditor: + defaults: + buildkite: + timeout_in_minutes: 30 + retry: + automatic: + limit: 1 + +steps: + + - label: ":linux: Validate Habitat Builds of Chef-cli" + commands: + - habitat/tests/test.sh + expeditor: + executor: + docker: + image: ruby:3.1 + privileged: true + + - label: ":windows: Validate Habitat Builds of Test Kitchen" + commands: + - .expeditor/buildkite/artifact.habitat.test.ps1 + expeditor: + executor: + docker: + host_os: windows + shell: ["powershell", "-Command"] + image: rubydistros/windows-2019:3.1 + user: 'NT AUTHORITY\SYSTEM' + environment: + - FORCE_FFI_YAJL=ext + - EXPIRE_CACHE=true + - CHEF_LICENSE=accept-no-persist + - CHEF_LICENSE_SERVER=http://hosted-license-service-lb-8000-606952349.us-west-2.elb.amazonaws.com:8000/ diff --git a/.github/workflows/habitat-build.yml b/.github/workflows/habitat-build.yml deleted file mode 100644 index 3dfc1441..00000000 --- a/.github/workflows/habitat-build.yml +++ /dev/null @@ -1,117 +0,0 @@ -name: Build Habitat packages - -on: - push: - branches: - - workstation-LTS - pull_request: - branches: - - workstation-LTS - -env: - # BLDR URL Defined as: 'https://bldr.habitat.sh/' but as an env var in workspace settings. - BLDR_URL: ${{vars.BLDR_URL}} - # HAB_ORIGIN Defined as: 'chef' defined in workspace settings. - HAB_ORIGIN: ${{vars.HAB_ORIGIN}} - # BLDR_CHANNEL defaulted to unstable, but can be switched to stable, it is defined via the environment setting https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment - BLDR_CHANNEL: ${{ vars.BLDR_CHANNEL }} - # HABITAT_VERSION_SET this is the version of habitat CLI you are using, defaults to latest. - HABITAT_VERSION_SET: ${{vars.HABITAT_VERSION_SET}} - # HAB_AUTH_TOKEN your orgs/projects auth token value - HAB_AUTH_TOKEN: ${{ secrets.HAB_AUTH_TOKEN }} - # HABITAT_TARGET this is the CPU arch for the linux CLI tool, its defaulted to x86_64 - #HABITAT_TARGET: $#{{vars.HABITAT_TARGET}} - HAB_FALLBACK_CHANNEL: ${{vars.HAB_FALLBACK_CHANNEL}} - -permissions: - contents: write - -jobs: - pre-build: - name: Setup before building packages - runs-on: ubuntu-latest - outputs: - app_version: ${{ steps.app_version.outputs.APP_VERSION }} - steps: - - name: Get branch name - id: get_branch_name - run: | - echo "BRANCH_NAME=${GITHUB_REF_NAME//\//-}" >> "$GITHUB_OUTPUT" - - name: Get version from tag - id: app_version - run: | - echo "APP_VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('{0}-{1}', steps.get_branch_name.outputs.BRANCH_NAME, github.sha) }}" >> "$GITHUB_OUTPUT" - agent-matrix: - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest] - # matrix strategy is described at https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs - - runs-on: ${{ matrix.os }} - # free runner types are https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners - # from macos-latest, windows-latest, ubuntu-latest, ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-2019, windows-2016 - # included software packages on runners are at https://github.com/actions/runner-images#available-images - # defaulted to unstable, but can be switched to stable, it is defined via the environment setting https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment - # environment: unstable - steps: - - name: print OS - run: echo "--- ${{ matrix.os }}" - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - - name: install habitat on Linux - if: ${{ matrix.os == 'ubuntu-latest' }} - shell: bash - run: | - echo "--- STARTING HAB INSTALL ON ${{ matrix.os }} UBUNTU with habitat version:${{vars.HABITAT_VERSION_SET}}" - export HABITAT_VERSION="${{vars.HABITAT_VERSION_SET}}" - export HAB_FALLBACK_CHANNEL="${{vars.HAB_FALLBACK_CHANNEL}}" - HABITAT_VERSION="${HABITAT_VERSION:?HABITAT_VERSION must be set}" - HABITAT_TARGET="${HABITAT_TARGET:-x86_64-linux}" - curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo bash -s -- -v "$HABITAT_VERSION" -t "$HABITAT_TARGET" - - name: run Habitat packaging (linux) - if: ${{ matrix.os == 'ubuntu-latest' }} - shell: bash - run: | - hab license accept - hab origin key download $HAB_ORIGIN - hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN - echo "--- running linux hab build" - hab pkg build . - hartfile=$(ls ./results | grep "chef-cli" | tail -n 1) - sudo hab license accept - export CHEF_LICENSE="accept-no-persist" - export HAB_LICENSE="accept-no-persist" - export HAB_NONINTERACTIVE="true" - sudo hab pkg install ./results/$hartfile - . ./results/last_build.env - export pkg_ident - chmod +x habitat/tests/test.sh - habitat/tests/test.sh - - name: Install Habitat on Windows - if: ${{ matrix.os == 'windows-latest' }} - shell: pwsh - run: | - write-output "--- STARTING HAB INSTALL ON ${{ matrix.os }} WINDOWS with habitat version:${{vars.HABITAT_VERSION_SET}}" - $env:HAB_LICENSE = "accept-no-persist" - $env:HAB_NONINTERACTIVE = "true" - $env:HAB_FALLBACK_CHANNEL= "${{vars.HAB_FALLBACK_CHANNEL}}" - Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.ps1) } -Version ${{vars.HABITAT_VERSION_SET}}" - - name: run habitat packaging windows - if: ${{ matrix.os == 'windows-latest' }} - shell: pwsh - run: | - $env:Path += ";C:\ProgramData\Habitat" - hab license accept - hab origin key download ${{ env.HAB_ORIGIN }} - hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} - write-output "--- running windows hab build" - hab pkg build . - $hartfile=(ls ./results -Name | findstr "chef-cli") - hab pkg install ./results/$hartfile - . ./results/last_build.ps1 - habitat/tests/test.ps1 $pkg_ident \ No newline at end of file diff --git a/.github/workflows/habitat-publish.yml b/.github/workflows/habitat-publish.yml deleted file mode 100644 index 956eb132..00000000 --- a/.github/workflows/habitat-publish.yml +++ /dev/null @@ -1,112 +0,0 @@ -name: Publish Habitat packages - -on: - push: - branches: - - workstation-LTS - release: - types: - - created - -env: - # BLDR URL Defined as: 'https://bldr.habitat.sh/' but as an env var in workspace settings. - BLDR_URL: ${{vars.BLDR_URL}} - # HAB_ORIGIN Defined as: 'chef' defined in workspace settings. - HAB_ORIGIN: ${{vars.HAB_ORIGIN}} - # BLDR_CHANNEL defaulted to unstable, but can be switched to stable, it is defined via the environment setting https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment - BLDR_CHANNEL: ${{ vars.BLDR_CHANNEL }} - # HABITAT_VERSION_SET this is the version of habitat CLI you are using, defaults to latest. - HABITAT_VERSION_SET: ${{vars.HABITAT_VERSION_SET}} - # HAB_PACKAGE is the name of the project you are on, IE: node-management-agent - HAB_PACKAGE: ${{vars.HAB_PACKAGE}} - # HAB_AUTH_TOKEN your orgs/projects auth token value - HAB_AUTH_TOKEN: ${{ secrets.HAB_AUTH_TOKEN }} - HAB_FALLBACK_CHANNEL: ${{vars.HAB_FALLBACK_CHANNEL}} - # HABITAT_TARGET this is the CPU arch for the linux CLI tool, its defaulted to x86_64 - #HABITAT_TARGET: $#{{vars.HABITAT_TARGET}} - # org-wide access token on https://github.com/organizations/progress-platform-services/settings/secrets/actions - -permissions: - contents: write - -jobs: - pre-build: - name: Setup before building packages - runs-on: ubuntu-latest - outputs: - app_version: ${{ steps.app_version.outputs.APP_VERSION }} - steps: - - name: Get branch name - id: get_branch_name - run: | - echo "BRANCH_NAME=${GITHUB_REF_NAME//\//-}" >> "$GITHUB_OUTPUT" - - name: Get version from tag - id: app_version - run: | - echo "APP_VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('{0}-{1}', steps.get_branch_name.outputs.BRANCH_NAME, github.sha) }}" >> "$GITHUB_OUTPUT" - agent-matrix: - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest] - # matrix strategy is described at https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs - - runs-on: ${{ matrix.os }} - # free runner types are https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners - # from macos-latest, windows-latest, ubuntu-latest, ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-2019, windows-2016 - # included software packages on runners are at https://github.com/actions/runner-images#available-images - # environment: unstable - steps: - - name: print OS - run: echo "--- ${{ matrix.os }}" - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - - name: install habitat on Linux - if: ${{ matrix.os == 'ubuntu-latest' }} - shell: bash - run: | - echo "--- STARTING HAB INSTALL ON ${{ matrix.os }} UBUNTU with habitat version:${{vars.HABITAT_VERSION_SET}}" - export HABITAT_VERSION="${{vars.HABITAT_VERSION_SET}}" - HABITAT_VERSION="${HABITAT_VERSION:?HABITAT_VERSION must be set}" - HABITAT_TARGET="${HABITAT_TARGET:-x86_64-linux}" - export HAB_FALLBACK_CHANNEL="${{vars.HAB_FALLBACK_CHANNEL}}" - curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo bash -s -- -v "$HABITAT_VERSION" -t "$HABITAT_TARGET" - - name: run Habitat packaging (linux) - if: ${{ matrix.os == 'ubuntu-latest' }} - shell: bash - run: | - hab license accept - hab origin key download $HAB_ORIGIN - hab origin key download --auth $HAB_AUTH_TOKEN --secret $HAB_ORIGIN - echo "--- running linux hab build" - hab pkg build . - echo "--- pushing to ${{ env.BLDR_URL }}/#/${{ env.HAB_ORIGIN }}/${{ env.HAB_PACKAGE }}..." - source results/last_build.env - hab pkg upload --auth $HAB_AUTH_TOKEN results/$pkg_artifact - echo "--- push complete!!" - - name: Install Habitat on Windows - if: ${{ matrix.os == 'windows-latest' }} - shell: pwsh - run: | - write-output "--- STARTING HAB INSTALL ON ${{ matrix.os }} WINDOWS with habitat version:${{vars.HABITAT_VERSION_SET}}" - $env:HAB_LICENSE = "accept-no-persist" - $env:HAB_FALLBACK_CHANNEL= "${{vars.HAB_FALLBACK_CHANNEL}}" - Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.ps1) } -Version ${{vars.HABITAT_VERSION_SET}}" - - name: run habitat packaging windows - if: ${{ matrix.os == 'windows-latest' }} - shell: pwsh - run: | - $env:Path += ";C:\ProgramData\Habitat" - hab license accept - hab origin key download ${{ env.HAB_ORIGIN }} - hab origin key download --auth ${{ secrets.HAB_AUTH_TOKEN }} --secret ${{ env.HAB_ORIGIN }} - write-output "--- running windows hab build" - hab pkg build . - write-output "--- pushing hab to unstable channel" - . results\last_build.ps1 - hab pkg upload results\$pkg_artifact --auth ${{ secrets.HAB_AUTH_TOKEN }} - write-output "--- push complete!!" \ No newline at end of file diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh index 4ce9d81d..72e288a4 100755 --- a/habitat/tests/test.sh +++ b/habitat/tests/test.sh @@ -3,7 +3,7 @@ set -euo pipefail project_root="$(git rev-parse --show-toplevel)" - +pkg_ident="$1" # print error message followed by usage and exit error () { local message="$1" From 12a3bf57904d326456746d3555f00274339ce5aa Mon Sep 17 00:00:00 2001 From: nitin sanghi Date: Thu, 5 Dec 2024 12:42:35 +0530 Subject: [PATCH 32/32] hab build yml file added Signed-off-by: nitin sanghi --- .expeditor/build.habitat.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .expeditor/build.habitat.yml diff --git a/.expeditor/build.habitat.yml b/.expeditor/build.habitat.yml new file mode 100644 index 00000000..72ea2567 --- /dev/null +++ b/.expeditor/build.habitat.yml @@ -0,0 +1,9 @@ +--- +origin: chef + +expeditor: + defaults: + buildkite: + retry: + automatic: + limit: 1