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

[Dockerfile.test] explicitly COPY .git/ #2

Open
wants to merge 21 commits into
base: github-app
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ __pycache__/
# Editors and IDEs
.idea/
.vscode/
.DS_Store

dump.rdb


11 changes: 0 additions & 11 deletions .s2i-dev/bin/assemble

This file was deleted.

20 changes: 0 additions & 20 deletions .s2i-dev/bin/run

This file was deleted.

10 changes: 0 additions & 10 deletions .s2i-dev/bin/usage

This file was deleted.

11 changes: 0 additions & 11 deletions .s2i/bin/assemble

This file was deleted.

20 changes: 0 additions & 20 deletions .s2i/bin/run

This file was deleted.

10 changes: 0 additions & 10 deletions .s2i/bin/usage

This file was deleted.

49 changes: 18 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
FROM registry.fedoraproject.org/fedora:30

EXPOSE 8080
ENV LANG=en_US.UTF-8 \
ANSIBLE_STDOUT_CALLBACK=debug \
USER=release-bot \
HOME=/home/release-bot

ENV STI_SCRIPTS_URL=image:///usr/libexec/s2i \
STI_SCRIPTS_PATH=/usr/libexec/s2i \
# The $HOME is not set by default, but some applications needs this variable
HOME=/opt/app-root/src \
PATH=/opt/app-root/src/bin:/opt/app-root/bin:/opt/app-root/src/.local/bin:$PATH
# Ansible doesn't like /tmp
COPY files/ /src/files/

LABEL summary="Automated releasing from GitHub repositories" \
name="release-bot" \
description="Automated releasing from GitHub repositories" \
io.k8s.description="Automated releasing from GitHub repositories" \
io.k8s.display-name="Release Bot" \
io.openshift.tags="builder" \
io.openshift.s2i.scripts-url="$STI_SCRIPTS_URL" \
usage="s2i build <CONFIGURATION-REPOSITORY> usercont/release-bot <APP-NAME>"
# Install packages first and reuse the cache as much as possible
RUN dnf install -y ansible \
&& cd /src/ \
&& ansible-playbook -vv -c local -i localhost, files/install-rpm-packages.yaml \
&& dnf clean all

RUN dnf install -y git nss_wrapper
COPY setup.py setup.cfg files/recipe.yaml /src/
# setuptools-scm
COPY .git/ /src/.git/
COPY release_bot/ /src/release_bot/

RUN mkdir -p ${HOME} && \
useradd -u 1001 -r -g 0 -d ${HOME} -s /sbin/nologin \
-c "Default Application User" default && \
chown -R 1001:0 /opt/app-root
RUN cd /src/ \
&& ansible-playbook -vv -c local -i localhost, files/recipe.yaml

USER 1001

RUN pip3 install --user release-bot && \
chgrp -R 0 /opt/app-root && \
chmod -R g=u /opt/app-root

# S2I scripts
COPY ./.s2i/bin/ $STI_SCRIPTS_PATH

WORKDIR $HOME

CMD $STI_SCRIPTS_PATH/usage
CMD ["/usr/bin/run.sh"]
39 changes: 0 additions & 39 deletions Dockerfile.dev

This file was deleted.

16 changes: 8 additions & 8 deletions Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ RUN useradd -u 1000 -d ${HOME} test-user

WORKDIR ${HOME}

COPY requirements.txt ${HOME}/
COPY tests/requirements.txt ${HOME}/tests/
RUN pip3 install -r requirements.txt -r tests/requirements.txt

COPY Makefile ${HOME}/

COPY ./tests/ ${HOME}/tests/
COPY tests/requirements.txt ${HOME}/tests/
RUN pip3 install -r tests/requirements.txt
COPY tests/ ${HOME}/tests/
RUN chown -R 1000 ${HOME}

COPY . /tmp/tmp/
RUN cd /tmp/tmp/ && pip3 install . && rm -rf /tmp/tmp/
COPY setup.py setup.cfg /src/
# setuptools-scm
COPY .git/ /src/.git/
COPY release_bot/ /src/release_bot/
RUN cd /src/ && pip3 install . && rm -rf /src/

USER 1000

Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ node('userspace-containerization'){

stage ("setup"){
onmyduffynode "yum -y install docker make"
synctoduffynode "*" // copy all source files
synctoduffynode "./." // copy all source files (hidden too, we need .git/)
onmyduffynode "systemctl start docker"
}

Expand Down
13 changes: 3 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
.PHONY: test

IMAGE_NAME := usercont/release-bot
IMAGE_NAME_DEV := usercont/release-bot:dev
IMAGE_NAME := usercont/release-bot:dev
TEST_IMAGE_NAME := release-bot-tests

image:
docker build --tag=$(IMAGE_NAME) .

image-dev:
docker build --tag=$(IMAGE_NAME_DEV) -f Dockerfile.dev .

image-dev-no-cache:
docker build --no-cache --tag=$(IMAGE_NAME_DEV) -f Dockerfile.dev .
image: files/install-rpm-packages.yaml files/recipe.yaml
docker build --rm -f Dockerfile --tag=$(IMAGE_NAME) .

image-test:
docker build --tag=$(TEST_IMAGE_NAME) -f Dockerfile.test .
Expand Down
59 changes: 4 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ Note that you have to setup your login details (see [Requirements](#requirements
```
$ pip install release-bot
```
Other possible installations are through
[Docker](#docker-image), [OpenShift](#openshift-template), [Arch User Repository](#arch-user-repository).
Other possible installations are through [Arch User Repository](#arch-user-repository) or install on repo as [Github Application](#github-application).

First interaction with release bot may be automated releases on Github. Let's do it.

Expand Down Expand Up @@ -187,60 +186,10 @@ Are specified in `requirements.txt`.
You have to setup your PyPI login details in `$HOME/.pypirc` as described in
[PyPI documentation](https://packaging.python.org/tutorials/distributing-packages/#create-an-account).

## Docker image
To make it easier to run this, release-bot is available as an
[source-to-image](https://github.com/openshift/source-to-image) builder image.
## Github Application

You can then create the final image like this:
```
$ s2i build $CONFIGURATION_REPOSITORY_URL usercont/release-bot app-name
```

where $CONFIGURATION_REPOSITORY_URL is link to repository with conf.yaml and .pypirc files.

To test it locally, you can the run the final image like this:

```
$ docker run <app-name>
```

once all changes, configuration files exist in GitHub and git repository contains needed files,
you can try to create an issue in your GitHub repository with string like "X.Y.Z release"
and you can see log like this:
```
$ docker run meta-test-family-bot
---> Setting up ssh key...
Agent pid 12
Identity added: ./.ssh/id_rsa (./.ssh/id_rsa)
11:47:36.212 configuration.py DEBUG Loaded configuration for fedora-modularity/meta-test-family
11:47:36.212 releasebot.py INFO release-bot v0.4.1 reporting for duty!
11:47:36.212 github.py DEBUG Fetching release-conf.yaml
11:47:51.636 releasebot.py DEBUG No merged release PR found
11:47:52.196 releasebot.py INFO Found new release issue with version: 0.8.4
11:47:55.578 releasebot.py DEBUG No more open issues found
11:47:56.098 releasebot.py INFO Making a new PR for release of version 0.8.5 based on an issue.
11:47:57.608 utils.py DEBUG ['git', 'clone', 'https://github.com/fedora-modularity/meta-test-family.git', '.']
...
```
## OpenShift template
You can also run this bot in OpenShift using [openshift-template.yml](openshift-template.yml) in this repository.
You must set two environment variables, the `$APP_NAME` is the name of your release-bot deployment,
and `$CONFIGURATION_REPOSITORY` which contains configuration for the release-bot.
The contents of the repository are described [above](#docker-image).
Note that if you use private repository (which you **absolutely** should),
you will need to set up a new [OpenShift secret](https://docs.openshift.com/container-platform/3.7/dev_guide/secrets.html) named
`release-bot-secret` to authenticate. It can be a ssh private key that you can use to access the repository
(for GitHub see [deploy keys](https://developer.github.com/v3/guides/managing-deploy-keys/)).
Here's an [guide](https://blog.openshift.com/deploy-private-git-repositories/) on
how to do that in OpenShift GUI, or another
[guide](https://blog.openshift.com/deploying-from-private-git-repositories/)
that uses `oc` commandline tool.

By default, the release-bot builder image won't update itself when a
new version of this image is pushed to docker hub.
You can change it by uncommenting lines with `#importPolicy:`
and `#scheduled: true` in [openshift-template.yml](openshift-template.yml).
Then the image will be pulled on a new release.
Release-bot as Github Application is currently in testing and will be available soon in Github market.
Github application will speed-up configuration process.

## Arch User Repository
For Arch or Arch based Linux distributions, you can install the bot from the [AUR Package](https://aur.archlinux.org/packages/release-bot).
Expand Down
5 changes: 5 additions & 0 deletions files/gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[user]
name = Release Bot
email = [email protected]
[push]
default = current
26 changes: 26 additions & 0 deletions files/install-rpm-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Install dependencies for release-bot
hosts: all
tasks:
- name: Install all RPM packages needed to run release-bot.
dnf:
name:
- python3-flask
- python3-ipdb # for easy debugging
- python3-jsonschema
- python3-ogr
- python3-pip
- python3-pyyaml
- python3-requests
- python3-setuptools
- python3-setuptools_scm
- python3-setuptools_scm_git_archive
- python3-wheel # for bdist_wheel
- python3-celery
- python3-cryptography
- python3-jwt
- python3-pystache
- python3-redis
- python3-semantic_version
- twine
state: present
Loading