From 9fc10c46a51dea4259ae7574fe838e028074a7fc Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Mon, 20 Jan 2025 16:43:08 +0000 Subject: [PATCH] Move install script here Signed-off-by: Dan Webb --- .github/actions/chef-install/action.yml | 46 ++++++ .../action.yml} | 32 ++-- .../action.yml} | 0 .github/workflows/ci.yml | 148 +++++++++--------- 4 files changed, 144 insertions(+), 82 deletions(-) create mode 100644 .github/actions/chef-install/action.yml rename .github/actions/{test-kitchen.yml => test-kitchen/action.yml} (55%) rename .github/actions/{virtualbox-setup.yml => virtualbox-setup/action.yml} (100%) diff --git a/.github/actions/chef-install/action.yml b/.github/actions/chef-install/action.yml new file mode 100644 index 000000000..68a64ff62 --- /dev/null +++ b/.github/actions/chef-install/action.yml @@ -0,0 +1,46 @@ +name: 'Install Chef' +description: 'Installs Chef products on Windows or Linux/macOS' + +inputs: + channel: + description: 'Chef download channel' + required: false + default: 'stable' + project: + description: 'Chef project to download' + required: false + default: 'chef-workstation' + version: + description: 'Version of Chef product' + required: false + license-id: + description: 'Chef license ID' + required: true + windows-path: + description: 'Windows installation path' + required: false + default: 'C:\opscode' + +runs: + using: "composite" + steps: + - name: Install Chef on Linux/macOS + if: runner.os != 'Windows' + shell: bash + run: | + curl -L https://chefdownload-commercial.chef.io/install.sh?license_id=${{ inputs.license-id }} -o chefDownload.sh + sudo chmod +x chefDownload.sh + sudo ./chefDownload.sh -c ${{ inputs.channel }} -P ${{ inputs.project }} ${{ inputs.version && format('-v {0}', inputs.version) }} + rm -f chefDownload.sh + + - name: Install Chef on Windows + if: runner.os == 'Windows' + shell: pwsh + run: | + . { iwr -useb https://chefdownload-commercial.chef.io/install.ps1?license_id=${{ inputs.license-id }} } | iex; + install -channel ${{ inputs.channel }} -project ${{ inputs.project }} ${{ inputs.version && format('-version {0}', inputs.version) }} + + - name: Add Windows Chef Path + if: runner.os == 'Windows' + shell: pwsh + run: echo "${{ inputs.windows-path }}\bin" >> $env:GITHUB_PATH diff --git a/.github/actions/test-kitchen.yml b/.github/actions/test-kitchen/action.yml similarity index 55% rename from .github/actions/test-kitchen.yml rename to .github/actions/test-kitchen/action.yml index c4e285b25..ac7919886 100644 --- a/.github/actions/test-kitchen.yml +++ b/.github/actions/test-kitchen/action.yml @@ -15,29 +15,43 @@ inputs: chef-version: description: 'Chef version to use' required: false - default: 'latest' - chef-license: - description: 'Chef license acceptance' - required: false - default: 'accept-no-persist' + default: 'current' + license-id: + description: 'Chef license ID' + required: true kitchen-command: description: 'Kitchen command to run (test, verify, etc)' required: false default: 'test' + channel: + description: 'Chef download channel' + required: false + default: 'stable' + project: + description: 'Chef project to download' + required: false + default: 'chef-workstation' + version: + description: 'Version of Chef product' + required: false + windows-path: + description: 'Windows installation path' + required: false + default: 'C:\opscode' runs: using: "composite" steps: - name: Install Chef - uses: actionshub/chef-install@3.0.1 + uses: ./.github/actions/chef-install with: version: ${{ inputs.chef-version }} + license-id: ${{ inputs.license-id }} - name: Run Test Kitchen shell: bash - run: - kitchen ${{ inputs.kitchen-command }} ${{ inputs.suite }}-${{ inputs.os }} + run: kitchen ${{ inputs.kitchen-command }} ${{ inputs.suite }}-${{ inputs.os }} env: - CHEF_LICENSE: ${{ inputs.chef-license }} + CHEF_LICENSE: ${{ inputs.license-id }} KITCHEN_LOCAL_YAML: ${{ inputs.kitchen-yaml }} KITCHEN_YAML: ${{ inputs.kitchen-yaml }} diff --git a/.github/actions/virtualbox-setup.yml b/.github/actions/virtualbox-setup/action.yml similarity index 100% rename from .github/actions/virtualbox-setup.yml rename to .github/actions/virtualbox-setup/action.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b697dfe2e..c01fa5168 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,53 +17,52 @@ jobs: statuses: write issues: write - integration: - needs: lint-unit - runs-on: ubuntu-22.04 - strategy: - matrix: - os: - - almalinux-9 - - almalinux-10 - - amazonlinux-2023 - - centos-stream-9 - - centos-stream-10 - - debian-11 - - debian-12 - - fedora-latest - - opensuse-leap-15 - - oraclelinux-8 - - oraclelinux-9 - - ubuntu-2204 - - ubuntu-2404 - suite: - - "installation-script-main" - - "installation-script-test" - - "installation-package" - - "installation-tarball" - - "install-and-stop" - fail-fast: false - steps: - - name: Check out code - uses: actions/checkout@v4 - - name: Test Kitchen - uses: ./.github/actions/test-kitchen - with: - suite: ${{ matrix.suite }} - os: ${{ matrix.os }} - kitchen-yaml: kitchen.dokken.yml - chef-version: latest - chef-license: accept-no-persist + # integration: + # needs: lint-unit + # runs-on: ubuntu-22.04 + # strategy: + # matrix: + # os: + # - almalinux-9 + # - almalinux-10 + # - amazonlinux-2023 + # - centos-stream-9 + # - centos-stream-10 + # - debian-11 + # - debian-12 + # - fedora-latest + # - opensuse-leap-15 + # - oraclelinux-8 + # - oraclelinux-9 + # - ubuntu-2204 + # - ubuntu-2404 + # suite: + # - "installation-script-main" + # - "installation-script-test" + # - "installation-package" + # - "installation-tarball" + # - "install-and-stop" + # fail-fast: false + # steps: + # - name: Check out code + # uses: actions/checkout@v4 + # - name: Test Kitchen + # uses: ./.github/actions/test-kitchen + # with: + # suite: ${{ matrix.suite }} + # os: ${{ matrix.os }} + # kitchen-yaml: kitchen.dokken.yml + # chef-version: latest + # license-id: ${{ secrets.CHEF_LICENSE_KEY }} integration-swarm: - needs: lint-unit + # needs: lint-unit runs-on: ubuntu-22.04 strategy: matrix: os: ["ubuntu-2204"] suite: ["swarm"] fail-fast: false - steps: - name: Check out code uses: actions/checkout@v4 @@ -76,38 +75,41 @@ jobs: os: ${{ matrix.os }} kitchen-yaml: kitchen.yml chef-version: latest - chef-license: accept-no-persist + license-id: ${{ secrets.CHEF_LICENSE_KEY }} - integration-smoke: - needs: lint-unit - runs-on: ubuntu-latest - strategy: - matrix: - os: - - "almalinux-8" - - "almalinux-9" - - "debian-11" - - "debian-12" - - "rockylinux-8" - - "rockylinux-9" - - "ubuntu-2004" - - "ubuntu-2204" - - "ubuntu-2404" - suite: - - "smoke" - fail-fast: false - steps: - - name: Check out code - uses: actions/checkout@v4 - - name: Setup VirtualBox & Vagrant - uses: ./.github/workflows/virtualbox-setup.yml - - name: Install Chef - uses: actionshub/chef-install@3.0.1 - - name: Test Kitchen - uses: ./.github/actions/test-kitchen - with: - suite: ${{ matrix.suite }} - os: ${{ matrix.os }} - kitchen-yaml: kitchen.yml - chef-version: latest - chef-license: accept-no-persist + # integration-smoke: + # needs: lint-unit + # runs-on: ubuntu-latest + # strategy: + # matrix: + # os: + # - "almalinux-8" + # - "almalinux-9" + # - "debian-11" + # - "debian-12" + # - "rockylinux-8" + # - "rockylinux-9" + # - "ubuntu-2004" + # - "ubuntu-2204" + # - "ubuntu-2404" + # suite: + # - "smoke" + # fail-fast: false + # steps: + # - name: Check out code + # uses: actions/checkout@v4 + # - name: Setup VirtualBox & Vagrant + # uses: ./.github/actions/virtualbox-setup + # - name: Install Chef + # uses: actionshub/chef-install@3.0.1 + # with: + # version: latest + # license-id: ${{ env.CHEF_LICENSE_KEY }} + # - name: Test Kitchen + # uses: ./.github/actions/test-kitchen + # with: + # suite: ${{ matrix.suite }} + # os: ${{ matrix.os }} + # kitchen-yaml: kitchen.yml + # chef-version: latest + # license-id: ${{ env.CHEF_LICENSE_KEY }}