Skip to content

Commit 8c8f0e7

Browse files
Merge pull request #1 from mozilla/init_jbi
Building out some of the structure for the configuration and action logic.
2 parents 7145f1a + 6ff1b53 commit 8c8f0e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2996
-0
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*.py @mozilla/jbi-reviewers

.github/workflows/build-image.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build Docker image
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
prepare:
7+
runs-on: ubuntu-latest
8+
outputs:
9+
FULL_IMAGE_TAG: ${{ steps.tag.outputs.tag }}
10+
steps:
11+
- name: Set Tag
12+
id: tag
13+
run: |
14+
export CI_COMMIT_SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-8)
15+
echo $CI_COMMIT_SHORT_SHA;
16+
echo ${GITHUB_REF##*/};
17+
echo $version_pattern;
18+
if [[ ${GITHUB_REF} =~ $version_pattern ]]; then
19+
echo "::set-output name=tag::${GITHUB_REF##*/}"
20+
elif [ ${GITHUB_REF##*/} = "main" ]; then
21+
echo "::set-output name=tag::stg-$CI_COMMIT_SHORT_SHA"
22+
else
23+
echo "::set-output name=tag::$CI_COMMIT_SHORT_SHA"
24+
fi
25+
env:
26+
version_pattern: "tags\\/v[0-9]+\\.[0-9]+\\.[0-9]+"
27+
28+
29+
build-image:
30+
runs-on: ubuntu-latest
31+
needs: prepare
32+
33+
steps:
34+
- name: Echo tag
35+
id: echotag
36+
env:
37+
IMAGE_TAG: ${{ needs.prepare.outputs.FULL_IMAGE_TAG }}
38+
run: |
39+
echo "Building an image with the following tag:"
40+
echo $IMAGE_TAG
41+
- name: Checkout
42+
uses: actions/checkout@v2
43+
44+
# - name: Configure AWS Credentials
45+
# uses: aws-actions/configure-aws-credentials@v1
46+
# id: configure-aws-creds
47+
# env:
48+
# AWS_REGION: us-west-2
49+
# with:
50+
# aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
51+
# aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
52+
# aws-region: ${{ env.AWS_REGION }}
53+
#
54+
# - name: Login to Amazon ECR
55+
# id: login-ecr
56+
# uses: aws-actions/amazon-ecr-login@v1
57+
#
58+
# - name: Build and push to ECR
59+
# id: build-push
60+
# env:
61+
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
62+
# ECR_REPOSITORY: jira-bugzilla-integration
63+
# IMAGE_TAG: ${{ needs.prepare.outputs.FULL_IMAGE_TAG }}
64+
# run: |
65+
# printf '{\n "commit": "%s",\n "version": "%s",\n "image_tag": "%s",\n "source": "%s",\n "build": "%s"\n}\n' \
66+
# "$GITHUB_SHA" \
67+
# "$GITHUB_REF" \
68+
# "$IMAGE_TAG" \
69+
# "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
70+
# "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" > ./version.json
71+
# docker build --file infra/Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
72+
# docker image tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
73+
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
74+
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
75+
# - name: Logut of Amazon ECR
76+
# if: always()
77+
# run: |
78+
# docker logout ${{ steps.login-ecr.outputs.registry }}

.github/workflows/test-build.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Run tests
2+
3+
on: pull_request
4+
5+
jobs:
6+
run_test:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v2
12+
13+
- name: Build test image
14+
uses: docker/build-push-action@v2
15+
with:
16+
context: .
17+
file: infra/Dockerfile
18+
push: false
19+
target: "test"
20+
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
21+
22+
- name: Run tests
23+
run: |-
24+
docker run --rm \
25+
-e JIRA_USERNAME \
26+
-e JIRA_PASSWORD \
27+
-e BUGZILLA_API_KEY \
28+
ghcr.io/${{ github.repository }}:${{ github.sha }}
29+
env:
30+
JIRA_USERNAME: "fake_username"
31+
JIRA_PASSWORD: "fake_password"
32+
BUGZILLA_API_KEY: "fake_api_key"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# iSort - Pre-Commit
132+
.isort.cfg

.pre-commit-config.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: pylint
5+
name: pylint
6+
entry: poetry run pylint
7+
language: system
8+
exclude: ^migrations/
9+
types: [python]
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v2.1.0
12+
hooks:
13+
- id: check-added-large-files
14+
- id: check-json
15+
- id: detect-private-key
16+
- id: end-of-file-fixer
17+
- id: pretty-format-json
18+
args: [
19+
'--autofix',
20+
'--indent', '4',
21+
'--no-sort-keys',
22+
]
23+
- id: trailing-whitespace
24+
- repo: local
25+
hooks:
26+
- id: mypy
27+
name: mypy
28+
entry: poetry run mypy
29+
language: system
30+
types: [python]
31+
- repo: local
32+
hooks:
33+
- id: bandit
34+
name: bandit
35+
entry: poetry run bandit
36+
args: [-lll, --recursive]
37+
language: system
38+
- repo: local
39+
hooks:
40+
- id: detect-secrets
41+
name: detect-secrets
42+
entry: poetry run detect-secrets-hook
43+
args: ['--baseline', '.secrets.baseline']
44+
exclude: "poetry.lock"
45+
language: system
46+
- repo: https://github.com/asottile/seed-isort-config
47+
rev: v1.9.3
48+
hooks:
49+
- id: seed-isort-config
50+
- repo: local
51+
hooks:
52+
- id: isort
53+
name: isort
54+
entry: poetry run isort
55+
args: ["--recursive", "--settings-path", "./pyproject.toml", "."]
56+
language: system
57+
types: [python]
58+
- repo: local
59+
hooks:
60+
- id: black
61+
name: black
62+
entry: poetry run black
63+
types: [python]
64+
language: system
65+
- repo: local
66+
hooks:
67+
- id: yamllint
68+
name: yamllint
69+
entry: poetry run yamllint
70+
args: ["-c", ".yamllint", 'config/']
71+
types: [file, yaml]
72+
language: system

.secrets.baseline

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"custom_plugin_paths": [],
3+
"exclude": {
4+
"files": null,
5+
"lines": null
6+
},
7+
"generated_at": "2022-02-04T19:26:47Z",
8+
"plugins_used": [
9+
{
10+
"name": "AWSKeyDetector"
11+
},
12+
{
13+
"name": "ArtifactoryDetector"
14+
},
15+
{
16+
"base64_limit": 4.5,
17+
"name": "Base64HighEntropyString"
18+
},
19+
{
20+
"name": "BasicAuthDetector"
21+
},
22+
{
23+
"name": "CloudantDetector"
24+
},
25+
{
26+
"hex_limit": 3,
27+
"name": "HexHighEntropyString"
28+
},
29+
{
30+
"name": "IbmCloudIamDetector"
31+
},
32+
{
33+
"name": "IbmCosHmacDetector"
34+
},
35+
{
36+
"name": "JwtTokenDetector"
37+
},
38+
{
39+
"keyword_exclude": null,
40+
"name": "KeywordDetector"
41+
},
42+
{
43+
"name": "MailchimpDetector"
44+
},
45+
{
46+
"name": "PrivateKeyDetector"
47+
},
48+
{
49+
"name": "SlackDetector"
50+
},
51+
{
52+
"name": "SoftlayerDetector"
53+
},
54+
{
55+
"name": "StripeDetector"
56+
},
57+
{
58+
"name": "TwilioKeyDetector"
59+
}
60+
],
61+
"results": {
62+
"poetry.lock": [
63+
{
64+
"hashed_secret": "a3c8e175e20ee103a0aafa92378200de0583c54b",
65+
"is_verified": false,
66+
"line_number": 542,
67+
"type": "Hex High Entropy String"
68+
}
69+
]
70+
},
71+
"version": "0.14.3",
72+
"word_list": {
73+
"file": null,
74+
"hash": null
75+
}
76+
}

.yamllint

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
3+
extends: default
4+
5+
ignore: |
6+
src/
7+
tests/
8+
infra/
9+
.github/
10+
docker-compose.yaml
11+
.pre-commit-config.yaml
12+
13+
14+
rules:
15+
key-duplicates: enable
16+
key-ordering: enable
17+
18+
19+
yaml-files:
20+
- 'config/*.yaml'
21+
- '.yamllint'

Makefile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Set these in the environment to override them. This is helpful for
2+
# development if you have file ownership problems because the user
3+
# in the container doesn't match the user on your host.
4+
_UID ?= 10001
5+
_GID ?= 10001
6+
7+
.PHONY: help
8+
help:
9+
@echo "Usage: make RULE"
10+
@echo ""
11+
@echo "JBI make rules:"
12+
@echo ""
13+
@echo " build - build docker containers"
14+
@echo " lint - lint check for code"
15+
@echo " start - run the API service"
16+
@echo ""
17+
@echo " test - run test suite"
18+
@echo " shell - open a shell in the web container"
19+
@echo " test-shell - open a shell in test environment"
20+
@echo ""
21+
@echo " generate - create json file from TEMPLATE"
22+
@echo ""
23+
@echo " help - see this text"
24+
25+
26+
.PHONY: build
27+
build:
28+
docker-compose -f ./docker-compose.yaml -f ./tests/infra/docker-compose.test.yaml build \
29+
--build-arg userid=${_UID} --build-arg groupid=${_GID}
30+
31+
.PHONY: lint
32+
lint:
33+
docker-compose -f ./docker-compose.yaml -f ./tests/infra/docker-compose.lint.yaml build \
34+
--build-arg userid=${_UID} --build-arg groupid=${_GID} lint
35+
36+
37+
.PHONY: shell
38+
shell:
39+
docker-compose -f ./docker-compose.yaml run web
40+
41+
.PHONY: start
42+
start:
43+
docker-compose up
44+
45+
.PHONY: test
46+
test:
47+
docker-compose -f ./docker-compose.yaml -f ./tests/infra/docker-compose.test.yaml run tests
48+
ifneq (1, ${MK_KEEP_DOCKER_UP})
49+
# Due to https://github.com/docker/compose/issues/2791 we have to explicitly
50+
# rm all running containers
51+
docker-compose down
52+
endif
53+
54+
.PHONY: test-shell
55+
test-shell:
56+
docker-compose -f ./docker-compose.yaml -f ./tests/infra/docker-compose.test.yaml run web

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
# Jira Bugzilla Integration (JBI)
22
System to sync bugs and issues
3+
4+
## Self-Service
5+
6+
If you're interested in using the default action;
7+
the process is simple to enabling a new downstream
8+
project. [...read more here.](src/jbi/whiteboard_tags/README.md)
9+
10+
If you're looking for a unique capability for your
11+
team's data flow; you can add your own python methods
12+
and functionality. [...read more here.](src/jbi/whiteboard_actions/README.md)

config/config.dev.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
3+
# Action Config
4+
actions:
5+
devtest:
6+
contact: tbd
7+
description: DevTest whiteboard tag
8+
parameters:
9+
jira_project_key: OSS
10+
whiteboard_tag: devtest

0 commit comments

Comments
 (0)