|
| 1 | +--- |
| 2 | +name: CI |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: {} |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + |
| 10 | +# minimal permissions |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + rubocop_and_matrix: |
| 16 | + runs-on: ubuntu-24.04 |
| 17 | + outputs: |
| 18 | + ruby: ${{ steps.ruby.outputs.versions }} |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v6 |
| 21 | + - name: Install Ruby ${{ matrix.ruby }} |
| 22 | + uses: ruby/setup-ruby@v1 |
| 23 | + with: |
| 24 | + ruby-version: "3.4" |
| 25 | + bundler-cache: true |
| 26 | + - name: Run Rubocop |
| 27 | + run: bundle exec rake rubocop |
| 28 | + - run: gem build --strict --verbose *.gemspec |
| 29 | + - id: ruby |
| 30 | + uses: voxpupuli/ruby-version@v2 |
| 31 | + |
| 32 | + linux_unit_tests: |
| 33 | + needs: |
| 34 | + - rubocop_and_matrix |
| 35 | + name: Unit tests on Linux with Ruby ${{ matrix.ruby }} |
| 36 | + strategy: |
| 37 | + fail-fast: false |
| 38 | + matrix: |
| 39 | + ruby: ${{ fromJSON(needs.rubocop_and_matrix.outputs.ruby) }} |
| 40 | + include: |
| 41 | + - ruby: 'jruby-9.4.12.1' |
| 42 | + - ruby: 'jruby-9.4.8.0' |
| 43 | + - ruby: 'jruby-10.0.2.0' |
| 44 | + runs-on: ubuntu-24.04 |
| 45 | + steps: |
| 46 | + - name: Checkout current PR |
| 47 | + uses: actions/checkout@v6 |
| 48 | + |
| 49 | + - name: Rspec checks |
| 50 | + uses: ruby/setup-ruby@v1 |
| 51 | + with: |
| 52 | + ruby-version: ${{ matrix.ruby }} |
| 53 | + bundler-cache: true |
| 54 | + - run: bundle exec rake spec_random |
| 55 | + |
| 56 | + windows_unit_tests: |
| 57 | + name: Unit tests on Windows with Ruby ${{ matrix.ruby }} |
| 58 | + strategy: |
| 59 | + matrix: |
| 60 | + ruby: |
| 61 | + - '2.7' |
| 62 | + - '3.2' |
| 63 | + runs-on: windows-2025 |
| 64 | + steps: |
| 65 | + - name: Checkout current PR |
| 66 | + uses: actions/checkout@v6 |
| 67 | + |
| 68 | + - name: Rspec checks |
| 69 | + uses: ruby/setup-ruby@v1 |
| 70 | + with: |
| 71 | + ruby-version: ${{ matrix.ruby }} |
| 72 | + bundler-cache: true |
| 73 | + - run: bundle exec rake spec_random |
| 74 | + |
| 75 | + acceptance_tests: |
| 76 | + name: Platform |
| 77 | + strategy: |
| 78 | + matrix: |
| 79 | + os: |
| 80 | + - windows-2022 |
| 81 | + - ubuntu-22.04 |
| 82 | + - ubuntu-24.04 |
| 83 | + fail-fast: false |
| 84 | + runs-on: ${{ matrix.os }} |
| 85 | + env: |
| 86 | + BEAKER_debug: true |
| 87 | + FACTER_ROOT: facter |
| 88 | + RELEASE_STREAM: puppet8 |
| 89 | + |
| 90 | + steps: |
| 91 | + - name: Checkout current PR |
| 92 | + uses: actions/checkout@v6 |
| 93 | + with: |
| 94 | + path: facter |
| 95 | + |
| 96 | + - name: Install Ruby 3.2 |
| 97 | + uses: ruby/setup-ruby@v1 |
| 98 | + with: |
| 99 | + ruby-version: '3.2' |
| 100 | + bundler-cache: true |
| 101 | + |
| 102 | + - name: Fix common Linux and macOS permissions |
| 103 | + if: runner.os != 'Windows' |
| 104 | + run: sudo chmod a-w /opt |
| 105 | + |
| 106 | + - name: Fix Linux permissions |
| 107 | + if: runner.os == 'Linux' |
| 108 | + run: | |
| 109 | + sudo chmod a-w /home/runner /usr/share && |
| 110 | + sudo chmod -R a-w /home/runner/.config /home/linuxbrew |
| 111 | +
|
| 112 | + - name: Install dhclient for Linux |
| 113 | + if: runner.os == 'Linux' |
| 114 | + run: | |
| 115 | + sudo apt install isc-dhcp-client |
| 116 | + sudo dhclient |
| 117 | +
|
| 118 | + # IPv6 is missing on the GitHub macOS image and we need it for the networking facts tests |
| 119 | + # https://github.com/actions/runner-images/issues/668 |
| 120 | + - name: Add IPv6 on macOS |
| 121 | + if: runner.os == 'macOS' |
| 122 | + run: | |
| 123 | + primary_interface=`route -n get default | awk '/interface: */{print $NF}'` |
| 124 | + sudo ifconfig $primary_interface inet6 add ::1/64 |
| 125 | +
|
| 126 | + - name: Run acceptance tests on Linux and MacOS platform |
| 127 | + if: runner.os != 'Windows' |
| 128 | + run: sudo -E "PATH=$PATH" ruby $FACTER_ROOT/.github/actions/presuite.rb ${{ matrix.os }} |
| 129 | + |
| 130 | + - name: Run acceptance tests on Windows-like platform |
| 131 | + if: runner.os == 'Windows' |
| 132 | + run: ruby $Env:FACTER_ROOT/.github/actions/presuite.rb ${{ matrix.os }} |
| 133 | + |
| 134 | + integration_tests: |
| 135 | + name: Integration on ${{ matrix.cfg.os }} with Ruby ${{ matrix.cfg.ruby }} |
| 136 | + strategy: |
| 137 | + fail-fast: false |
| 138 | + matrix: |
| 139 | + cfg: |
| 140 | + - {os: ubuntu-latest, ruby: '2.7'} |
| 141 | + - {os: ubuntu-22.04, ruby: '3.2'} # with openssl 3 |
| 142 | + - {os: ubuntu-22.04, ruby: 'jruby-9.3.14.0'} |
| 143 | + - {os: ubuntu-latest, ruby: 'jruby-9.4.8.0'} |
| 144 | + - {os: ubuntu-latest, ruby: 'jruby-9.4.12.1'} |
| 145 | + - {os: ubuntu-latest, ruby: 'jruby-10.0.2.0'} |
| 146 | + - {os: windows-2022, ruby: '2.7'} |
| 147 | + - {os: windows-2022, ruby: '3.2'} # with openssl 3 |
| 148 | + runs-on: ${{ matrix.cfg.os }} |
| 149 | + env: |
| 150 | + BUNDLE_WITH: 'integration' |
| 151 | + steps: |
| 152 | + - name: Checkout current PR |
| 153 | + uses: actions/checkout@v6 |
| 154 | + |
| 155 | + - name: Rspec checks |
| 156 | + uses: ruby/setup-ruby@v1 |
| 157 | + with: |
| 158 | + ruby-version: ${{ matrix.cfg.ruby }} |
| 159 | + bundler-cache: true |
| 160 | + - run: bundle exec rake spec_integration |
| 161 | + |
| 162 | + tests: |
| 163 | + if: always() |
| 164 | + needs: |
| 165 | + - rubocop_and_matrix |
| 166 | + - linux_unit_tests |
| 167 | + - windows_unit_tests |
| 168 | + - acceptance_tests |
| 169 | + - integration_tests |
| 170 | + runs-on: ubuntu-24.04 |
| 171 | + name: Test suite |
| 172 | + steps: |
| 173 | + - name: Decide whether the needed jobs succeeded or failed |
| 174 | + uses: re-actors/alls-green@release/v1 |
| 175 | + with: |
| 176 | + jobs: ${{ toJSON(needs) }} |
0 commit comments