Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ This repository contains [docker-compose.yml](./docker-compose.yml) for
Before you run it, we suggest that you open the file and read all the comments.
You can also run only certain pieces of packit-service for local development
(e.g. worker, database or service/httpd).
You also need to populate `secrets/packit/dev/` manually, for instructions
see [deployment repo](https://github.com/packit/deployment/tree/main/secrets).

When you are running service/httpd and making requests to it,
make sure that `server_name` configuration file in `packit-service.yaml` is set.
Expand Down
29 changes: 24 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
BASE_IMAGE ?= quay.io/packit/base
# true|false
PULL_BASE_IMAGE ?= true
SERVICE_IMAGE ?= quay.io/packit/packit-service:dev
WORKER_IMAGE ?= quay.io/packit/packit-worker:dev
TEST_IMAGE ?= quay.io/packit/packit-service-tests:stg
# missing|always|never
PULL_TEST_IMAGE ?= missing
TEST_TARGET ?= ./tests/unit ./tests/integration/
CONTAINER_ENGINE ?= $(shell command -v podman 2> /dev/null || echo docker)
Expand All @@ -16,21 +19,37 @@ COMPOSE ?= docker-compose
MY_ID ?= `id -u`

service: files/install-deps.yaml files/recipe.yaml
$(CONTAINER_ENGINE) pull $(BASE_IMAGE)
$(CONTAINER_ENGINE) build --rm -t $(SERVICE_IMAGE) -f files/docker/Dockerfile --build-arg SOURCE_BRANCH=$(SOURCE_BRANCH) .
$(CONTAINER_ENGINE) build --rm \
--pull=$(PULL_BASE_IMAGE) \
-t $(SERVICE_IMAGE) \
-f files/docker/Dockerfile \
--build-arg SOURCE_BRANCH=$(SOURCE_BRANCH) \
.

worker: files/install-deps-worker.yaml files/recipe-worker.yaml
$(CONTAINER_ENGINE) pull $(BASE_IMAGE)
$(CONTAINER_ENGINE) build --rm -t $(WORKER_IMAGE) -f files/docker/Dockerfile.worker --build-arg SOURCE_BRANCH=$(SOURCE_BRANCH) .
$(CONTAINER_ENGINE) build --rm \
--pull=$(PULL_BASE_IMAGE) \
-t $(WORKER_IMAGE) \
-f files/docker/Dockerfile.worker \
--build-arg SOURCE_BRANCH=$(SOURCE_BRANCH) \
.

check:
find . -name "*.pyc" -exec rm {} \;
PYTHONPATH=$(CURDIR) PYTHONDONTWRITEBYTECODE=1 python3 -m pytest --color=$(COLOR) --verbose --showlocals --cov=packit_service --cov-report=$(COV_REPORT) $(TEST_TARGET)

# In most cases you don't need to build your test-image, the one in registry should be all you need.
build-test-image: files/install-deps-worker.yaml files/install-deps.yaml files/recipe-tests.yaml
$(CONTAINER_ENGINE) build --rm -t $(TEST_IMAGE) -f files/docker/Dockerfile.tests --build-arg SOURCE_BRANCH=$(SOURCE_BRANCH) .
$(CONTAINER_ENGINE) build --rm \
-t $(TEST_IMAGE) \
-f files/docker/Dockerfile.tests \
--build-arg SOURCE_BRANCH=$(SOURCE_BRANCH) \
.

# We use a test image pre-built (by Github action) from latest commit in main.
# The PULL_TEST_IMAGE specifies whether the image is downloaded before running tests in a container.
# Default is 'missing', which means that it's downloaded/updated ONLY if missing.
# Set PULL_TEST_IMAGE=always to pull/update the test image before running tests.
check-in-container:
@# don't use -ti here in CI, TTY is not allocated in zuul
echo $(SOURCE_BRANCH)
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ services:
SOURCE_BRANCH: main
image: quay.io/packit/packit-worker:dev
command: /usr/bin/run_worker.sh
#tty: true
depends_on:
- redis
- postgres
Expand Down
30 changes: 15 additions & 15 deletions files/check-inside-openshift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@
k8s:
host: "{{ oc_server.stdout }}"
api_key: "{{ kubeconfig_token.stdout }}"
validate_certs: no
validate_certs: false
namespace: "{{ oc_project.stdout }}"
resource_definition: "{{ lookup('file', './test-src-pvc.yaml') }}"
- name: Start pod which mounts test-src-pvc to /src
k8s:
host: "{{ oc_server.stdout }}"
api_key: "{{ kubeconfig_token.stdout }}"
validate_certs: no
validate_certs: false
namespace: "{{ oc_project.stdout }}"
resource_definition: "{{ lookup('file', './test-src-mounter.yaml') }}"
- name: Wait for the pod to be running so we can rsync the files
k8s:
host: "{{ oc_server.stdout }}"
api_key: "{{ kubeconfig_token.stdout }}"
validate_certs: no
validate_certs: false
namespace: "{{ oc_project.stdout }}"
name: mount-src
api_version: v1
kind: Pod
wait: yes
wait: true
wait_condition:
type: Ready
wait_timeout: 100
Expand All @@ -54,7 +54,7 @@
k8s:
host: "{{ oc_server.stdout }}"
api_key: "{{ kubeconfig_token.stdout }}"
validate_certs: no
validate_certs: false
namespace: "{{ oc_project.stdout }}"
name: mount-src
api_version: v1
Expand All @@ -65,7 +65,7 @@
k8s:
host: "{{ oc_server.stdout }}"
api_key: "{{ kubeconfig_token.stdout }}"
validate_certs: no
validate_certs: false
namespace: "{{ oc_project.stdout }}"
name: "{{ tests_job_name }}"
api_version: v1
Expand All @@ -75,7 +75,7 @@
k8s:
host: "{{ oc_server.stdout }}"
api_key: "{{ kubeconfig_token.stdout }}"
validate_certs: no
validate_certs: false
namespace: "{{ oc_project.stdout }}"
name: get-requre-data
api_version: v1
Expand All @@ -85,13 +85,13 @@
k8s:
host: "{{ oc_server.stdout }}"
api_key: "{{ kubeconfig_token.stdout }}"
validate_certs: no
validate_certs: false
namespace: "{{ oc_project.stdout }}"
name: test-data-pvc
api_version: v1
kind: PersistentVolumeClaim
state: absent
wait: yes
wait: true
wait_condition:
type: Complete
wait_timeout: 300
Expand All @@ -104,21 +104,21 @@
k8s:
host: "{{ oc_server.stdout }}"
api_key: "{{ kubeconfig_token.stdout }}"
validate_certs: no
validate_certs: false
namespace: "{{ oc_project.stdout }}"
name: "{{ tests_job_name }}"
api_version: v1
kind: Job
wait: yes
wait: true
wait_condition:
type: Complete
wait_timeout: 300
ignore_errors: yes # we want to see logs either way
ignore_errors: true # we want to see logs either way
- name: get test results
k8s_info:
host: "{{ oc_server.stdout }}"
api_key: "{{ kubeconfig_token.stdout }}"
validate_certs: no
validate_certs: false
namespace: "{{ oc_project.stdout }}"
kind: Job
name: "{{ tests_job_name }}"
Expand All @@ -136,12 +136,12 @@
k8s:
host: "{{ oc_server.stdout }}"
api_key: "{{ kubeconfig_token.stdout }}"
validate_certs: no
validate_certs: false
namespace: "{{ oc_project.stdout }}"
name: get-requre-data
api_version: v1
kind: Pod
wait: yes
wait: true
wait_condition:
type: Ready
wait_timeout: 100
Expand Down
3 changes: 3 additions & 0 deletions files/deployment-check.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

---
- name: Check packit-service deployment
hosts: all
Expand Down
7 changes: 5 additions & 2 deletions files/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

---
# This file is the entrypoint to deploy packit-service to an openshift cluster (e.g. in Zuul)
- name: Deploy dev version of packit-service into zuul.
Expand Down Expand Up @@ -33,7 +36,7 @@
git:
repo: "https://github.com/packit/deployment.git"
dest: "{{ deployment_dir }}"
clone: yes
clone: true
when: zuul is not defined

- name: Generate secrets
Expand Down Expand Up @@ -61,7 +64,7 @@
- name: get minishift ip
command: minishift ip
register: minishift_ip
ignore_errors: True
ignore_errors: true

- set_fact:
cluster_ip: "{{ minishift_ip.stdout if not minishift_ip.failed else '127.0.0.1' }}"
Expand Down
3 changes: 3 additions & 0 deletions files/install-deps-worker.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

---
- name: Install dependencies for packit-service worker
hosts: all
Expand Down
4 changes: 3 additions & 1 deletion files/install-deps.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

---
- name: Install dependencies for packit-service
hosts: all
Expand All @@ -14,7 +17,6 @@
# httpd & deps
- python3-mod_wsgi
- mod_ssl
#- python3-packit # temporary workaround for sake of marhsmallow
- python3-pip # not included in base fedora:31 image, needed for next task
# temporary dependencies
- krb5-devel
Expand Down
3 changes: 3 additions & 0 deletions files/recipe-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

---
- name: This is a recipe for a container image where packit-service tests will run
hosts: all
Expand Down
3 changes: 3 additions & 0 deletions files/recipe-worker.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

---
- name: This is a recipe for how to cook with packit-service worker
hosts: all
Expand Down
3 changes: 3 additions & 0 deletions files/recipe.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

---
- name: This is a recipe for how to cook with packit-service
hosts: all
Expand Down
21 changes: 13 additions & 8 deletions files/tasks/common.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
# Tasks common to all images
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

# Tasks common to all images
-
- name: Create /usr/share/packit
file:
ansible.builtin.file:
state: directory
path: /usr/share/packit
mode: 0775
- name: make packit home dir
file:
ansible.builtin.file:
state: directory
path: "{{ home_path }}"
mode: 0776
- name: stat {{ packit_service_path }}
stat:
ansible.builtin.stat:
path: "{{ packit_service_path }}"
tags:
- no-cache
register: src_path
- name: Let's make sure {{ packit_service_path }} is present
assert:
ansible.builtin.assert:
that:
- src_path.stat.isdir
- name: Install packit-service from {{ packit_service_path }}
pip:
ansible.builtin.pip:
name: "{{ packit_service_path }}"
executable: pip3
- name: Clean all the cache files (especially pip)
file:
ansible.builtin.file:
state: absent
path: ~/.cache/
- name: Copy setup_env_in_openshift.sh
copy:
ansible.builtin.copy:
src: setup_env_in_openshift.sh
dest: /usr/bin/setup_env_in_openshift.sh
mode: 0775
4 changes: 2 additions & 2 deletions files/tasks/httpd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# SPDX-License-Identifier: MIT

- name: Copy packit.wsgi file
copy:
ansible.builtin.copy:
src: packit.wsgi
dest: /usr/share/packit/packit.wsgi
mode: 0664
- name: Copy run_httpd.sh
copy:
ansible.builtin.copy:
src: run_httpd.sh
dest: /usr/bin/run_httpd.sh
mode: 0775
15 changes: 10 additions & 5 deletions files/tasks/install-ogr-deps.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

# Install dependencies from setup.cfg as rpm packages for ogr
- name: Download script setupcfg2rpm.py
get_url:
ansible.builtin.get_url:
url: https://raw.githubusercontent.com/packit/deployment/main/scripts/setupcfg2rpm.py
dest: ./setupcfg2rpm.py
mode: "0744"
mode: 0775
register: fetch_setupcfg2rpm
until: fetch_setupcfg2rpm is not failed
retries: 6

- name: Download ogr setup.cfg
get_url:
ansible.builtin.get_url:
# ogr has only main branch
url: https://raw.githubusercontent.com/packit/ogr/main/setup.cfg
dest: ./ogr_setup.cfg
mode: 0664
register: fetch_ogr_setup
until: fetch_ogr_setup is not failed
retries: 6

- name: Install ogr dependencies provided by setupcfg2rpm
shell: dnf install $(./setupcfg2rpm.py ogr_setup.cfg) -y
ansible.builtin.shell: dnf install $(./setupcfg2rpm.py ogr_setup.cfg) -y
args:
warn: no
warn: false
become: true
changed_when: true
Loading