Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(exec): add macOS testing via. GitHub Actions #443

Merged
merged 2 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ ignore: |
ssf/files/default/.yamllint
ssf/files/default/inspec/inspec.yml
ssf/files/default/kitchen.yml
ssf/files/default/kitchen.macos.yml
ssf/files/default/kitchen.windows.yml
ssf/files/default/.github/workflows/kitchen.yml
ssf/files/default/.github/workflows/kitchen.macos.yml
ssf/files/default/.github/workflows/kitchen.windows.yml
ssf/files/tofs_ssf-formula/.yamllint

Expand Down
5 changes: 5 additions & 0 deletions ssf/config/formulas.sls
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{%- set inspec_suites_kitchen = context.inspec_suites_kitchen %}
{%- set kitchen = context.kitchen %}
{%- set testing_freebsd = context.testing_freebsd %}
{%- set testing_macos = context.testing_macos %}
{%- set testing_openbsd = context.testing_openbsd %}
{%- set testing_windows = context.testing_windows %}
{%- set use_cirrus_ci = context.use_cirrus_ci %}
Expand Down Expand Up @@ -140,6 +141,7 @@ prepare-git-branch-for-{{ formula }}:
{#- Likewise, if running the state for TOFS files when `use_tofs` is `False` #}
{#- Also remove the local `CONTRIBUTING` file to use the org-level file instead #}
{#- Furthermore, remove `.travis.yml` for the `ssf-formula` #}
{#- Also: remove both `kitchen.macos.yml` files if relevant testing not active #}
{#- Also: remove both `kitchen.vagrant.yml` files if relevant testing not active #}
{#- Also: remove both `kitchen.windows.yml` files if relevant testing not active #}
{#- Also: remove both Jinja libaries used for the new `map.jinja` if a v5+ `map.jinja` isn't involved #}
Expand All @@ -150,6 +152,7 @@ prepare-git-branch-for-{{ formula }}:
(semrel_file in ['docs/TOFS_pattern.rst', 'formula/libtofs.jinja'] and not use_tofs) or
(semrel_file in ['docs/CONTRIBUTING.rst'] and formula not in ['.github', 'ssf-formula']) or
(semrel_file in ['.travis.yml'] and formula in ['ssf-formula']) or
(semrel_file.endswith('kitchen.macos.yml') and not testing_macos.active) or
(semrel_file.endswith('kitchen.vagrant.yml') and not testing_freebsd.active and not testing_openbsd.active and not testing_windows.active) or
(semrel_file.endswith('kitchen.windows.yml') and not testing_windows.active) or
(semrel_file in ['formula/libmapstack.jinja', 'formula/libmatchers.jinja'] and map_jinja.version < 5) or
Expand Down Expand Up @@ -202,6 +205,7 @@ remove-previous-file-location-for-{{ formula }}-{{ dest_file }}:
owner: {{ owner }}
formula: {{ formula }}
codeowners: {{ context.codeowners | yaml }}
execplatformsmacos: {{ ssf.execplatformsmacos | yaml }}
gitlab: {{ context.git.gitlab | yaml }}
inspec_suites_kitchen: {{ inspec_suites_kitchen | yaml }}
inspec_suites_matrix: {{ context.inspec_suites_matrix | yaml }}
Expand All @@ -219,6 +223,7 @@ remove-previous-file-location-for-{{ formula }}-{{ dest_file }}:
shellcheck: {{ context.shellcheck | yaml }}
suite: {{ suite | yaml }}
testing_freebsd: {{ testing_freebsd | yaml }}
testing_macos: {{ testing_macos | yaml }}
testing_openbsd: {{ testing_openbsd | yaml }}
testing_windows: {{ testing_windows | yaml }}
travis: {{ context.travis | yaml }}
Expand Down
21 changes: 19 additions & 2 deletions ssf/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ ssf_node_anchors:
upstream: 'upstream'
commit:
# yamllint disable rule:line-length rule:quoted-strings
title: "test(system.rb): add support for '`'mac_os_x'`' [skip ci]"
body: '* Automated using https://github.com/myii/ssf-formula/pull/442'
title: "ci(macos): enable testing using GitHub Actions"
body: '* Automated using https://github.com/myii/ssf-formula/pull/443'
# yamllint enable rule:line-length rule:quoted-strings
github:
owner: 'saltstack-formulas'
Expand Down Expand Up @@ -119,6 +119,7 @@ ssf_node_anchors:
- gentoo
- almalinux
- rocky
- mac_os_x
- windows
provisioner:
dependencies: []
Expand Down Expand Up @@ -215,6 +216,17 @@ ssf_node_anchors:
exclude_paths: []
testing_freebsd:
active: false
testing_macos:
active: false
github:
driver:
name: 'exec'
platforms:
provisioner:
sudo: 'true' # So that this comes through as `true` vs. `True`
salt_install: 'bootstrap'
salt_bootstrap_options: '-P stable latest'
salt_call_command: '/opt/salt/bin/salt-call'
testing_openbsd:
active: false
vagrant:
Expand Down Expand Up @@ -334,6 +346,11 @@ ssf:
create_PR:
active: false
source: 'salt://ssf/files/default/git/git_30_create_PR.sh'
execplatformsmacos:
### `macos`
- [macos , 12 , latest, 3] # maco-1200-latest-py3
- [macos , 11 , latest, 3] # maco-1100-latest-py3
- [macos , 10.15, latest, 3] # maco-1015-latest-py3
proxyplatformswindows:
### `windows`
- [windows , 2022 , latest, 3] # wind-2022-latest-py3
Expand Down
42 changes: 42 additions & 0 deletions ssf/files/default/.github/workflows/kitchen.macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
{%- from tplroot ~ "/libcimatrix.jinja" import format_ci_matrix with context %}
name: 'Kitchen (macOS)'
'on': ['push', 'pull_request']

env:
KITCHEN_LOCAL_YAML: 'kitchen.macos.yml'

jobs:
{%- for platform in execplatformsmacos %}
{%- set os = platform[0] | d('') %}
{%- set os_ver = platform[1] | d('') %}
{#- set salt_ver = platform[2] | d('') #}
{#- set py_ver = platform[3] | d('') #}
test-{{ os_ver | replace('.', '') }}:
runs-on: '{{ os }}-{{ os_ver }}'
strategy:
fail-fast: false
matrix:
instance:
{{- format_ci_matrix(platforms, inspec_suites_kitchen, inspec_suites_matrix, platforms_matrix, platforms_matrix_allow_failure, platforms_matrix_commented_includes, semrel_formula, width=10, use_github_format=True, use_exec_platforms_macos=platform) }}
{%- raw %}
steps:
- name: 'Check out code'
uses: 'actions/checkout@v2'
- name: 'Set up Bundler cache'
uses: 'actions/cache@v1'
with:
path: 'vendor/bundle'
key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}"
restore-keys: "${{ runner.os }}-gems-"
- name: 'Run Bundler'
run: |
ruby --version
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: 'Run Test Kitchen'
run: 'bundle exec kitchen verify ${{ matrix.instance }}'
{%- endraw %}
{%- endfor %}
6 changes: 3 additions & 3 deletions ssf/files/default/.github/workflows/kitchen.windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ env:

jobs:
{%- for platform in proxyplatformswindows %}
{#- set os = platform[0] | d('') #}
{%- set os = platform[0] | d('') %}
{%- set os_ver = platform[1] | d('') %}
{#- set salt_ver = platform[2] | d('') #}
{#- set py_ver = platform[3] | d('') #}
test-{{ os_ver }}:
runs-on: 'windows-{{ os_ver }}'
test-{{ os_ver | replace('.', '') }}:
runs-on: '{{ os }}-{{ os_ver }}'
strategy:
fail-fast: false
matrix:
Expand Down
32 changes: 32 additions & 0 deletions ssf/files/default/kitchen.macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
driver:
name: {{ testing_macos.github.driver.name }}

provisioner:
sudo: {{ testing_macos.github.platforms.provisioner.sudo }}
salt_install: {{ testing_macos.github.platforms.provisioner.salt_install }}
salt_bootstrap_options: {{ testing_macos.github.platforms.provisioner.salt_bootstrap_options }}
salt_call_command: {{ testing_macos.github.platforms.provisioner.salt_call_command }}

platforms:
{%- for platform in execplatformsmacos %}
{%- set os = platform[0] | d('') %}
{%- set os_ver = platform[1] | d('') %}
{%- set salt_ver = platform[2] | d('') %}
{%- set py_ver = platform[3] | d('') %}
- name: {{ os | replace('/', '-') }}-{{ os_ver | replace('.', '') }}-{{ salt_ver | replace('.', '-') }}-py{{ py_ver }}
{#- Centralise duplication from here and `kitchen*.yml` #}
{%- if kitchen.platforms.verifier.inputs %}
verifier:
inputs:
{%- for input_name, input_val in kitchen.platforms.verifier.inputs.items() %}
{%- if [semrel_formula, input_name] in [['salt', 'saltmajorversion']] %}
{{ input_name }}: {{ input_val.get(salt_ver, salt_ver | int) }}
{%- else %}
{{ input_name }}: {{ input_val }}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endfor %}
2 changes: 1 addition & 1 deletion ssf/files/default/kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{%- if cludes %}
{{ clude_type }}:
{#- Centralise duplication from here and `libcimatrix.jinja` #}
{%- set all_platforms = saltimages + vagrantboxes + proxyplatformswindows %}
{%- set all_platforms = saltimages + vagrantboxes + proxyplatformswindows + execplatformsmacos %}
{%- for platform in all_platforms %}
{%- set os = platform[0] | d('') %}
{%- set os_ver = platform[1] | d('') %}
Expand Down
12 changes: 12 additions & 0 deletions ssf/formulas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ ssf_node_anchors:
<<: *file_default
template: 'jinja'
# yamllint disable-line rule:line-length
.github/workflows/kitchen.macos.yml: &file__--github__workflows__kitchen--macos--yml
<<: *file_default
template: 'jinja'
# yamllint disable-line rule:line-length
.github/workflows/kitchen.vagrant.yml: &file__--github__workflows__kitchen--vagrant--yml
<<: *file_default
template: 'jinja'
Expand Down Expand Up @@ -365,6 +369,9 @@ ssf_node_anchors:
kitchen.yml: &file__kitchen--yml
<<: *file_default
template: 'jinja'
kitchen.macos.yml: &file__kitchen--macos--yml
<<: *file_default
template: 'jinja'
kitchen.vagrant.yml: &file__kitchen--vagrant--yml
<<: *file_default
template: 'jinja'
Expand Down Expand Up @@ -4431,8 +4438,11 @@ ssf:
- [openbsd , 7.0 , 3003.3, 3, default]
- [openbsd , 6.9 , 3002.6, 3, default]
- [windows , 0 , latest, 3, default]
- [macos , 0 , latest, 3, default]
testing_freebsd:
active: true
testing_macos:
active: true
testing_openbsd:
active: true
testing_windows:
Expand Down Expand Up @@ -4616,8 +4626,10 @@ ssf:
- ssf/files/default/.yamllint
- ssf/files/default/inspec/inspec.yml
- ssf/files/default/kitchen.yml
- ssf/files/default/kitchen.macos.yml
- ssf/files/default/kitchen.windows.yml
- ssf/files/default/.github/workflows/kitchen.yml
- ssf/files/default/.github/workflows/kitchen.macos.yml
- ssf/files/default/.github/workflows/kitchen.windows.yml
- ssf/files/tofs_ssf-formula/.yamllint
rules:
Expand Down
12 changes: 9 additions & 3 deletions ssf/libcimatrix.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@
use_gitlab_format=False,
use_github_format=False,
use_vagrant_platforms=False,
use_proxy_platforms_windows=[]
use_proxy_platforms_windows=[],
use_exec_platforms_macos=[]
) %}
{%- filter indent(width) %}
{#- Centralise duplication from here and `kitchen.yml` #}
{%- set platform_and_suite_names_done = [] %}
{%- set commented_platform_done = [] %}
{%- set all_platforms = saltimages + vagrantboxes + proxyplatformswindows %}
{%- set all_platforms = saltimages + vagrantboxes + proxyplatformswindows + execplatformsmacos %}
{%- set driver_platforms = saltimages %}
{%- if use_vagrant_platforms %}
{%- set driver_platforms = vagrantboxes %}
{%- elif use_proxy_platforms_windows %}
{%- set driver_platforms = proxyplatformswindows %}
{%- elif use_exec_platforms_macos %}
{%- set driver_platforms = execplatformsmacos %}
{%- endif %}
{%- for platform in driver_platforms %}
{%- set os = platform[0] %}
Expand All @@ -34,6 +37,7 @@
{%- set py_ver = platform[3] %}
{#- Go to the next platform where not set as active #}
{%- if (os == 'freebsd' and not testing_freebsd.active) or
(os == 'macos' and not testing_macos.active) or
(os == 'openbsd' and not testing_openbsd.active) or
(os == 'windows' and not testing_windows.active) %}
{%- continue %}
Expand All @@ -53,8 +57,10 @@
{%- endfor %}
{#- If a match hasn't been found, go to the next entry under `driver_platforms` #}
{#- Likewise, if working with Windows proxy platforms and doesn't match the platform sent through #}
{#- Likewise, if working with macOS exec platforms and doesn't match the platform sent through #}
{%- if (not ns_check_platform.match) or
(use_proxy_platforms_windows and use_proxy_platforms_windows != platform)
(use_proxy_platforms_windows and use_proxy_platforms_windows != platform) or
(use_exec_platforms_macos and use_exec_platforms_macos != platform)
%}
{%- continue %}
{%- endif %}
Expand Down