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
30 changes: 30 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,22 @@ jobs:
command: docker run app:build pytest


build-job-webcompat-kb:
docker:
- image: << pipeline.parameters.git-image >>
steps:
- checkout
- compare-branch:
pattern: ^jobs/webcompat-kb/
- setup_remote_docker:
version: << pipeline.parameters.docker-version >>
- run:
name: Build Docker image
command: docker build -t app:build jobs/webcompat-kb/
- run:
name: Test Code
command: docker run app:build pytest --flake8 --black

workflows:
docker-etl:
jobs:
Expand Down Expand Up @@ -475,3 +491,17 @@ workflows:
branches:
only: main


job-webcompat-kb:
jobs:
- build-job-webcompat-kb
- gcp-gcr/build-and-push-image:
context: data-eng-airflow-gcr
docker-context: jobs/webcompat-kb/
path: jobs/webcompat-kb/
image: webcompat-kb_docker_etl
requires:
- build-job-webcompat-kb
filters:
branches:
only: main
7 changes: 7 additions & 0 deletions jobs/webcompat-kb/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.ci_job.yaml
.ci_workflow.yaml
.DS_Store
*.pyc
.pytest_cache/
__pycache__/
venv/
2 changes: 2 additions & 0 deletions jobs/webcompat-kb/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 88
4 changes: 4 additions & 0 deletions jobs/webcompat-kb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
*.pyc
__pycache__/
venv/
26 changes: 26 additions & 0 deletions jobs/webcompat-kb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.8
MAINTAINER <kberezina@mozilla.com>

# https://github.com/mozilla-services/Dockerflow/blob/master/docs/building-container.md
ARG USER_ID="10001"
ARG GROUP_ID="app"
ARG HOME="/app"

ENV HOME=${HOME}
RUN groupadd --gid ${USER_ID} ${GROUP_ID} && \
useradd --create-home --uid ${USER_ID} --gid ${GROUP_ID} --home-dir ${HOME} ${GROUP_ID}

WORKDIR ${HOME}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only a minor nit, but it's generally a good idea to reduce the number of layers for container images. While it doesn't matter much here as the images don't get pushed to a registry, it's probably not a bad idea to take care of that.

You can reduce the images quite a bit by changing the user first, then copy'ing all the files while doing a chown at the same time, and then combining all the RUNs together:

WORKDIR ${HOME}
USER ${USER_ID}

COPY --chown=${USER_ID}:${GROUP_ID} . .

RUN pip install --upgrade pip && \
    pip install -r requirements.txt && \
    pip install .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't modified this file since it was generated by create_job script based on a template that every job in this repository follows, so it's probably fine to leave it as is.


RUN pip install --upgrade pip

COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

COPY . .

RUN pip install .

# Drop root and change ownership of the application folder to the user
RUN chown -R ${USER_ID}:${GROUP_ID} ${HOME}
USER ${USER_ID}
47 changes: 47 additions & 0 deletions jobs/webcompat-kb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Web compatibility Knowledge Base bugs import from bugzilla

This job fetches bugzilla bugs from Web Compatibility > Knowledge Base component,
as well as their core bugs dependencies and breakage reports and puts them into BQ.

## Usage

This script is intended to be run in a docker container.
Build the docker image with:

```sh
docker build -t webcompat-kb .
```

To run locally, first install dependencies in `jobs/webcompat-kb`:

```sh
pip install -r requirements.txt
```

And then run the script after authentication with gcloud:

```sh
gcloud auth application-default login
python3 webcompat_kb/main.py --bq_project_id=<your_project_id> --bq_dataset_id=<your_dataset_id>
```

## Development

Run tests with:

```sh
pytest
```

`flake8` and `black` are included for code linting and formatting:

```sh
pytest --black --flake8
```

or

```sh
flake8 webcompat_kb/ tests/
black --diff webcompat_kb/ tests/
```
15 changes: 15 additions & 0 deletions jobs/webcompat-kb/ci_job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
build-job-webcompat-kb:
docker:
- image: << pipeline.parameters.git-image >>
steps:
- checkout
- compare-branch:
pattern: ^jobs/webcompat-kb/
- setup_remote_docker:
version: << pipeline.parameters.docker-version >>
- run:
name: Build Docker image
command: docker build -t app:build jobs/webcompat-kb/
- run:
name: Test Code
command: docker run app:build pytest --flake8 --black
13 changes: 13 additions & 0 deletions jobs/webcompat-kb/ci_workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
job-webcompat-kb:
jobs:
- build-job-webcompat-kb
- gcp-gcr/build-and-push-image:
context: data-eng-airflow-gcr
docker-context: jobs/webcompat-kb/
path: jobs/webcompat-kb/
image: webcompat-kb_docker_etl
requires:
- build-job-webcompat-kb
filters:
branches:
only: main
3 changes: 3 additions & 0 deletions jobs/webcompat-kb/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
testpaths =
tests
6 changes: 6 additions & 0 deletions jobs/webcompat-kb/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
click==8.0.4
flake8==3.8.4
google-cloud-bigquery==3.11.4
pytest==6.0.2
pytest-black==0.3.11
pytest-flake8==1.0.6
15 changes: 15 additions & 0 deletions jobs/webcompat-kb/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python

from setuptools import setup, find_packages

readme = open("README.md").read()

setup(
name="webcompat-kb",
version="0.1.0",
author="Mozilla Corporation",
packages=find_packages(include=["webcompat_kb"]),
long_description=readme,
include_package_data=True,
license="MPL 2.0",
)
Empty file.
Loading