|
| 1 | +# This is a generic workflow for Puppet module CI operations. |
| 2 | +name: "Module CI" |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + runs_on: |
| 8 | + description: "The operating system used for the runner." |
| 9 | + required: false |
| 10 | + default: "ubuntu-latest" |
| 11 | + type: "string" |
| 12 | + flags: |
| 13 | + description: "Additional flags to pass to matrix_from_metadata_v2." |
| 14 | + required: false |
| 15 | + default: '' |
| 16 | + type: "string" |
| 17 | + |
| 18 | +jobs: |
| 19 | + setup_matrix: |
| 20 | + name: "Setup Test Matrix" |
| 21 | + runs-on: ${{ inputs.runs_on }} |
| 22 | + outputs: |
| 23 | + spec_matrix: ${{ steps.get-matrix.outputs.spec_matrix }} |
| 24 | + |
| 25 | + steps: |
| 26 | + |
| 27 | + - name: "Checkout" |
| 28 | + uses: "actions/checkout@v4" |
| 29 | + with: |
| 30 | + ref: ${{ github.event.pull_request.head.sha }} |
| 31 | + |
| 32 | + - name: "Setup ruby" |
| 33 | + uses: "ruby/setup-ruby@v1" |
| 34 | + with: |
| 35 | + ruby-version: "2.7" |
| 36 | + bundler-cache: true |
| 37 | + |
| 38 | + - name: "Bundle environment" |
| 39 | + run: | |
| 40 | + echo ::group::bundler environment |
| 41 | + bundle env |
| 42 | + echo ::endgroup:: |
| 43 | +
|
| 44 | + - name: Setup Spec Test Matrix |
| 45 | + id: get-matrix |
| 46 | + run: | |
| 47 | + bundle exec matrix_from_metadata_v2 ${{ inputs.flags }} |
| 48 | +
|
| 49 | + spec: |
| 50 | + name: "Spec tests (Puppet: ${{matrix.puppet_version}}, Ruby Ver: ${{matrix.ruby_version}})" |
| 51 | + needs: "setup_matrix" |
| 52 | + runs-on: ${{ inputs.runs_on }} |
| 53 | + strategy: |
| 54 | + fail-fast: false |
| 55 | + matrix: ${{ fromJson( needs.setup_matrix.outputs.spec_matrix ) }} |
| 56 | + |
| 57 | + env: |
| 58 | + PUPPET_GEM_VERSION: ${{ matrix.puppet_version }} |
| 59 | + FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' # why is this set? |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: "Checkout" |
| 63 | + uses: "actions/checkout@v4" |
| 64 | + with: |
| 65 | + ref: ${{ github.event.pull_request.head.sha }} |
| 66 | + |
| 67 | + - name: "Setup ruby" |
| 68 | + uses: "ruby/setup-ruby@v1" |
| 69 | + with: |
| 70 | + ruby-version: ${{matrix.ruby_version}} |
| 71 | + bundler-cache: true |
| 72 | + |
| 73 | + - name: "Bundle environment" |
| 74 | + run: | |
| 75 | + echo ::group::bundler environment |
| 76 | + bundle env |
| 77 | + echo ::endgroup:: |
| 78 | +
|
| 79 | + - name: "Run Static & Syntax Tests" |
| 80 | + run: | |
| 81 | + bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop |
| 82 | + bundle exec dependency-checker metadata.json || true # temporarily allow to fail |
| 83 | +
|
| 84 | + - name: "Run tests" |
| 85 | + run: | |
| 86 | + bundle exec rake parallel_spec |
0 commit comments