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