From df12aea826d3ba00541acbcedab921fd1c4ce987 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Tue, 17 Dec 2024 10:48:57 +0000 Subject: [PATCH] YOLO Signed-off-by: Dan Webb --- .github/actions/test-kitchen/action.yml | 43 +++++++ .github/actions/virtualbox-setup/action.yml | 23 ++++ .github/workflows/ci.yml | 119 ++++++-------------- kitchen.dokken.yml | 15 --- kitchen.yml | 27 +++++ resources/swarm_token.rb | 2 +- 6 files changed, 131 insertions(+), 98 deletions(-) create mode 100644 .github/actions/test-kitchen/action.yml create mode 100644 .github/actions/virtualbox-setup/action.yml diff --git a/.github/actions/test-kitchen/action.yml b/.github/actions/test-kitchen/action.yml new file mode 100644 index 000000000..c4e285b25 --- /dev/null +++ b/.github/actions/test-kitchen/action.yml @@ -0,0 +1,43 @@ +name: 'Run Test Kitchen' +description: 'Runs Test Kitchen tests with configurable options' + +inputs: + suite: + description: 'Test Kitchen suite to run' + required: true + os: + description: 'Operating system to test' + required: true + kitchen-yaml: + description: 'Kitchen YAML file to use' + required: false + default: 'kitchen.dokken.yml' + chef-version: + description: 'Chef version to use' + required: false + default: 'latest' + chef-license: + description: 'Chef license acceptance' + required: false + default: 'accept-no-persist' + kitchen-command: + description: 'Kitchen command to run (test, verify, etc)' + required: false + default: 'test' + +runs: + using: "composite" + steps: + - name: Install Chef + uses: actionshub/chef-install@3.0.1 + with: + version: ${{ inputs.chef-version }} + + - name: Run Test Kitchen + shell: bash + run: + kitchen ${{ inputs.kitchen-command }} ${{ inputs.suite }}-${{ inputs.os }} + env: + CHEF_LICENSE: ${{ inputs.chef-license }} + KITCHEN_LOCAL_YAML: ${{ inputs.kitchen-yaml }} + KITCHEN_YAML: ${{ inputs.kitchen-yaml }} diff --git a/.github/actions/virtualbox-setup/action.yml b/.github/actions/virtualbox-setup/action.yml new file mode 100644 index 000000000..ae3a40426 --- /dev/null +++ b/.github/actions/virtualbox-setup/action.yml @@ -0,0 +1,23 @@ +name: 'Setup VirtualBox & Vagrant' +description: 'Installs VirtualBox and Vagrant on Ubuntu runners' + +inputs: + virtualbox-version: + description: 'Version of VirtualBox to install' + required: false + default: '*' + vagrant-version: + description: 'Version of Vagrant to install' + required: false + default: 'latest' + +runs: + using: "composite" + steps: + - name: Install VirtualBox & Vagrant + shell: bash + run: | + sudo apt update && sudo apt install virtualbox -y + wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg + echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list + sudo apt update && sudo apt install vagrant diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 663d4b316..8432a0f02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,104 +19,64 @@ jobs: integration: needs: lint-unit - runs-on: ubuntu-latest + runs-on: ubuntu-2204 strategy: matrix: os: - - "almalinux-8" - - "debian-11" - - "debian-12" - - "rockylinux-8" - - "rockylinux-9" - - "ubuntu-2004" - - "ubuntu-2204" - - "ubuntu-2404" + - almalinux-9 + - almalinux-10 + - amazonlinux-2023 + - centos-stream-9 + - centos-stream-10 + - debian-11 + - debian-12 + - fedora-latest + - opensuse-leap-15 + - oraclelinux-8 + - oraclelinux-9 + - ubuntu-2204 + - ubuntu-2404 suite: - "installation-script-main" - "installation-script-test" - "installation-package" - "installation-tarball" - "install-and-stop" - exclude: - - os: debian-11 - suite: installation-script-test - - os: debian-12 - suite: installation-script-test - - os: almalinux-8 - suite: installation-script-main - - os: almalinux-8 - suite: installation-script-test - - os: rockylinux-8 - suite: installation-script-main - - os: rockylinux-8 - suite: installation-script-test - - os: rockylinux-9 - suite: installation-script-main - - os: rockylinux-9 - suite: installation-script-test fail-fast: false - steps: - name: Check out code uses: actions/checkout@v4 - - name: Install Chef - uses: actionshub/chef-install@3.0.1 - - name: Dokken - uses: actionshub/test-kitchen@3.0.0 - env: - CHEF_VERSION: latest - CHEF_LICENSE: accept-no-persist - KITCHEN_LOCAL_YAML: kitchen.dokken.yml + - name: Test Kitchen + uses: ./.github/actions/test-kitchen with: suite: ${{ matrix.suite }} os: ${{ matrix.os }} + kitchen-yaml: kitchen.dokken.yml + chef-version: latest + chef-license: accept-no-persist - integration-amazonlinux: + integration-swarm: needs: lint-unit - runs-on: ubuntu-24.04 + runs-on: ubuntu-22.04 strategy: matrix: - os: - - amazonlinux-2 - suite: - - "installation-tarball" - - "install-and-stop" + os: ["ubuntu-2204"] + suite: ["swarm"] fail-fast: false steps: - name: Check out code uses: actions/checkout@v4 - - name: Install Chef - uses: actionshub/chef-install@3.0.1 - - name: Dokken - uses: actionshub/test-kitchen@3.0.0 - env: - CHEF_VERSION: latest - CHEF_LICENSE: accept-no-persist - KITCHEN_LOCAL_YAML: kitchen.dokken.yml + - name: Setup VirtualBox & Vagrant + uses: ./.github/actions/virtualbox-setup + - name: Run Kitchen Tests + uses: ./.github/actions/test-kitchen with: suite: ${{ matrix.suite }} os: ${{ matrix.os }} - - integration-swarm: - needs: lint-unit - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v4 - - name: Install Chef - uses: actionshub/chef-install@3.0.1 - - name: Install Docker - uses: docker/setup-docker-action@v4 - - name: Test Kitchen - uses: actionshub/test-kitchen@3.0.0 - env: - CHEF_VERSION: latest - CHEF_LICENSE: accept-no-persist - KITCHEN_LOCAL_YAML: kitchen.exec.yml - with: - suite: swarm - os: ubuntu-latest + kitchen-yaml: kitchen.yml + chef-version: latest + chef-license: accept-no-persist integration-smoke: needs: lint-unit @@ -136,23 +96,18 @@ jobs: suite: - "smoke" fail-fast: false - steps: - name: Check out code uses: actions/checkout@v4 - - name: Install VirtualBox & Vagrant - run: | - sudo apt update && sudo apt install virtualbox - wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg - echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list - sudo apt update && sudo apt install vagrant + - name: Setup VirtualBox & Vagrant + uses: ./.github/workflows/virtualbox-setup.yml - name: Install Chef uses: actionshub/chef-install@3.0.1 - - name: Dokken - uses: actionshub/test-kitchen@3.0.0 - env: - CHEF_VERSION: latest - CHEF_LICENSE: accept-no-persist + - name: Test Kitchen + uses: ./.github/actions/test-kitchen with: suite: ${{ matrix.suite }} os: ${{ matrix.os }} + kitchen-yaml: kitchen.yml + chef-version: latest + chef-license: accept-no-persist diff --git a/kitchen.dokken.yml b/kitchen.dokken.yml index 998bb20cb..e4da09138 100644 --- a/kitchen.dokken.yml +++ b/kitchen.dokken.yml @@ -67,21 +67,6 @@ platforms: image: dokken/oraclelinux-9 pid_one_command: /usr/lib/systemd/systemd - - name: rockylinux-8 - driver: - image: dokken/rockylinux-8 - pid_one_command: /usr/lib/systemd/systemd - - - name: rockylinux-9 - driver: - image: dokken/rockylinux-9 - pid_one_command: /usr/lib/systemd/systemd - - - name: ubuntu-20.04 - driver: - image: dokken/ubuntu-20.04 - pid_one_command: /bin/systemd - - name: ubuntu-22.04 driver: image: dokken/ubuntu-22.04 diff --git a/kitchen.yml b/kitchen.yml index 8657ca411..4a3301009 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -179,3 +179,30 @@ suites: - name: smoke run_list: - recipe[docker_test::smoke] + + ############################### + # docker_swarm resources + ############################### + - name: swarm + includes: + - ubuntu-22.04 + provisioner: + enforce_idempotency: false + multiple_converge: 1 + attributes: + docker: + version: '20.10.11' + swarm: + init: + advertise_addr: '127.0.0.1' + listen_addr: '0.0.0.0:2377' + rotate_token: true + service: + name: 'web' + image: 'nginx:latest' + publish: ['80:80'] + replicas: 2 + run_list: + - recipe[docker_test::swarm_default] + - recipe[docker_test::swarm_init] + - recipe[docker_test::swarm_service] diff --git a/resources/swarm_token.rb b/resources/swarm_token.rb index c41b6995f..437b6d571 100644 --- a/resources/swarm_token.rb +++ b/resources/swarm_token.rb @@ -10,7 +10,7 @@ load_current_value do if swarm_manager? - cmd = Mixlib::ShellOut.new("docker swarm join-token -q #{token_type}") + cmd = Mixlib::ShellOut.new("docker swarm join-token -q #{new_resource.token_type}") cmd.run_command current_value_does_not_exist! if cmd.error? else