Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vpereira committed Mar 26, 2020
0 parents commit 3f036c5
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.bundle
vendor
config.yml
.oscrc
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM opensuse/tumbleweed

RUN zypper --non-interactive --quiet ref \
&& zypper -n in osc ruby2.6 ruby2.6-devel git gcc make autoconf zlib-devel libxml2-devel libxslt-devel
RUN gem install bundler
RUN bundle.ruby2.6 config build.nokogiri --use-system-libraries
COPY . /home/puller/pull_request_package
RUN cd /home/puller/pull_request_package && bundler.ruby2.6 install

RUN useradd -ms /bin/bash puller

RUN mkdir -p /home/puller/.config/osc/
COPY oscrc /home/puller/.config/osc/oscrc
RUN chown -R puller:users /home/puller/

USER puller

WORKDIR /home/puller/pull_request_package

ENTRYPOINT ["./entrypoint.sh"]
CMD ["./runner.rb", "-f", "config/config.yml"]
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'slop'
gem 'pull_request_builder', github: 'vpereira/pull_request_builder'
58 changes: 58 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
GIT
remote: https://github.com/vpereira/pull_request_builder
revision: b2b1c99e384f74e705238dfff84b9e15a58337c0
specs:
pull_request_builder (0.1.0)
activemodel (~> 5.2)
cheetah (~> 0.5.0)
nokogiri (~> 1.10)
octokit (~> 4.9)

GEM
remote: https://rubygems.org/
specs:
abstract_method (1.2.1)
activemodel (5.2.2.1)
activesupport (= 5.2.2.1)
activesupport (5.2.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
cheetah (0.5.0)
abstract_method (~> 1.2)
concurrent-ruby (1.1.5)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
mini_portile2 (2.4.0)
minitest (5.11.3)
multipart-post (2.0.0)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
nokogiri (1.10.1-java)
octokit (4.13.0)
sawyer (~> 0.8.0, >= 0.5.3)
public_suffix (3.0.3)
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
slop (4.6.2)
thread_safe (0.3.6)
thread_safe (0.3.6-java)
tzinfo (1.2.5)
thread_safe (~> 0.1)

PLATFORMS
java
ruby

DEPENDENCIES
pull_request_builder!
slop

BUNDLED WITH
1.16.6
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
buid:
docker build -t pull_request_package .

run:
docker run --restart always -v $(PWD):/home/puller/pull_request_package -e RUN_EVERY=600 -d pull_request_package
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Build Git(hub) pull requests on openSUSE BuildService (https://build.opensuse.org/)

How to run it:

### Development

I normally have the openSUSE [BuildService](https://github.com/openSUSE/open-build-service/wiki/Development-Environment-Tips-&-Tricks) locally running and then I can configure it together with a ```config.yml```

then I call:

```
docker build -t $USER/pull_request_package .
```

and then

```
docker run --network="open-build-service_default" -v $PWD:/home/puller/pull_request_package --rm -ti $USER/pull_request_package -e RUN_EVERY=360
```

if you want to run multiple instances in parallel, just map the new config file
to ```config/config.yml``` inside the container, i.e:

```
docker run -v $(PWD):/home/puller/pull_request_package -v $PWD/other-config.yml:$PWD/config/config.yml -e RUN_EVERY=60--rm -ti $USER/pull_request_package
```

if you need to pass an existing osc config to your container do something
similar with:

```
docker run -v /home/vpereira/.config/osc/oscrc:/home/puller/.config/osc/oscrc -v $(PWD):/home/puller/pull_request_package -e RUN_EVERY=600 --rm -ti $USER/pull_request_package
```

### Production

- First generate the config file
- Run ```make build``` to build the docker container
- Run ```make run``` to start the container as a service


## The config.yml file syntax:

```
# generate and customize your token here
# https://github.com/settings/tokens
#
# The only necessary rights are to update Mrepo:status
:credentials:
:access_token: my-oath-tokens
:logging: false
:build_server: https://build.opensuse.org
:build_server_project_integration_prefix: OBS:Server:Unstable:TestGithub:PR
:build_server_project: OBS:Server:Unstable
:build_server_package_name: obs-server
:git_repository: openSUSE/open-buildservice
:git_server: https://github.com/
:git_branch: master
```
3 changes: 3 additions & 0 deletions config/config.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:credentials:
:login: username
:password: mypassword
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

while true; do
exec "$@"
sleep $RUN_EVERY
done
6 changes: 6 additions & 0 deletions oscrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[general]
apiurl = http://frontend:3000

[http://frontend:3000]
user = Admin
pass = opensuse
15 changes: 15 additions & 0 deletions runner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'rubygems'
require "bundler"
Bundler.require(:default)

opts = Slop.parse do |o|
o.string '-f', '--filename', 'configuration file to be used', required: true
end


pull_request_builder_config = YAML.load_file(opts[:filename])
fetcher = PullRequestBuilder::GithubPullRequestFetcher.new(pull_request_builder_config)
fetcher.pull
fetcher.delete

0 comments on commit 3f036c5

Please sign in to comment.