diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 751d7c2..282eaee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,6 @@ jobs: strategy: matrix: os_version: - - windows-2019 - windows-2022 - windows-2025 salt_state: @@ -26,3 +25,40 @@ jobs: salt-os-version: ${{ matrix.os_version }} salt-state: ${{ matrix.salt_state }} salt-pillar-root: ${{ matrix.salt_pillar_root }} + + verify-shortcut-integration: + name: "Execute Salt Kitchen Integration Verification" + runs-on: "windows-2022" + steps: + - name: "Check Out Source Repository" + uses: "actions/checkout@v4" + + - name: "Set Up Ruby Execution Environment" + uses: "ruby/setup-ruby@v1" + with: + ruby-version: "3.2" + + - name: "Regenerate Dependency Lockfile with Full Index" + run: | + Remove-Item Gemfile.lock -Force -ErrorAction SilentlyContinue + bundle install --full-index + shell: "powershell" + + - name: "Install Salt Minion Natively" + run: | + choco install saltminion -y + echo "C:\Program Files\Salt Project\Salt" >> $env:GITHUB_PATH + shell: "powershell" + + - name: "Execute Converge and Verify Integration Tests" + run: | + bundle exec kitchen converge default + bundle exec kitchen verify default + shell: "powershell" + + - if: "always()" + name: "Upload Test Kitchen Execution Logs" + uses: "actions/upload-artifact@v4" + with: + name: "kitchen-logs" + path: ".kitchen/logs/" diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..f084722 --- /dev/null +++ b/Gemfile @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +# This is a placeholder version to remind us to update the Gemfile +# when a new stable Chef Workstation is released +# renovate: chef-workstation 25.14.2 + +source ENV.fetch('PROXY_RUBYGEMSORG', 'https://rubygems.org') + +# Install the `inspec` gem using `git` because versions after `4.22.22` +# suppress diff output; this version fixes this for our uses. +# rubocop:disable Layout/LineLength +gem 'inspec', git: 'https://gitlab.com/saltstack-formulas/infrastructure/inspec', branch: 'ssf' +# rubocop:enable Layout/LineLength + +# Install the `kitchen-docker` gem using `git` in order to avoid an upstream +# error caused by `kitchen-docker.gemspec`. +# TODO: correct the error upstream +# rubocop:disable Layout/LineLength +gem 'kitchen-docker', git: 'https://github.com/dafyddj/kitchen-docker', branch: 'chore/gemspec' +# rubocop:enable Layout/LineLength + +gem 'kitchen-inspec', '3.1.0' +gem 'kitchen-salt', '0.7.2' + +gem 'net-ssh', '7.3.2' + +gem 'test-kitchen', '4.0.0' diff --git a/git-bash/_mapdata/init.sls b/git-bash/_mapdata/init.sls index 3529a8d..927f7e8 100644 --- a/git-bash/_mapdata/init.sls +++ b/git-bash/_mapdata/init.sls @@ -10,13 +10,16 @@ } %} {%- do salt["log.debug"]("### MAP.JINJA DUMP ###\n" ~ _mapdata | yaml(False)) %} -{%- set output_dir = "/temp" if grains.os_family == "Windows" else "/tmp" %} -{%- set output_file = output_dir ~ "/salt_mapdata_dump.yaml" %} +{%- set output_dir = "C:\\temp" if grains.os_family == "Windows" else "/tmp" %} +{%- set output_file = output_dir ~ "\\salt_mapdata_dump.yaml" + if grains.os_family == "Windows" + else output_dir ~ "/salt_mapdata_dump.yaml" %} -{{ tplroot }}-mapdata-dump: +Dump Formula Map Data To File: file.managed: + - context: + map: {{ _mapdata | yaml }} + - makedirs: true - name: {{ output_file }} - source: salt://{{ tplroot }}/_mapdata/_mapdata.jinja - template: jinja - - context: - map: {{ _mapdata | yaml }} diff --git a/kitchen.yml b/kitchen.yml new file mode 100644 index 0000000..33704ba --- /dev/null +++ b/kitchen.yml @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +driver: + name: "exec" + +provisioner: + formula: "git-bash" + log_level: "debug" + name: "salt_solo" + pillars_from_directories: + - "tests/pillar/git-bash" + require_chef: false + root_path: "C:\\salt_kitchen" + salt_copy_filter: + - ".kitchen" + - ".git" + salt_install: "none" + +transport: + max_wait_until_ready: 60 + +verifier: + name: "inspec" + reporter: + - "cli" + root_path: "C:\\salt_kitchen" + sudo: true + +platforms: + - name: "windows-2022" + +suites: + - name: "default" + provisioner: + state_top: + base: + "*": + - "git-bash._mapdata" + - "git-bash"