-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update from voxpupuli modulesync_config
- Loading branch information
markuszilch
committed
Aug 23, 2023
1 parent
0969477
commit 7180fb6
Showing
9 changed files
with
191 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: 2 | ||
updates: | ||
# raise PRs for gem updates | ||
- package-ecosystem: bundler | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "13:00" | ||
open-pull-requests-limit: 10 | ||
|
||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "13:00" | ||
open-pull-requests-limit: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == 'voxpupuli' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install Ruby 3.0 | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.0' | ||
bundler: 'none' | ||
env: | ||
BUNDLE_WITHOUT: release:development:rubocop | ||
- name: Build gem | ||
run: gem build --strict --verbose *.gemspec | ||
- name: Publish gem to rubygems.org | ||
run: gem push *.gem | ||
env: | ||
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}' | ||
- name: Setup GitHub packages access | ||
run: | | ||
mkdir -p ~/.gem | ||
echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials | ||
chmod 0600 ~/.gem/credentials | ||
- name: Publish gem to GitHub packages | ||
run: gem push --key github --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: {} | ||
push: | ||
branches: | ||
- master | ||
- main | ||
|
||
env: | ||
BUNDLE_WITHOUT: release | ||
|
||
jobs: | ||
rubocop: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.0' | ||
bundler-cache: true | ||
- name: Run rake rubocop | ||
run: bundle exec rake rubocop | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- ruby: "2.7" | ||
- ruby: "3.0" | ||
- ruby: "3.1" | ||
coverage: "yes" | ||
- ruby: "3.2" | ||
env: | ||
COVERAGE: ${{ matrix.coverage }} | ||
name: Ruby ${{ matrix.ruby }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install Ruby ${{ matrix.ruby }} | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby }} | ||
bundler-cache: true | ||
- name: Run tests | ||
run: bundle exec rake spec | ||
- name: Verify gem builds | ||
run: gem build --strict --verbose *.gemspec | ||
tests: | ||
needs: | ||
- rubocop | ||
- test | ||
runs-on: ubuntu-latest | ||
name: Test suite | ||
steps: | ||
- run: echo Test suite completed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*.gem | ||
*.swp | ||
Gemfile.lock | ||
.bundle/ | ||
/.bundle/ | ||
/vendor/gems/ | ||
/Gemfile.lock | ||
vendor/bundle | ||
.vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
# Managed by modulesync - DO NOT EDIT | ||
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ | ||
|
||
inherit_gem: | ||
voxpupuli-rubocop: rubocop.yml | ||
|
||
Naming/FileName: | ||
Exclude: | ||
- "*.gemspec" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
source ENV['GEM_SOURCE'] || "https://rubygems.org" | ||
source ENV['GEM_SOURCE'] || 'https://rubygems.org' | ||
|
||
gemspec | ||
|
||
group :release do | ||
gem 'faraday-retry', '~> 2.1', require: false | ||
gem 'github_changelog_generator', '~> 1.16.4', require: false | ||
end | ||
|
||
group :coverage, optional: ENV['COVERAGE'] != 'yes' do | ||
gem 'codecov', require: false | ||
gem 'simplecov-console', require: false | ||
end | ||
|
||
group :development do | ||
gem 'rake', '~> 13.0', '>= 13.0.6' | ||
gem 'rspec', '~> 3.12' | ||
gem 'rspec-collection_matchers', '~> 1.2' | ||
gem 'rspec-its', '~> 1.3' | ||
gem 'voxpupuli-rubocop', '~> 2.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task default: :spec | ||
|
||
begin | ||
require 'rspec/core/rake_task' | ||
RSpec::Core::RakeTask.new(:spec) | ||
require 'rubygems' | ||
require 'github_changelog_generator/task' | ||
rescue LoadError | ||
# github-changelog-generator is an optional group | ||
else | ||
GitHubChangelogGenerator::RakeTask.new :changelog do |config| | ||
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file." | ||
config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog modulesync] | ||
config.user = 'voxpupuli' | ||
config.project = 'puppet-ghostbuster' | ||
config.future_release = Gem::Specification.load("#{config.project}.gemspec").version | ||
end | ||
end | ||
|
||
require 'github_changelog_generator/task' | ||
require 'puppet-ghostbuster/version' | ||
GitHubChangelogGenerator::RakeTask.new :changelog do |config| | ||
config.future_release = PuppetGhostbuster::VERSION | ||
config.release_url = "https://rubygems.org/gems/puppet-ghostbuster/versions/%s" | ||
end | ||
begin | ||
require 'rubocop/rake_task' | ||
rescue LoadError | ||
# RuboCop is an optional group | ||
else | ||
RuboCop::RakeTask.new(:rubocop) do |task| | ||
# These make the rubocop experience maybe slightly less terrible | ||
task.options = ['--display-cop-names', '--display-style-guide', '--extra-details'] | ||
|
||
task :default => :spec | ||
# Use Rubocop's Github Actions formatter if possible | ||
task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,29 @@ | ||
require 'puppet-lint' | ||
require 'jgrep' | ||
|
||
PuppetLint::Plugins.load_spec_helper | ||
|
||
class PuppetDB::Client | ||
def puppetdb_to_jgrep(query) | ||
if query[0] == :'and' || query[0] == :'or' | ||
"(#{puppetdb_to_jgrep(query[1])} #{query[0]} #{puppetdb_to_jgrep(query[2])})" | ||
else | ||
"#{[query[1]].flatten.join('.')}#{query[0]}#{query[2]}" | ||
end | ||
end | ||
|
||
def process_pql_kv(q) | ||
k, v = q.split(/\s*=\s*/) | ||
".#{k}=#{v}" | ||
end | ||
|
||
def pql_to_jgrep(query) | ||
endpoint_cols = query.split('{').first | ||
endpoint = endpoint_cols.split(/[\s\[]/).first | ||
query.sub!(/^#{Regexp.quote(endpoint_cols)}\{\s*/, '') | ||
query.sub!(/\s*}\s*/, '') | ||
query.sub!(/(and\s+)?nodes\s*\{\s*deactivated\s+is\s+null\s*\}/, '') | ||
# frozen_string_literal: true | ||
|
||
return endpoint, '' if query == '' | ||
begin | ||
require 'simplecov' | ||
require 'simplecov-console' | ||
require 'codecov' | ||
rescue LoadError | ||
else | ||
SimpleCov.start do | ||
track_files 'lib/**/*.rb' | ||
|
||
query.gsub!('parameters.', 'parameter.') | ||
query.sub!(/\s*=\s*/, '=') | ||
add_filter '/spec' | ||
|
||
jgrep_query_and_parts = [] | ||
query.split(/\s+and\s+/).each do |q| | ||
newq = '' | ||
if q.start_with?('(') | ||
newq << '(' | ||
newq << q.split(/\s+or\s+/).map do |qq| | ||
process_pql_kv(qq.sub(/^\(/, '').sub(/\)$/, '')) | ||
end.join(' or ') | ||
newq << ')' | ||
else | ||
newq << process_pql_kv(q) | ||
end | ||
jgrep_query_and_parts << newq | ||
end | ||
jgrep_query = jgrep_query_and_parts.join(" and ") | ||
jgrep_query.rstrip! | ||
enable_coverage :branch | ||
|
||
return endpoint, jgrep_query | ||
# do not track vendored files | ||
add_filter '/vendor' | ||
add_filter '/.vendor' | ||
end | ||
|
||
def request(endpoint, query, opts={}) | ||
if endpoint == '' | ||
endpoint, query = pql_to_jgrep(query) | ||
else | ||
query = puppetdb_to_jgrep(query) | ||
end | ||
ret = JGrep.jgrep(File.read("spec/fixtures/#{endpoint}.json"), query) | ||
PuppetDB::Response.new(ret, ret.size) | ||
end | ||
SimpleCov.formatters = [ | ||
SimpleCov::Formatter::Console, | ||
SimpleCov::Formatter::Codecov, | ||
] | ||
end | ||
|
||
require 'puppet-lint' | ||
|
||
PuppetLint::Plugins.load_spec_helper |