Skip to content

Commit

Permalink
Add CI
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Webb <[email protected]>
  • Loading branch information
damacus committed Dec 15, 2024
1 parent b7d2cd2 commit 555c112
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,26 @@ jobs:
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/[email protected]
- name: Install Docker
uses: docker/setup-docker-action@v4
- name: Test Kitchen
uses: actionshub/[email protected]
env:
CHEF_VERSION: latest
CHEF_LICENSE: accept-no-persist
KITCHEN_LOCAL_YAML: kitchen.exec.yml
with:
suite: swarm
os: ubuntu-latest

integration-smoke:
needs: lint-unit
runs-on: ubuntu-latest
Expand Down
26 changes: 24 additions & 2 deletions kitchen.exec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,27 @@ driver: { name: exec }
transport: { name: exec }

platforms:
- name: macos-latest
- name: windows-latest
- name: ubuntu-latest

suites:
- name: swarm
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]
4 changes: 2 additions & 2 deletions resources/swarm_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ def create_service_cmd(new_resource)
cmd = %w(docker service create)
cmd << "--name #{new_resource.service_name}"
cmd << "--replicas #{new_resource.replicas}"

new_resource.env.each { |e| cmd << "--env #{e}" }
new_resource.labels.each { |k, v| cmd << "--label #{k}=#{v}" }
new_resource.mounts.each { |m| cmd << "--mount #{m}" }
new_resource.networks.each { |n| cmd << "--network #{n}" }
new_resource.ports.each { |p| cmd << "--publish #{p}" }
new_resource.constraints.each { |c| cmd << "--constraint #{c}" }

if new_resource.restart_policy
cmd << "--restart-condition #{new_resource.restart_policy[:condition]}"
cmd << "--restart-delay #{new_resource.restart_policy[:delay]}" if new_resource.restart_policy[:delay]
Expand Down

0 comments on commit 555c112

Please sign in to comment.