Projet

Général

Profil

Révision 78f22811

ID78f22811a4bdb9795e76c47d1b91cf42d43756f0
Parent 8897f7d0
Enfant 11bf7237

Ajouté par Steve Traylen il y a plus de 4 ans

modulesync 4.0.0

Voir les différences:

.editorconfig
1
# editorconfig.org
2

  
3
# MANAGED BY MODULESYNC
4

  
5
root = true
6

  
7
[*]
8
charset = utf-8
9
end_of_line = lf
10
indent_size = 2
11
tab_width = 2
12
indent_style = space
13
insert_final_newline = true
14
trim_trailing_whitespace = true
.github/CONTRIBUTING.md
1
# Contribution guidelines
2

  
3
## Table of contents
4

  
5
* [Contributing](#contributing)
6
* [Writing proper commits - short version](#writing-proper-commits-short-version)
7
* [Writing proper commits - long version](#writing-proper-commits-long-version)
8
* [Dependencies](#dependencies)
9
  * [Note for OS X users](#note-for-os-x-users)
10
* [The test matrix](#the-test-matrix)
11
* [Syntax and style](#syntax-and-style)
12
* [Running the unit tests](#running-the-unit-tests)
13
* [Unit tests in docker](#unit-tests-in-docker)
14
* [Integration tests](#integration-tests)
15

  
16
This module has grown over time based on a range of contributions from
17
people using it. If you follow these contributing guidelines your patch
18
will likely make it into a release a little more quickly.
19

  
20
## Contributing
21

  
22
Please note that this project is released with a Contributor Code of Conduct.
23
By participating in this project you agree to abide by its terms.
24
[Contributor Code of Conduct](https://voxpupuli.org/coc/).
25

  
26
* Fork the repo.
27
* Create a separate branch for your change.
28
* We only take pull requests with passing tests, and documentation. [travis-ci](http://travis-ci.org) runs the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix).
29
* Checkout [our docs](https://voxpupuli.org/docs/reviewing_pr/) we use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). They provide some guidance for new code that might help you before you submit a pull request.
30
* Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, please add a test.
31
* Squash your commits down into logical components. Make sure to rebase against our current master.
32
* Push the branch to your fork and submit a pull request.
33

  
34
Please be prepared to repeat some of these steps as our contributors review your code.
35

  
36
Also consider sending in your profile code that calls this component module as an acceptance test or provide it via an issue. This helps reviewers a lot to test your use case and prevents future regressions!
37

  
38
## Writing proper commits - short version
39

  
40
* Make commits of logical units.
41
* Check for unnecessary whitespace with "git diff --check" before committing.
42
* Commit using Unix line endings (check the settings around "crlf" in git-config(1)).
43
* Do not check in commented out code or unneeded files.
44
* The first line of the commit message should be a short description (50 characters is the soft limit, excluding ticket number(s)), and should skip the full stop.
45
* Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message".
46
* The body should provide a meaningful commit message, which:
47
  *uses the imperative, present tense: `change`, not `changed` or `changes`.
48
  * includes motivation for the change, and contrasts its implementation with the previous behavior.
49
  * Make sure that you have tests for the bug you are fixing, or feature you are adding.
50
  * Make sure the test suites passes after your commit:
51
  * When introducing a new feature, make sure it is properly documented in the README.md
52

  
53
## Writing proper commits - long version
54

  
55
  1.  Make separate commits for logically separate changes.
56

  
57
      Please break your commits down into logically consistent units
58
      which include new or changed tests relevant to the rest of the
59
      change.  The goal of doing this is to make the diff easier to
60
      read for whoever is reviewing your code.  In general, the easier
61
      your diff is to read, the more likely someone will be happy to
62
      review it and get it into the code base.
63

  
64
      If you are going to refactor a piece of code, please do so as a
65
      separate commit from your feature or bug fix changes.
66

  
67
      We also really appreciate changes that include tests to make
68
      sure the bug is not re-introduced, and that the feature is not
69
      accidentally broken.
70

  
71
      Describe the technical detail of the change(s).  If your
72
      description starts to get too long, that is a good sign that you
73
      probably need to split up your commit into more finely grained
74
      pieces.
75

  
76
      Commits which plainly describe the things which help
77
      reviewers check the patch and future developers understand the
78
      code are much more likely to be merged in with a minimum of
79
      bike-shedding or requested changes.  Ideally, the commit message
80
      would include information, and be in a form suitable for
81
      inclusion in the release notes for the version of Puppet that
82
      includes them.
83

  
84
      Please also check that you are not introducing any trailing
85
      whitespace or other "whitespace errors".  You can do this by
86
      running "git diff --check" on your changes before you commit.
87

  
88
  2.  Sending your patches
89

  
90
      To submit your changes via a GitHub pull request, we _highly_
91
      recommend that you have them on a topic branch, instead of
92
      directly on `master`.
93
      It makes things much easier to keep track of, especially if
94
      you decide to work on another thing before your first change
95
      is merged in.
96

  
97
      GitHub has some pretty good
98
      [general documentation](http://help.github.com/) on using
99
      their site.  They also have documentation on
100
      [creating pull requests](http://help.github.com/send-pull-requests/).
101

  
102
      In general, after pushing your topic branch up to your
103
      repository on GitHub, you can switch to the branch in the
104
      GitHub UI and click "Pull Request" towards the top of the page
105
      in order to open a pull request.
106

  
107

  
108
  3.  Update the related GitHub issue.
109

  
110
      If there is a GitHub issue associated with the change you
111
      submitted, then you should update the ticket to include the
112
      location of your branch, along with any other commentary you
113
      may wish to make.
114

  
115
## Dependencies
116

  
117
The testing and development tools have a bunch of dependencies,
118
all managed by [bundler](http://bundler.io/) according to the
119
[Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions).
120

  
121
By default the tests use a baseline version of Puppet.
122

  
123
If you have Ruby 2.x or want a specific version of Puppet,
124
you must set an environment variable such as:
125

  
126
```sh
127
export PUPPET_VERSION="~> 5.5.6"
128
```
129

  
130
You can install all needed gems for spec tests into the modules directory by
131
running:
132

  
133
```sh
134
bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)"
135
```
136

  
137
If you also want to run acceptance tests:
138

  
139
```sh
140
bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"
141
```
142

  
143
Our all in one solution if you don't know if you need to install or update gems:
144

  
145
```sh
146
bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean
147
```
148

  
149
As an alternative to the `--jobs "$(nproc)` parameter, you can set an
150
environment variable:
151

  
152
```sh
153
BUNDLE_JOBS="$(nproc)"
154
```
155

  
156
### Note for OS X users
157

  
158
`nproc` isn't a valid command under OS x. As an alternative, you can do:
159

  
160
```sh
161
--jobs "$(sysctl -n hw.ncpu)"
162
```
163

  
164
## The test matrix
165

  
166
### Syntax and style
167

  
168
The test suite will run [Puppet Lint](http://puppet-lint.com/) and
169
[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to
170
check various syntax and style things. You can run these locally with:
171

  
172
```sh
173
bundle exec rake lint
174
bundle exec rake validate
175
```
176

  
177
It will also run some [Rubocop](http://batsov.com/rubocop/) tests
178
against it. You can run those locally ahead of time with:
179

  
180
```sh
181
bundle exec rake rubocop
182
```
183

  
184
### Running the unit tests
185

  
186
The unit test suite covers most of the code, as mentioned above please
187
add tests if you're adding new functionality. If you've not used
188
[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask
189
about how best to test your new feature.
190

  
191
To run the linter, the syntax checker and the unit tests:
192

  
193
```sh
194
bundle exec rake test
195
```
196

  
197
To run your all the unit tests
198

  
199
```sh
200
bundle exec rake spec
201
```
202

  
203
To run a specific spec test set the `SPEC` variable:
204

  
205
```sh
206
bundle exec rake spec SPEC=spec/foo_spec.rb
207
```
208

  
209
#### Unit tests in docker
210

  
211
Some people don't want to run the dependencies locally or don't want to install
212
ruby. We ship a Dockerfile that enables you to run all unit tests and linting.
213
You only need to run:
214

  
215
```sh
216
docker build .
217
```
218

  
219
Please ensure that a docker daemon is running and that your user has the
220
permission to talk to it. You can specify a remote docker host by setting the
221
`DOCKER_HOST` environment variable. it will copy the content of the module into
222
the docker image. So it will not work if a Gemfile.lock exists.
223

  
224
### Integration tests
225

  
226
The unit tests just check the code runs, not that it does exactly what
227
we want on a real machine. For that we're using
228
[beaker](https://github.com/puppetlabs/beaker).
229

  
230
This fires up a new virtual machine (using vagrant) and runs a series of
231
simple tests against it after applying the module. You can run this
232
with:
233

  
234
```sh
235
bundle exec rake beaker
236
```
237

  
238
This will run the tests on the module's default nodeset. You can override the
239
nodeset used, e.g.,
240

  
241
```sh
242
BEAKER_set=centos-7-x64 bundle exec rake beaker
243
```
244

  
245
There are default rake tasks for the various acceptance test modules, e.g.,
246

  
247
```sh
248
bundle exec rake beaker:centos-7-x64
249
bundle exec rake beaker:ssh:centos-7-x64
250
```
251

  
252
If you don't want to have to recreate the virtual machine every time you can
253
use `BEAKER_destroy=no` and `BEAKER_provision=no`. On the first run you will at
254
least need `BEAKER_provision` set to yes (the default). The Vagrantfile for the
255
created virtual machines will be in `.vagrant/beaker_vagrant_files`.
256

  
257
Beaker also supports docker containers. We also use that in our automated CI
258
pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant:
259

  
260
```sh
261
PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker
262
```
263

  
264
You can replace the string `debian10` with any common operating system.
265
The following strings are known to work:
266

  
267
* ubuntu1604
268
* ubuntu1804
269
* ubuntu2004
270
* debian9
271
* debian10
272
* centos7
273
* centos8
274

  
275
The easiest way to debug in a docker container is to open a shell:
276

  
277
```sh
278
docker exec -it -u root ${container_id_or_name} bash
279
```
280

  
281
The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb)
282
repository.
.github/ISSUE_TEMPLATE.md
1
<!--
2
Thank you for contributing to this project!
3

  
4
- This project has a Contributor Code of Conduct: https://voxpupuli.org/coc/
5
- Please check that here is no existing issue or PR that addresses your problem.
6
- Please fill the following form to enable us to help you.
7
- Our vulnerabilities reporting process is at https://voxpupuli.org/security/
8

  
9
-->
10

  
11
## Affected Puppet, Ruby, OS and module versions/distributions
12

  
13
- Puppet:
14
- Ruby:
15
- Distribution:
16
- Module version:
17

  
18
## How to reproduce (e.g Puppet code you use)
19

  
20
## What are you seeing
21

  
22
## What behaviour did you expect instead
23

  
24
## Output log
25

  
26
## Any additional information you'd like to impart
.github/PULL_REQUEST_TEMPLATE.md
1
<!--
2
Thank you for contributing to this project!
3

  
4
- This project has a Contributor Code of Conduct: https://voxpupuli.org/coc/
5
- Please check that here is no existing issue or PR that addresses your problem.
6
- Our vulnerabilities reporting process is at https://voxpupuli.org/security/
7

  
8
-->
9
#### Pull Request (PR) description
10
<!--
11
Replace this comment with a description of your pull request.
12
-->
13

  
14
#### This Pull Request (PR) fixes the following issues
15
<!--
16
Replace this comment with the list of issues or n/a.
17
Use format:
18
Fixes #123
19
Fixes #124
20
-->
.github/SECURITY.md
1
# Vox Pupuli Security Policy
2

  
3
Our vulnerabilities reporting process is at https://voxpupuli.org/security/
.github/workflows/ci.yml
1
name: CI
2

  
3
on: pull_request
4

  
5
jobs:
6
  setup_matrix:
7
    name: 'Setup Test Matrix'
8
    runs-on: ubuntu-latest
9
    outputs:
10
      beaker_setfiles: ${{ steps.get-outputs.outputs.beaker_setfiles }}
11
      puppet_major_versions: ${{ steps.get-outputs.outputs.puppet_major_versions }}
12
      puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }}
13
    env:
14
      BUNDLE_WITHOUT: development:test:release
15
    steps:
16
      - uses: actions/checkout@v2
17
      - name: Setup ruby
18
        uses: ruby/setup-ruby@v1
19
        with:
20
          ruby-version: '2.7'
21
          bundler-cache: true
22
      - name: Run rake validate
23
        run: bundle exec rake validate
24
      - name: Setup Test Matrix
25
        id: get-outputs
26
        run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false
27

  
28
  unit:
29
    needs: setup_matrix
30
    runs-on: ubuntu-latest
31
    strategy:
32
      fail-fast: false
33
      matrix:
34
        include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}}
35
    env:
36
      BUNDLE_WITHOUT: development:system_tests:release
37
      PUPPET_VERSION: "~> ${{ matrix.puppet }}.0"
38
    name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }})
39
    steps:
40
      - uses: actions/checkout@v2
41
      - name: Setup ruby
42
        uses: ruby/setup-ruby@v1
43
        with:
44
          ruby-version: ${{ matrix.ruby }}
45
          bundler-cache: true
46
      - name: Run tests
47
        run: bundle exec rake
.github/workflows/release.yml
1
name: Release
2

  
3
on:
4
  push:
5
    tags:
6
      - '*'
7

  
8
env:
9
  BUNDLE_WITHOUT: development:test:system_tests
10

  
11
jobs:
12
  deploy:
13
    name: 'deploy to forge'
14
    runs-on: ubuntu-latest
15
    steps:
16
      - name: Checkout repository
17
        uses: actions/checkout@v2
18
      - name: Setup Ruby
19
        uses: ruby/setup-ruby@v1
20
        with:
21
          ruby-version: '2.7'
22
          bundler-cache: true
23
      - name: Build and Deploy
24
        env:
25
          # Configure secrets here:
26
          #  https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets
27
          BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}'
28
          BLACKSMITH_FORGE_API_KEY: '${{ secrets.PUPPET_FORGE_API_KEY }}'
29
        run: bundle exec rake module:push
.gitignore
1
.git/
2
.*.sw[op]
3
.metadata
4
.yardoc
5
.yardwarns
6
*.iml
7
/.bundle/
8
/.idea/
9
/.vagrant/
10
/coverage/
11
/bin/
12
/doc/
13
/Gemfile.local
14
/Gemfile.lock
15
/junit/
16
/log/
17
/pkg/
18
/spec/fixtures/manifests/
19
/spec/fixtures/modules/
20
/tmp/
21
/vendor/
22
/convert_report.txt
23
/update_report.txt
24
.DS_Store
25
.project
26
.envrc
27
/inventory.yaml
1
pkg/
2
Gemfile.lock
3
Gemfile.local
4
vendor/
5
.vendor/
6
spec/fixtures/manifests/
7
spec/fixtures/modules/
8
.vagrant/
9
.bundle/
28 10
.ruby-version
11
coverage/
12
log/
13
.idea/
14
.dependencies/
15
.librarian/
16
Puppetfile.lock
17
*.iml
18
.*.sw?
19
.yardoc/
20
Guardfile
.msync.yml
1
---
2
modulesync_config_version: '4.0.0'
.overcommit.yml
1
# Managed by https://github.com/voxpupuli/modulesync_configs
2
#
3
# Hooks are only enabled if you take action.
4
#
5
# To enable the hooks run:
6
#
7
# ```
8
# bundle exec overcommit --install
9
# # ensure .overcommit.yml does not harm to you and then
10
# bundle exec overcommit --sign
11
# ```
12
#
13
# (it will manage the .git/hooks directory):
14
#
15
# Examples howto skip a test for a commit or push:
16
#
17
# ```
18
# SKIP=RuboCop git commit
19
# SKIP=PuppetLint git commit
20
# SKIP=RakeTask git push
21
# ```
22
#
23
# Don't invoke overcommit at all:
24
#
25
# ```
26
# OVERCOMMIT_DISABLE=1 git commit
27
# ```
28
#
29
# Read more about overcommit: https://github.com/brigade/overcommit
30
#
31
# To manage this config yourself in your module add
32
#
33
# ```
34
# .overcommit.yml:
35
#   unmanaged: true
36
# ```
37
#
38
# to your modules .sync.yml config
39
---
40
PreCommit:
41
  RuboCop:
42
    enabled: true
43
    description: 'Runs rubocop on modified files only'
44
    command: ['bundle', 'exec', 'rubocop']
45
  PuppetLint:
46
    enabled: true
47
    description: 'Runs puppet-lint on modified files only'
48
    command: ['bundle', 'exec', 'puppet-lint']
49
  YamlSyntax:
50
    enabled: true
51
  JsonSyntax:
52
    enabled: true
53
  TrailingWhitespace:
54
    enabled: true
55

  
56
PrePush:
57
  RakeTarget:
58
    enabled: true
59
    description: 'Run rake targets'
60
    targets:
61
      - 'validate'
62
      - 'test'
63
      - 'rubocop'
64
    command: ['bundle', 'exec', 'rake']
.pmtignore
1
docs/
2
pkg/
3
Gemfile
4
Gemfile.lock
5
Gemfile.local
6
vendor/
7
.vendor/
8
spec/
9
Rakefile
10
.vagrant/
11
.bundle/
12
.ruby-version
13
coverage/
14
log/
15
.idea/
16
.dependencies/
17
.github/
18
.librarian/
19
Puppetfile.lock
20
*.iml
21
.editorconfig
22
.fixtures.yml
23
.gitignore
24
.msync.yml
25
.overcommit.yml
26
.pmtignore
27
.rspec
28
.rspec_parallel
29
.rubocop.yml
30
.sync.yml
31
.*.sw?
32
.yardoc/
33
.yardopts
34
Dockerfile
.rspec
1
--color
2 1
--format documentation
2
--color
.rspec_parallel
1
--format progress
.rubocop.yml
1 1
---
2
require:
3
- rubocop-rspec
4
- rubocop-i18n
5
AllCops:
6
  DisplayCopNames: true
7
  TargetRubyVersion: '2.1'
8
  Include:
9
  - "./**/*.rb"
10
  Exclude:
11
  - bin/*
12
  - ".vendor/**/*"
13
  - "**/Gemfile"
14
  - "**/Rakefile"
15
  - pkg/**/*
16
  - spec/fixtures/**/*
17
  - vendor/**/*
18
  - "**/Puppetfile"
19
  - "**/Vagrantfile"
20
  - "**/Guardfile"
21
Metrics/LineLength:
22
  Description: People have wide screens, use them.
23
  Max: 200
24
GetText:
25
  Enabled: false
26
GetText/DecorateString:
27
  Description: We don't want to decorate test output.
28
  Exclude:
29
  - spec/**/*
30
  Enabled: false
31
RSpec/BeforeAfterAll:
32
  Description: Beware of using after(:all) as it may cause state to leak between tests.
33
    A necessary evil in acceptance testing.
34
  Exclude:
35
  - spec/acceptance/**/*.rb
36
RSpec/HookArgument:
37
  Description: Prefer explicit :each argument, matching existing module's style
38
  EnforcedStyle: each
39
Style/BlockDelimiters:
40
  Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
41
    be consistent then.
42
  EnforcedStyle: braces_for_chaining
43
Style/BracesAroundHashParameters:
44
  Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0.
45
    See https://github.com/rubocop-hq/rubocop/pull/7643
46
  Enabled: true
47
Style/ClassAndModuleChildren:
48
  Description: Compact style reduces the required amount of indentation.
49
  EnforcedStyle: compact
50
Style/EmptyElse:
51
  Description: Enforce against empty else clauses, but allow `nil` for clarity.
52
  EnforcedStyle: empty
53
Style/FormatString:
54
  Description: Following the main puppet project's style, prefer the % format format.
55
  EnforcedStyle: percent
56
Style/FormatStringToken:
57
  Description: Following the main puppet project's style, prefer the simpler template
58
    tokens over annotated ones.
59
  EnforcedStyle: template
60
Style/Lambda:
61
  Description: Prefer the keyword for easier discoverability.
62
  EnforcedStyle: literal
63
Style/RegexpLiteral:
64
  Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
65
  EnforcedStyle: percent_r
66
Style/TernaryParentheses:
67
  Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
68
    on complex expressions for better readability, but seriously consider breaking
69
    it up.
70
  EnforcedStyle: require_parentheses_when_complex
71
Style/TrailingCommaInArguments:
72
  Description: Prefer always trailing comma on multiline argument lists. This makes
73
    diffs, and re-ordering nicer.
74
  EnforcedStyleForMultiline: comma
75
Style/TrailingCommaInLiteral:
76
  Description: Prefer always trailing comma on multiline literals. This makes diffs,
77
    and re-ordering nicer.
78
  EnforcedStyleForMultiline: comma
79
Style/SymbolArray:
80
  Description: Using percent style obscures symbolic intent of array's contents.
81
  EnforcedStyle: brackets
82
RSpec/MessageSpies:
83
  EnforcedStyle: receive
84
Style/Documentation:
85
  Exclude:
86
  - lib/puppet/parser/functions/**/*
87
  - spec/**/*
88
Style/WordArray:
89
  EnforcedStyle: brackets
90
Style/CollectionMethods:
91
  Enabled: true
92
Style/MethodCalledOnDoEndBlock:
93
  Enabled: true
94
Style/StringMethods:
95
  Enabled: true
96
GetText/DecorateFunctionMessage:
97
  Enabled: false
98
GetText/DecorateStringFormattingUsingInterpolation:
99
  Enabled: false
100
GetText/DecorateStringFormattingUsingPercent:
101
  Enabled: false
102
Layout/EndOfLine:
103
  Enabled: false
104
Layout/IndentHeredoc:
105
  Enabled: false
106
Metrics/AbcSize:
107
  Enabled: false
108
Metrics/BlockLength:
109
  Enabled: false
110
Metrics/ClassLength:
111
  Enabled: false
112
Metrics/CyclomaticComplexity:
113
  Enabled: false
114
Metrics/MethodLength:
115
  Enabled: false
116
Metrics/ModuleLength:
117
  Enabled: false
118
Metrics/ParameterLists:
119
  Enabled: false
120
Metrics/PerceivedComplexity:
121
  Enabled: false
122
RSpec/DescribeClass:
123
  Enabled: false
124
RSpec/ExampleLength:
125
  Enabled: false
126
RSpec/MessageExpectation:
127
  Enabled: false
128
RSpec/MultipleExpectations:
129
  Enabled: false
130
RSpec/NestedGroups:
131
  Enabled: false
132
Style/AsciiComments:
133
  Enabled: false
134
Style/IfUnlessModifier:
135
  Enabled: false
136
Style/SymbolProc:
137
  Enabled: false
2
inherit_gem:
3
  voxpupuli-test: rubocop.yml
.travis.yml
1
---
2
os: linux
3
dist: xenial
4
language: ruby
5
cache: bundler
6
before_install:
7
  - bundle -v
8
  - rm -f Gemfile.lock
9
  - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner"
10
  - "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used"
11
  - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set"
12
  - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION'
13
  - gem --version
14
  - bundle -v
15
script:
16
  - 'bundle exec rake $CHECK'
17
bundler_args: --without system_tests
18
rvm:
19
  - 2.5.7
20
stages:
21
  - static
22
  - spec
23
  - acceptance
24
  -
25
    if: tag =~ ^v\d
26
    name: deploy
27
jobs:
28
  fast_finish: true
29
  include:
30
    -
31
      env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint"
32
      stage: static
33
    -
34
      env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
35
      rvm: 2.4.5
36
      stage: spec
37
    -
38
      env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec
39
      rvm: 2.5.7
40
      stage: spec
41
    -
42
      env: DEPLOY_TO_FORGE=yes
43
      stage: deploy
44
branches:
45
  only:
46
    - master
47
    - /^v\d/
48
notifications:
49
  email: false
.yardopts
1 1
--markup markdown
2
--output-dir docs/
Dockerfile
1
FROM ruby:2.5.3
2

  
3
WORKDIR /opt/puppet
4

  
5
# https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39
6
RUN mkdir -p /etc/sv
7

  
8
ARG PUPPET_VERSION="~> 6.0"
9
ARG PARALLEL_TEST_PROCESSORS=4
10

  
11
# Cache gems
12
COPY Gemfile .
13
RUN bundle install --without system_tests development release --path=${BUNDLE_PATH:-vendor/bundle}
14

  
15
COPY . .
16

  
17
RUN bundle install
18
RUN bundle exec rake release_checks
19

  
20
# Container should not saved
21
RUN exit 1
Gemfile
1
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
1
source ENV['GEM_SOURCE'] || "https://rubygems.org"
2 2

  
3
def location_for(place_or_version, fake_version = nil)
4
  git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
5
  file_url_regex = %r{\Afile:\/\/(?<path>.*)}
6

  
7
  if place_or_version && (git_url = place_or_version.match(git_url_regex))
8
    [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
9
  elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
10
    ['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
11
  else
12
    [place_or_version, { require: false }]
13
  end
3
group :test do
4
  gem 'voxpupuli-test', '~> 2.1',  :require => false
5
  gem 'coveralls',                 :require => false
6
  gem 'simplecov-console',         :require => false
14 7
end
15 8

  
16
ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
17
minor_version = ruby_version_segments[0..1].join('.')
18

  
19 9
group :development do
20
  gem "fast_gettext", '1.1.0',                                   require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
21
  gem "fast_gettext",                                            require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
22
  gem "json_pure", '<= 2.0.1',                                   require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
23
  gem "json", '= 1.8.1',                                         require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
24
  gem "json", '= 2.0.4',                                         require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
25
  gem "json", '= 2.1.0',                                         require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
26
  gem "rb-readline", '= 0.5.5',                                  require: false, platforms: [:mswin, :mingw, :x64_mingw]
27
  gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby]
28
  gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4',     require: false, platforms: [:ruby]
29
  gem "puppet-module-win-default-r#{minor_version}", '~> 0.4',   require: false, platforms: [:mswin, :mingw, :x64_mingw]
30
  gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4',       require: false, platforms: [:mswin, :mingw, :x64_mingw]
10
  gem 'guard-rake',               :require => false
11
  gem 'overcommit', '>= 0.39.1',  :require => false
31 12
end
32 13

  
33
puppet_version = ENV['PUPPET_GEM_VERSION']
34
facter_version = ENV['FACTER_GEM_VERSION']
35
hiera_version = ENV['HIERA_GEM_VERSION']
36

  
37
gems = {}
38

  
39
gems['puppet'] = location_for(puppet_version)
40

  
41
# If facter or hiera versions have been specified via the environment
42
# variables
43

  
44
gems['facter'] = location_for(facter_version) if facter_version
45
gems['hiera'] = location_for(hiera_version) if hiera_version
46

  
47
if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)}
48
  # If we're using a Puppet gem on Windows which handles its own win32-xxx gem
49
  # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445).
50
  gems['win32-dir'] =      ['<= 0.4.9', require: false]
51
  gems['win32-eventlog'] = ['<= 0.6.5', require: false]
52
  gems['win32-process'] =  ['<= 0.7.5', require: false]
53
  gems['win32-security'] = ['<= 0.2.5', require: false]
54
  gems['win32-service'] =  ['0.8.8', require: false]
14
group :system_tests do
15
  gem 'puppet_metadata', '~> 0.3.0',  :require => false
16
  gem 'voxpupuli-acceptance',         :require => false
55 17
end
56 18

  
57
gems.each do |gem_name, gem_params|
58
  gem gem_name, *gem_params
19
group :release do
20
  gem 'github_changelog_generator',  :require => false, :git => 'https://github.com/voxpupuli/github-changelog-generator', :branch => 'voxpupuli_essential_fixes'
21
  gem 'puppet-blacksmith',           :require => false
22
  gem 'voxpupuli-release',           :require => false
23
  gem 'puppet-strings', '>= 2.2',    :require => false
59 24
end
60 25

  
61
# Evaluate Gemfile.local and ~/.gemfile if they exist
62
extra_gemfiles = [
63
  "#{__FILE__}.local",
64
  File.join(Dir.home, '.gemfile'),
65
]
26
gem 'puppetlabs_spec_helper', '~> 2.0', :require => false
27
gem 'rake', :require => false
28
gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test]
29

  
30
puppetversion = ENV['PUPPET_VERSION'] || '~> 6.0'
31
gem 'puppet', puppetversion, :require => false, :groups => [:test]
66 32

  
67
extra_gemfiles.each do |gemfile|
68
  if File.file?(gemfile) && File.readable?(gemfile)
69
    eval(File.read(gemfile), binding)
70
  end
71
end
72 33
# vim: syntax=ruby
Rakefile
1
# frozen_string_literal: true
2

  
3
require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any?
4
require 'puppetlabs_spec_helper/rake_tasks'
5
require 'puppet-syntax/tasks/puppet-syntax'
6
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
7
require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
8
require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any?
9

  
10
def changelog_user
11
  return unless Rake.application.top_level_tasks.include? "changelog"
12
  returnVal = nil || JSON.load(File.read('metadata.json'))['author']
13
  raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
14
  puts "GitHubChangelogGenerator user:#{returnVal}"
15
  returnVal
1
# Attempt to load voxupuli-test (which pulls in puppetlabs_spec_helper),
2
# otherwise attempt to load it directly.
3
begin
4
  require 'voxpupuli/test/rake'
5
rescue LoadError
6
  require 'puppetlabs_spec_helper/rake_tasks'
16 7
end
17 8

  
18
def changelog_project
19
  return unless Rake.application.top_level_tasks.include? "changelog"
20

  
21
  returnVal = nil
22
  returnVal ||= begin
23
    metadata_source = JSON.load(File.read('metadata.json'))['source']
24
    metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z})
9
# load optional tasks for releases
10
# only available if gem group releases is installed
11
begin
12
  require 'voxpupuli/release/rake_tasks'
13
rescue LoadError
14
end
25 15

  
26
    metadata_source_match && metadata_source_match[1]
16
desc "Run main 'test' task and report merged results to coveralls"
17
task test_with_coveralls: [:test] do
18
  if Dir.exist?(File.expand_path('../lib', __FILE__))
19
    require 'coveralls/rake/task'
20
    Coveralls::RakeTask.new
21
    Rake::Task['coveralls:push'].invoke
22
  else
23
    puts 'Skipping reporting to coveralls.  Module has no lib dir'
27 24
  end
28

  
29
  raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil?
30

  
31
  puts "GitHubChangelogGenerator project:#{returnVal}"
32
  returnVal
33 25
end
34 26

  
35
def changelog_future_release
36
  return unless Rake.application.top_level_tasks.include? "changelog"
37
  returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version']
38
  raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
39
  puts "GitHubChangelogGenerator future_release:#{returnVal}"
40
  returnVal
27
desc 'Generate REFERENCE.md'
28
task :reference, [:debug, :backtrace] do |t, args|
29
  patterns = ''
30
  Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace])
41 31
end
42 32

  
43
PuppetLint.configuration.send('disable_relative')
44

  
45
if Bundler.rubygems.find_name('github_changelog_generator').any?
33
begin
34
  require 'github_changelog_generator/task'
35
  require 'puppet_blacksmith'
46 36
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
47
    raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil?
48
    config.user = "#{changelog_user}"
49
    config.project = "#{changelog_project}"
50
    config.future_release = "#{changelog_future_release}"
51
    config.exclude_labels = ['maintenance']
52
    config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
53
    config.add_pr_wo_labels = true
54
    config.issues = false
55
    config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB"
56
    config.configure_sections = {
57
      "Changed" => {
58
        "prefix" => "### Changed",
59
        "labels" => ["backwards-incompatible"],
60
      },
61
      "Added" => {
62
        "prefix" => "### Added",
63
        "labels" => ["enhancement", "feature"],
64
      },
65
      "Fixed" => {
66
        "prefix" => "### Fixed",
67
        "labels" => ["bug", "documentation", "bugfix"],
68
      },
69
    }
37
    version = (Blacksmith::Modulefile.new).version
38
    config.future_release = "v#{version}" if version =~ /^\d+\.\d+.\d+$/
39
    config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module."
40
    config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog}
41
    config.user = 'voxpupuli'
42
    metadata_json = File.join(File.dirname(__FILE__), 'metadata.json')
43
    metadata = JSON.load(File.read(metadata_json))
44
    config.project = metadata['name']
70 45
  end
71
else
72
  desc 'Generate a Changelog from GitHub'
73
  task :changelog do
74
    raise <<EOM
75
The changelog tasks depends on recent features of the github_changelog_generator gem.
76
Please manually add it to your .sync.yml for now, and run `pdk update`:
77
---
78
Gemfile:
79
  optional:
80
    ':development':
81
      - gem: 'github_changelog_generator'
82
        version: '~> 1.15'
83
        condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')"
84
EOM
46

  
47
  # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715
48
  require 'rbconfig'
49
  if RbConfig::CONFIG['host_os'] =~ /linux/
50
    task :changelog do
51
      puts 'Fixing line endings...'
52
      changelog_file = File.join(__dir__, 'CHANGELOG.md')
53
      changelog_txt = File.read(changelog_file)
54
      new_contents = changelog_txt.gsub(%r{\r\n}, "\n")
55
      File.open(changelog_file, "w") {|file| file.puts new_contents }
56
    end
85 57
  end
86
end
87 58

  
59
rescue LoadError
60
end
61
# vim: syntax=ruby
spec/default_facts.yml
1
# Use default_module_facts.yml for module specific facts.
2
#
3
# Facts specified here will override the values provided by rspec-puppet-facts.
4
---
5
ipaddress: "172.16.254.254"
6
ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA"
7
is_pe: false
8
macaddress: "AA:AA:AA:AA:AA:AA"
spec/spec_helper.rb
1
# frozen_string_literal: true
2

  
3
require 'puppetlabs_spec_helper/module_spec_helper'
4
require 'rspec-puppet-facts'
5

  
6
require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
7

  
8
include RspecPuppetFacts
9

  
10
default_facts = {
11
  puppetversion: Puppet.version,
12
  facterversion: Facter.version,
13
}
14

  
15
default_fact_files = [
16
  File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')),
17
  File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')),
18
]
19

  
20
default_fact_files.each do |f|
21
  next unless File.exist?(f) && File.readable?(f) && File.size?(f)
22

  
23
  begin
24
    default_facts.merge!(YAML.safe_load(File.read(f), [], [], true))
25
  rescue => e
26
    RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
1
# This file is managed via modulesync
2
# https://github.com/voxpupuli/modulesync
3
# https://github.com/voxpupuli/modulesync_config
4

  
5
# puppetlabs_spec_helper will set up coverage if the env variable is set.
6
# We want to do this if lib exists and it hasn't been explicitly set.
7
ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__))
8

  
9
require 'voxpupuli/test/spec_helper'
10

  
11
if File.exist?(File.join(__dir__, 'default_module_facts.yml'))
12
  facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml')))
13
  if facts
14
    facts.each do |name, value|
15
      add_custom_fact name.to_sym, value
16
    end
27 17
  end
28 18
end
29

  
30
# read default_facts and merge them over what is provided by facterdb
31
default_facts.each do |fact, value|
32
  add_custom_fact fact, value
33
end
34

  
35
RSpec.configure do |c|
36
  c.default_facts = default_facts
37
  c.before :each do
38
    # set to strictest setting for testing
39
    # by default Puppet runs at warning level
40
    Puppet.settings[:strict] = :warning
41
    Puppet.settings[:strict_variables] = true
42
  end
43
  c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
44
  c.after(:suite) do
45
  end
46
end
47

  
48
# Ensures that a module is defined
49
# @param module_name Name of the module
50
def ensure_module_defined(module_name)
51
  module_name.split('::').reduce(Object) do |last_module, next_module|
52
    last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)
53
    last_module.const_get(next_module, false)
54
  end
55
end
56

  
57
# 'spec_overrides' from sync.yml will appear below this line

Formats disponibles : Unified diff