Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate CI to GH Actions #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/criteo-cookbooks-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Criteo Cookbooks CI
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
tags: [ 'v*' ]
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
rspec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- run: bundle exec rubocop --version
- run: bundle exec rubocop
- run: bundle exec foodcritic --version
- run: bundle exec foodcritic . --exclude spec -f any
- run: bundle exec rspec
kitchen:
needs: [rspec]
runs-on: ubuntu-latest
strategy:
matrix:
instance: ['default-centos-7']
steps:
- uses: shimataro/ssh-key-action@v2
with:
key: ${{secrets.AWS_SSH_PRIVATE_KEY}}
known_hosts: unnecessary
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- run: CHEF_LICENSE='accept-no-persist' KITCHEN_LOCAL_YAML=kitchen.yml bundle exec kitchen test ${{ matrix.instance }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_SSH_KEY_ID: ${{ secrets.AWS_SSH_KEY_ID }}
AWS_SUBNET: ${{ secrets.AWS_SUBNET }}
AWS_SECURITY_GROUP: ${{ secrets.AWS_SECURITY_GROUP }}
supermarket:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [kitchen]
steps:
- uses: actions/checkout@v2
- name: Publish to supermarket
uses: afaundez/chef-supermarket-action@8cdbe1cccbe1ecd8685b2ea8f48780135bae7cee
with:
user: criteo
cookbook: librenms
category: Utilities
env:
SUPERMARKET_API_KEY: ${{ secrets.SUPERMARKET_API_KEY }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ bin/*
.kitchen.local.yml

.cookbook_version
Policyfile.lock.json
4 changes: 0 additions & 4 deletions .kitchen_suites.yml

This file was deleted.

12 changes: 3 additions & 9 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# - submit the change in the code_generator

AllCops:
TargetRubyVersion: 2.4

TargetRubyVersion: 2.7

# This requires to alphabetically sort Gem's requirements
Bundler/OrderedGems:
Expand All @@ -17,7 +16,7 @@ Style/FrozenStringLiteralComment:
Enabled: false

### Disable line length constraint
Metrics/LineLength:
Layout/LineLength:
Max: 180
# Because we're not in the 80s anymore.
# Based on data from http://sideeffect.kr/popularconvention#ruby
Expand Down Expand Up @@ -45,7 +44,7 @@ Style/TrailingCommaInHashLiteral:
# }
#
### Align hashes as a table
Layout/AlignHash:
Layout/HashAlignment:
EnforcedColonStyle: table
EnforcedHashRocketStyle: key
# When dealing with long key names, it is easier to read hashes in colon
Expand Down Expand Up @@ -98,11 +97,6 @@ Style/FormatString:
Style/MultilineBlockChain:
Enabled: false

# We ain't serving subseconds requests. Forcing to use tr instead of gsub will
# be annoying without much value
Performance/StringReplacement:
Enabled: false

# We don't write documentation there at the moment
Style/Documentation:
Enabled: false
Expand Down
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

Binary file removed .travis/client.pem.enc
Binary file not shown.
Binary file removed .travis/travis-ci.pem.enc
Binary file not shown.
6 changes: 0 additions & 6 deletions Berksfile

This file was deleted.

9 changes: 4 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
source 'https://rubygems.org'

gem 'berkshelf'
gem 'kitchen-vagrant'
gem 'chefspec'
gem 'rake'
gem 'foodcritic'
gem 'chef-zero-scheduled-task'
gem 'chef'
gem 'chef', '= 14.7.17'
gem 'chef-dk'

gem 'kitchen-transport-speedy'
group :ec2 do
gem 'test-kitchen'
gem 'kitchen-ec2', git: 'https://github.com/criteo-forks/kitchen-ec2.git', branch: 'criteo'
gem 'kitchen-ec2'
gem 'winrm', '>= 1.6'
gem 'winrm-fs', '>= 0.3'
gem 'dotenv'
end

# Other gems should go after this comment
gem 'rubocop', '=0.61.1'
gem 'rubocop', '=1.29.1'
6 changes: 6 additions & 0 deletions Policyfile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name 'librenms'

run_list ['librenms']

default_source :community
cookbook 'librenms', path: '.'
3 changes: 1 addition & 2 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

default['mariadb']['database']['name'] = 'librenms'
default['mariadb']['user_librenms']['username'] = 'librenms'
default['mariadb']['user_librenms']['password'] = 'default'
Expand Down Expand Up @@ -31,7 +30,7 @@
default['librenms']['env']['DB_DATABASE'] = node['mariadb']['database']['name']
default['librenms']['env']['DB_USERNAME'] = node['mariadb']['user_librenms']['username']
default['librenms']['env']['DB_PASSWORD'] = node['mariadb']['user_librenms']['password']
default['librenms']['env']['APP_URL'] = 'http://' + node['librenms']['web']['name'] + '/'
default['librenms']['env']['APP_URL'] = "http://#{node['librenms']['web']['name']}/"

# snmpd
default['librenms']['snmp']['community'] = 'public'
Expand Down
2 changes: 1 addition & 1 deletion chefignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ Procfile
.rubocop.yml
spec/*
Rakefile
.travis.yml
.foodcritic
.codeclimate.yml
.github

# SCM #
#######
Expand Down
11 changes: 10 additions & 1 deletion .kitchen.ec2.yml → kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ driver:
volume_type: gp2
delete_on_termination: true

provisioner:
name: chef_zero
install_strategy: always
chef_license: accept
product_name: chef

transport:
ssh_key: <%= ENV['HOME'] %>/.ssh/id_rsa

Expand All @@ -39,4 +45,7 @@ platforms:
image_id: ami-d2c924b2

suites:
<%= require 'erubis'; Erubis::Eruby.new(File.read('.kitchen_suites.yml')).evaluate %>
- name: default
run_list:
- recipe[librenms::default]
attributes:
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
maintainer_email '[email protected]'
license 'Apache-2.0'
description 'Installs/Configures librenms'
long_description 'This cookbook installs and configure LibreNMS along with the required components (Apache and MySQL). LibreNMS is an autodiscovering PHP/MySQL-based network monitoring system.'
long_description 'Installs and configures LibreNMS along with the required components (Apache and MySQL). LibreNMS is an autodiscovering PHP/MySQL-based network monitoring system.'
issues_url 'https://github.com/criteo-cookbooks/librenms/issues'
source_url 'https://github.com/criteo-cookbooks/librenms'
version '0.2.29'
Expand Down
4 changes: 2 additions & 2 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@
# enforce right permissions

facl dir do
group :'' => 'rwx'
default :group => { :'' => 'rwx' }
group '': 'rwx'
default group: { '': 'rwx' }
recurse true
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require 'chefspec'
require 'chefspec/berkshelf'
require 'chefspec/policyfile'