-
Notifications
You must be signed in to change notification settings - Fork 5
129 lines (110 loc) · 3.89 KB
/
module_ci.yml
File metadata and controls
129 lines (110 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# This is a generic workflow for Puppet module CI operations.
name: "Module CI"
on:
workflow_call:
inputs:
runs_on:
description: "The operating system used for the runner."
required: false
default: "ubuntu-latest"
type: "string"
flags:
description: "Additional flags to pass to matrix_from_metadata_v3."
required: false
default: ''
type: "string"
run_shellcheck:
description: "Run shellcheck on all bash files"
required: false
default: false
type: "boolean"
ruby_version:
description: "Ruby version to use"
required: false
default: '3.1'
type: "string"
additional_packages:
description: "Space-separated list of OS packages to install on the runner (apt-get)"
required: false
default: ''
type: "string"
# ENABLE PUPPETCORE. The calling workflow must:
# - Set a valid PUPPET_FORGE_TOKEN secret on its repository.
# - Set ruby_version >= 3.1 to override this workflow's default 2.7; otherwise bundle install will fail.
env:
PUPPET_FORGE_TOKEN: ${{ secrets.PUPPET_FORGE_TOKEN || secrets.PUPPET_FORGE_TOKEN_PUBLIC }}
BUNDLE_RUBYGEMS___PUPPETCORE__PUPPET__COM: "forge-key:${{ secrets.PUPPET_FORGE_TOKEN || secrets.PUPPET_FORGE_TOKEN_PUBLIC }}"
jobs:
setup_matrix:
name: "Setup Test Matrix"
runs-on: ${{ inputs.runs_on }}
outputs:
spec_matrix: ${{ steps.get-matrix.outputs.spec_matrix }}
env:
BUNDLE_WITHOUT: release_prep
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Install additional packages"
if: ${{ inputs.additional_packages != '' }}
run: sudo apt-get install -y ${{ inputs.additional_packages }}
- name: "Setup ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: ${{ inputs.ruby_version }}
bundler-cache: true
- name: "Bundle environment"
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::
- name: Setup Spec Test Matrix
id: get-matrix
run: |
bundle exec matrix_from_metadata_v3 ${{ inputs.flags }}
spec:
name: "Spec tests (Puppet: ${{matrix.puppet_version}}, Ruby Ver: ${{matrix.ruby_version}})"
needs: "setup_matrix"
runs-on: ${{ inputs.runs_on }}
strategy:
fail-fast: false
matrix: ${{ fromJson( needs.setup_matrix.outputs.spec_matrix ) }}
env:
BUNDLE_WITHOUT: release_prep
PUPPET_GEM_VERSION: ${{ matrix.puppet_version }}
FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' # why is this set?
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: "Install additional packages"
if: ${{ inputs.additional_packages != '' }}
run: sudo apt-get install -y ${{ inputs.additional_packages }}
- name: "Setup ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: ${{matrix.ruby_version}}
bundler-cache: true
- name: "Bundle environment"
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::
- name: "shellcheck"
uses: reviewdog/action-shellcheck@v1
if: |
inputs.run_shellcheck &&
inputs.runs_on == 'ubuntu-latest' &&
matrix.ruby_version == '3.1'
with:
check_all_files_with_shebangs: "true"
- name: "Run Static & Syntax Tests"
run: |
bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
bundle exec dependency-checker metadata.json
- name: "Run tests"
run: |
bundle exec rake parallel_spec