-
Notifications
You must be signed in to change notification settings - Fork 19
Fixes #135 - Add a job to fetch Webcompat Knowldege Base related bugs and store them in BQ #136
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [flake8] | ||
| max-line-length = 88 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| .DS_Store | ||
| *.pyc | ||
| __pycache__/ | ||
| venv/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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} | ||
|
|
||
| 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} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/ | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [pytest] | ||
| testpaths = | ||
| tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
chownat the same time, and then combining all theRUNs together:There was a problem hiding this comment.
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_jobscript based on a template that every job in this repository follows, so it's probably fine to leave it as is.