From 5b350d937aa33324eeb1ade6a9c0455d5d1378a7 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Tue, 14 Nov 2023 13:37:30 +0000 Subject: [PATCH] Add CI workflow (#404) * Add CI workflow --------- Signed-off-by: Dan Webb --- .github/dependabot.yml | 10 ++--- .github/workflows/ci.yml | 94 ++++++++++++++++++++++++++++++++++++++++ .kitchen.windows.yml | 33 -------------- .kitchen.yml | 65 --------------------------- .travis.yml | 57 ------------------------ .yamllint | 15 +++++++ kitchen-docker.gemspec | 1 + kitchen.windows.yml | 33 ++++++++++++++ kitchen.yml | 65 +++++++++++++++++++++++++++ 9 files changed, 213 insertions(+), 160 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .kitchen.windows.yml delete mode 100644 .kitchen.yml delete mode 100644 .travis.yml create mode 100644 .yamllint create mode 100644 kitchen.windows.yml create mode 100644 kitchen.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 452ebb34..9071cbce 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,7 @@ version: 2 updates: -- package-ecosystem: bundler - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 + - package-ecosystem: bundler + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..c2955aa8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,94 @@ +--- +name: Lint & Unit + +"on": + pull_request: + push: + branches: + - main + +jobs: + yamllint: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Run yaml Lint + uses: actionshub/yamllint@main + + chefstyle: + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + ruby: ["3.1"] + name: Chefstyle on Ruby ${{ matrix.ruby }} + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - uses: r7kamura/rubocop-problem-matchers-action@v1 + - run: bundle exec chefstyle + + unit: + name: Unit test on Ruby ${{ matrix.ruby }} + needs: [yamllint, chefstyle] + runs-on: ubuntu-latest + strategy: + matrix: + ruby: ["2.7", "3.0", "3.1"] + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - run: bundle exec rake spec + + integration-windows: + name: Windows ${{matrix.suite}} $${{matrix.os}} + runs-on: windows-latest + needs: unit + strategy: + fail-fast: false + matrix: + suite: [default] + os: [ubuntu-20.04] + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.1" + bundler-cache: true + - run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }} + + integration-linux: + name: Linux ${{matrix.suite}} $${{matrix.os}} + runs-on: windows-latest + needs: unit + strategy: + fail-fast: false + matrix: + suite: [default, context, capabilities, arm64, amd64, inspec] + os: + - amazonlinux-2 + - ubuntu-18.04 + - ubuntu-20.04 + - fedora-latest + - centos-7 + - centos-8 + - oraclelinux-7 + - rockylinux-8 + - debian-9 + - debian-10 + - opensuse-15 + - dockerfile + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.1" + bundler-cache: true + - run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }} diff --git a/.kitchen.windows.yml b/.kitchen.windows.yml deleted file mode 100644 index b58b915d..00000000 --- a/.kitchen.windows.yml +++ /dev/null @@ -1,33 +0,0 @@ -<% # Make sure the local copy of the driver is loaded %> -<% lib = File.expand_path('../lib', __FILE__) %> -<% $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) %> ---- -driver: - name: docker - provision_command: - - powershell -ExecutionPolicy Bypass -NoLogo -Command . { iwr -useb https://omnitruck.chef.io/install.ps1 } ^| iex; install - - powershell -Command $path=$env:Path + ';c:\opscode\chef\embedded\bin'; Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $path - -transport: - name: docker - socket: tcp://localhost:2375 - -provisioner: - name: dummy - -platforms: -- name: windows - driver_config: - image: mcr.microsoft.com/windows/servercore:1809 - platform: windows - -suites: -- name: default -- name: context - driver: - build_context: false -- name: inspec - driver: - provision_command: echo 1 - verifier: - name: inspec diff --git a/.kitchen.yml b/.kitchen.yml deleted file mode 100644 index ab46fa87..00000000 --- a/.kitchen.yml +++ /dev/null @@ -1,65 +0,0 @@ -<% # Make sure the local copy of the driver is loaded %> -<% lib = File.expand_path('../lib', __FILE__) %> -<% $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) %> ---- -driver: - name: docker - provision_command: curl -L https://www.chef.io/chef/install.sh | bash - -transport: - name: docker - -provisioner: - name: dummy - -platforms: -- name: amazonlinux-2 -- name: ubuntu-18.04 -- name: ubuntu-20.04 -- name: fedora-latest - driver: - provision_command: - - yum install libxcrypt-compat -y - - curl -L https://www.chef.io/chef/install.sh | bash -- name: centos-7 -- name: oraclelinux-7 -- name: rockylinux-8 -- name: debian-9 -- name: debian-10 -- name: opensuse-15 - driver: - image: opensuse/leap:15 -- name: dockerfile - driver: - username: dockerfile - password: dockerfile - dockerfile: test/Dockerfile - run_command: /sbin/init - -suites: -- name: default - excludes: [arch, debian-9] -- name: context - excludes: [arch, debian-9] - driver: - build_context: false -- name: capabilities - includes: [debian-10,ubuntu-18.04,ubuntu-20.04] - driver: - provision_command: - - curl -L https://www.chef.io/chef/install.sh | bash - - apt-get install -y net-tools - cap_drop: - - NET_ADMIN -- name: arm64 - excludes: [debian-9] - driver: - docker_platform: linux/arm64 -- name: amd64 - driver: - docker_platform: linux/amd64 -- name: inspec - driver: - provision_command: true - verifier: - name: inspec diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 065c8340..00000000 --- a/.travis.yml +++ /dev/null @@ -1,57 +0,0 @@ -matrix: - include: - - os: linux - rvm: 2.4.9 - dist: xenial - language: ruby - cache: bundler - script: - - bundle exec docker version - - bundle exec kitchen --version - - bundle exec rake spec - - bundle exec kitchen test -d always - - os: linux - rvm: 2.5.7 - dist: xenial - language: ruby - cache: bundler - script: - - bundle exec docker version - - bundle exec kitchen --version - - bundle exec rake spec - - bundle exec kitchen test -d always - - os: linux - rvm: 2.6.5 - dist: xenial - language: ruby - cache: bundler - script: - - bundle exec docker version - - bundle exec kitchen --version - - bundle exec rake spec - - bundle exec kitchen test -d always - - os: windows - language: bash - install: - - choco uninstall ruby - - choco install ruby --version=2.6.5.1 - - export PATH=$(echo "$PATH" | sed -e 's/:\/c\/tools\/ruby27\/bin//') - - export PATH=$PATH:/c/tools/ruby26/bin - - choco install mingw - - choco install msys2 - - ridk.cmd exec pacman -S --noconfirm --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-libxslt - script: - - if [[ $(tasklist | grep "gpg-agent") ]]; then taskkill -IM "gpg-agent.exe" -F; else echo "Process gpg-agent not found. Skipping."; fi - - powershell -ExecutionPolicy Bypass -NoLogo -File docker.ps1 - - export KITCHEN_YAML=.kitchen.windows.yml - - ruby -v - - gem install bundler - - bundle config build.nokogiri --use-system-libraries - - bundle install - - bundle exec docker version - - bundle exec kitchen --version - - bundle exec rake spec - - bundle exec kitchen test -d always - -services: -- docker diff --git a/.yamllint b/.yamllint new file mode 100644 index 00000000..0046b237 --- /dev/null +++ b/.yamllint @@ -0,0 +1,15 @@ +--- +extends: default +rules: + line-length: + max: 256 + level: warning + document-start: disable + braces: + forbid: false + min-spaces-inside: 0 + max-spaces-inside: 1 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + comments: + min-spaces-from-content: 1 diff --git a/kitchen-docker.gemspec b/kitchen-docker.gemspec index 08474a9b..fdfa674f 100644 --- a/kitchen-docker.gemspec +++ b/kitchen-docker.gemspec @@ -32,6 +32,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'fuubar', '~> 2.0' spec.add_development_dependency 'simplecov', '~> 0.9' spec.add_development_dependency 'codecov', '~> 0.0', '>= 0.0.2' + spec.add_development_dependency 'chefstyle' # Integration testing gems. spec.add_development_dependency 'kitchen-inspec', '~> 2.0' diff --git a/kitchen.windows.yml b/kitchen.windows.yml new file mode 100644 index 00000000..ef520bd1 --- /dev/null +++ b/kitchen.windows.yml @@ -0,0 +1,33 @@ +# <% # Make sure the local copy of the driver is loaded %> +# <% lib = File.expand_path('../lib', __FILE__) %> +# <% $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) %> +--- +driver: + name: docker + provision_command: + - powershell -ExecutionPolicy Bypass -NoLogo -Command . { iwr -useb https://omnitruck.chef.io/install.ps1 } ^| iex; install + - powershell -Command $path=$env:Path + ';c:\opscode\chef\embedded\bin'; Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $path + +transport: + name: docker + socket: tcp://localhost:2375 + +provisioner: + name: dummy + +platforms: + - name: windows + driver_config: + image: mcr.microsoft.com/windows/servercore:1809 + platform: windows + +suites: + - name: default + - name: context + driver: + build_context: false + - name: inspec + driver: + provision_command: echo 1 + verifier: + name: inspec diff --git a/kitchen.yml b/kitchen.yml new file mode 100644 index 00000000..f3579dfe --- /dev/null +++ b/kitchen.yml @@ -0,0 +1,65 @@ +# <% # Make sure the local copy of the driver is loaded %> +# <% lib = File.expand_path('../lib', __FILE__) %> +# <% $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) %> +--- +driver: + name: docker + provision_command: curl -L https://www.chef.io/chef/install.sh | bash + +transport: + name: docker + +provisioner: + name: dummy + +platforms: + - name: amazonlinux-2 + - name: ubuntu-18.04 + - name: ubuntu-20.04 + - name: fedora-latest + driver: + provision_command: + - yum install libxcrypt-compat -y + - curl -L https://www.chef.io/chef/install.sh | bash + - name: centos-7 + - name: oraclelinux-7 + - name: rockylinux-8 + - name: debian-9 + - name: debian-10 + - name: opensuse-15 + driver: + image: opensuse/leap:15 + - name: dockerfile + driver: + username: dockerfile + password: dockerfile + dockerfile: test/Dockerfile + run_command: /sbin/init + +suites: + - name: default + excludes: [arch, debian-9] + - name: context + excludes: [arch, debian-9] + driver: + build_context: false + - name: capabilities + includes: [debian-10, ubuntu-18.04, ubuntu-20.04] + driver: + provision_command: + - curl -L https://www.chef.io/chef/install.sh | bash + - apt-get install -y net-tools + cap_drop: + - NET_ADMIN + - name: arm64 + excludes: [debian-9] + driver: + docker_platform: linux/arm64 + - name: amd64 + driver: + docker_platform: linux/amd64 + - name: inspec + driver: + provision_command: true + verifier: + name: inspec