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

Add support for vpt in sync #313

Merged
merged 16 commits into from
Aug 29, 2021
Merged
Show file tree
Hide file tree
Changes from 10 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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [Existing Automatisation](#existing-automatisation)
- [Merge Conflicts - Milestone 1](#merge-conflicts---milestone-1)
- [Sync GitHub Labels](#sync-github-labels)
- [Configure your module repo](#configure-your-module-repo)
- [Local Setup](#local-setup)
- [Dry Run](#dry-run)
- [Production Setup](#production-setup)
Expand Down Expand Up @@ -183,6 +184,20 @@ renamed to the correct one.

The work for this feature is/was tracked in [issue #131](https://github.com/voxpupuli/vox-pupuli-tasks/issues/131).

## Configure your module repo
> The old list with repos to ignore is still active but will be replaced with the below workflow soon.

Per default VPT does take care of every repo in the voxpupuli group matching `/^puppet-(?!lint)/`.

You can configure VPT on a repository level to override some of the default behavior via the `.sync.yml` file.

Example configuration of the current posibilities:

```yml
vpt:
enabled: false # vpt will ignore this repository completely. default: true
```

## Local Setup

To start the app locally, do the following (assumes that you've ruby, bundler
Expand Down
23 changes: 23 additions & 0 deletions app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ class Repository < ApplicationRecord

##
# Checks if the given Repository name is in our application scope (a module)
#
# The config can be a hash containing a 'enabled' key.
# Only if the key explicitly contains false we skip right away, a missing key does default to true.
def notably?
return false if vpt_config['enabled'] == false

Repository.notably?(name)
end

def self.notably?(name)
/^puppet-(?!lint)/.match?(name) && LEGACY_OR_BROKEN_NOBODY_KNOWS.exclude?(name)
Expand Down Expand Up @@ -175,6 +183,21 @@ def update_pull_requests(only_open: false)
pull_requests.count
end

##
# Within the .sync.yml you can optionally place some vpt config
# If there is some content, we set this in the repo to avoid multiple github requests
# If the file is missing completely, we also remove the config locally.
def update_vpt_config
sync_file = Github.get_file(full_name, '.sync.yml')

if sync_file
content = YAML.safe_load(sync_file)
update(vpt_config: content['vpt'].to_h)
elsif vpt_config.any?
update(vpt_config: {})
end
end

def healty?
repository_statuses.last.checks.values.all?
end
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20210815140513_add_config_to_repository.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddConfigToRepository < ActiveRecord::Migration[6.1]
def change
add_column :repositories, :vpt_config, :json, default: {}
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_07_23_173538) do
ActiveRecord::Schema.define(version: 2021_08_15_140513) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -66,6 +66,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.json "todos", default: {}
t.json "vpt_config", default: {}
t.index ["github_id"], name: "index_repositories_on_github_id", unique: true
t.index ["name"], name: "index_repositories_on_name", unique: true
end
Expand Down