Skip to content

Commit

Permalink
Merge pull request #549 from h0tw1r3/matrix-v3
Browse files Browse the repository at this point in the history
(feature) matrix from metadata v3
  • Loading branch information
gavindidrichsen authored Jun 6, 2024
2 parents c541934 + 654c713 commit cce4641
Show file tree
Hide file tree
Showing 6 changed files with 684 additions and 37 deletions.
33 changes: 20 additions & 13 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-04-18 15:58:23 UTC using RuboCop version 1.48.1.
# on 2024-02-13 06:54:13 UTC using RuboCop version 1.50.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 17
# Offense count: 16
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 116
Max: 105

# Offense count: 8
# Offense count: 10
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 350
Max: 348

# Offense count: 8
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 33

# Offense count: 20
# Offense count: 18
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 79

# Offense count: 3
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 324
Max: 255

# Offense count: 7
# Offense count: 8
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 38
Expand Down Expand Up @@ -66,15 +66,15 @@ RSpec/DescribeClass:
- '**/spec/routing/**/*'
- '**/spec/system/**/*'
- '**/spec/views/**/*'
- 'spec/exe/matrix_from_metadata_v2_spec.rb'
- 'spec/exe/*.rb'
- 'spec/lib/puppet_litmus/rake_tasks_spec.rb'

# Offense count: 31
# Offense count: 22
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 22

# Offense count: 126
# Offense count: 106
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Expand All @@ -96,15 +96,22 @@ RSpec/NoExpectationExample:
Exclude:
- 'spec/lib/puppet_litmus/rake_helper_spec.rb'

# Offense count: 113
# Offense count: 93
RSpec/StubbedMock:
Exclude:
- 'spec/lib/puppet_litmus/puppet_helpers_spec.rb'
- 'spec/lib/puppet_litmus/rake_helper_spec.rb'
- 'spec/lib/puppet_litmus/rake_tasks_spec.rb'

# Offense count: 6
# Offense count: 7
Style/OpenStructUse:
Exclude:
- 'exe/matrix_from_metadata_v3'
- 'lib/puppet_litmus/puppet_helpers.rb'
- 'spec/spec_helper.rb'

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
Style/StderrPuts:
Exclude:
- 'exe/matrix_from_metadata_v3'
64 changes: 40 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,49 @@ Install Litmus as a gem by running `gem install puppet_litmus`.

- Note if you choose to override the `litmus_inventory.yaml` location, please ensure that the directory structure you define exists.

## matrix_from_metadata_v2
## matrix_from_metadata_v3

matrix_from_metadata_v2 tool generates a github action matrix from the supported operating systems listed in the module's metadata.json.
matrix_from_metadata_v3 tool generates a github action matrix from the supported operating systems listed in the module's metadata.json.

How to use it:
in the project module root directory run `bundle exec matrix_from_metadata_v2`

### --exclude-platforms parameter

matrix_from_metadata_v2 accepts the `--exclude-platforms <JSON array>` argument in order to exclude some platforms from the matrix.

For example:

`$: bundle exec matrix_from_metadata_v2 --exclude-platforms '["debian-11","centos-8"]'`

> Note: The option value should be JSON string otherwise it will throw an error.
> The values provided in the json array are case-insensitive `["debian-11","centos-8"]'` or `["Debian-11","CentOS-8"]'` are treated as being the same.
### --custom-matrix parameter

matrix_from_metadata_v2 accepts the `--custom-matrix /path/to/matrix.json` argument in order to execute your test suite against a custom matrix. This is useful for use cases that do not fit the default matrix generated.

In order to use this new functionality, run:

`$: bundle exec matrix_from_metadata_v2 --custom-matrix matrix.json`

> Note: The file should contain a valid Array of JSON Objects (i.e. see [here](https://github.com/puppetlabs/puppet_litmus/blob/main/docs/custom_matrix.json)), otherwise it will throw an error.
in the project module root directory run `bundle exec matrix_from_metadata_v3`

### Optional arguments

| argument | value | default | description |
|---------------------|-------|-------------------|-------------|
| --matrix | FILE | built-in | File containing possible collections and provisioners |
| --metadata | FILE | metadata.json | File containing module metadata json |
| --debug | | | Enable debug messages |
| --quiet | | | Disable notice messages |
| --output | TYPE | auto | Type of output to generate; auto, github or stdout |
| --runner | NAME | ubuntu-latest | Default Github action runner |
| --puppet-include | MAJOR | | Select puppet major version |
| --puppet-exclude | MAJOR | | Filter puppet major version |
| --platform-include | REGEX | | Select platform |
| --platform-exclude | REGEX | | Filter platform |
| --arch-include | REGEX | | Select architecture |
| --arch-exclude | REGEX | | Filter architecture |
| --provision-prefer | NAME | docker | Prefer provisioner |
| --provision-include | NAME | all | Select provisioner |
| --provision-exclude | NAME | provision_service | Filter provisioner |

> Refer to the [built-in matrix.json](https://github.com/puppetlabs/puppet_litmus/blob/main/exe/matrix.json) for a list of supported collection, provisioners, and platforms.
### Examples

* Only specific platforms
```sh
matrix_from_metadata_v3 --platform-include redhat --platform-include 'ubuntu-(20|22).04'
```
* Exclude platforms
```sh
matrix_from_metadata_v3 --platform-exclude redhat-7 --platform-exclude ubuntu-18.04
```
* Exclude architecture
```sh
matrix_from_metadata_v3 --arch-exclude x86_64
```

## Documentation

Expand Down
90 changes: 90 additions & 0 deletions exe/matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"collections": [
{
"puppet": 7.24,
"ruby": 2.7
},
{
"puppet": 8.0,
"ruby": 3.2
}
],
"provisioners": {
"provision_service": {
"AlmaLinux": {
"8": { "x86_64": "almalinux-cloud/almalinux-8" }
},
"CentOS": {
"7": { "x86_64": "centos-7" },
"8": { "x86_64": "centos-stream-8" }
},
"Rocky": {
"8": { "x86_64": "rocky-linux-cloud/rocky-linux-8" }
},
"Debian": {
"10": { "x86_64": "debian-10" },
"11": { "x86_64": "debian-11" }
},
"RedHat": {
"7": { "x86_64": "rhel-7" },
"8": { "x86_64": "rhel-8" },
"9": { "x86_64": "rhel-9", "arm": "rhel-9-arm64" }
},
"SLES" : {
"12": { "x86_64": "sles-12" },
"15": { "x86_64": "sles-15" }
},
"Ubuntu": {
"20.04": { "x86_64": "ubuntu-2004-lts" },
"22.04": { "x86_64": "ubuntu-2204-lts", "arm": "ubuntu-2204-lts-arm64" }
},
"Windows": {
"2016": { "x86_64": "windows-2016" },
"2019": { "x86_64": "windows-2019" },
"2022": { "x86_64": "windows-2022" }
}
},
"docker": {
"AmazonLinux": {
"2": { "x86_64": "litmusimage/amazonlinux:2" },
"2023": { "x86_64": "litmusimage/amazonlinux:2023" }
},
"CentOS": {
"7": { "x86_64": "litmusimage/centos:7" },
"8": { "x86_64": "litmusimage/centos:stream8" },
"9": { "x86_64": "litmusimage/centos:stream9" }
},
"Rocky": {
"8": { "x86_64": "litmusimage/rockylinux:8" },
"9": { "x86_64": "litmusimage/rockylinux:9" }
},
"AlmaLinux": {
"8": { "x86_64": "litmusimage/almalinux:8" },
"9": { "x86_64": "litmusimage/almalinux:9" }
},
"Debian": {
"10": { "x86_64": "litmusimage/debian:10" },
"11": { "x86_64": "litmusimage/debian:11" },
"12": { "x86_64": "litmusimage/debian:12" }
},
"OracleLinux": {
"7": { "x86_64": "litmusimage/oraclelinux:7" },
"8": { "x86_64": "litmusimage/oraclelinux:8" },
"8": { "x86_64": "litmusimage/oraclelinux:9" }
},
"Scientific": {
"7": { "x86_64": "litmusimage/scientificlinux:7" }
},
"Ubuntu": {
"18.04": { "x86_64": "litmusimage/ubuntu:18.04" },
"20.04": { "x86_64": "litmusimage/ubuntu:20.04" },
"22.04": { "x86_64": "litmusimage/ubuntu:22.04" }
}
}
},
"github_runner": {
"docker": {
"^(AmazonLinux-2|(CentOS|OracleLinux|Scientific)-7|Ubuntu-18|Debian-10)": "ubuntu-20.04"
}
}
}
Loading

0 comments on commit cce4641

Please sign in to comment.