Skip to content

Commit 91428c9

Browse files
authored
Discourse API (#3)
* Add discourse client API * Add CI using common github actions workflows
1 parent 014e64d commit 91428c9

25 files changed

+1569
-39
lines changed

.github/workflows/ci.yaml

-19
This file was deleted.

.github/workflows/comment.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Comment on the pull request
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Tests"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
comment-on-pr:
11+
uses: canonical/operator-workflows/.github/workflows/comment.yaml@main
12+
secrets: inherit
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Integration Tests
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
integration-tests:
8+
uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main
9+
secrets: inherit
10+
with:
11+
pre-run-script: tests/integration/pre_run.sh

.github/workflows/on_pull_request.yaml

-9
This file was deleted.

.github/workflows/test.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
unit-tests:
8+
uses: canonical/operator-workflows/.github/workflows/test.yaml@main
9+
secrets: inherit

.woke.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
rules:
2+
# Ignore "master" - discourse uses this as the rake action to generate the
3+
# main API key for server interactions.
4+
- name: master

CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @canonical/is-charms

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
FROM python:3-slim AS builder
2-
ADD . /app
2+
COPY . /app
33
WORKDIR /app
44

55
# We are installing a dependency here directly into our app source dir
6-
RUN pip install --target=/app requests
6+
RUN pip install --no-cache-dir requests
77

88
# A distroless container image with Python and some basics like SSL certificates
99
# https://github.com/GoogleContainerTools/distroless

action.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ inputs:
88
docs key in metadata.yaml either does not exist or is empty. Defaults to
99
not creating a new topic in which case an error is returned.
1010
default: false
11+
discourse_host:
12+
description: The discourse host name.
13+
discourse_category_id:
14+
description: The category identifier to use on discourse for all topics.
1115
runs:
1216
using: docker
1317
image: Dockerfile

main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright 2022 Canonical Ltd.
2-
# Licensed under the GPLv3, see LICENCE file for details.
2+
# See LICENSE file for licensing details.
33

44
"""Main execution for the action."""
55

pyproject.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ skips = ["*/*test.py", "*/test_*.py"]
1111
branch = true
1212

1313
[tool.coverage.report]
14-
fail_under = 85
14+
fail_under = 100
1515
show_missing = true
1616

1717

@@ -39,9 +39,12 @@ select = ["E", "W", "F", "C", "N", "R", "D", "H"]
3939
# Ignore D107 Missing docstring in __init__
4040
ignore = ["W503", "E501", "D107"]
4141
# D100, D101, D102, D103: Ignore missing docstrings in tests
42-
per-file-ignores = ["tests/*:D100,D101,D102,D103,D104"]
42+
per-file-ignores = ["tests/*:D100,D101,D102,D103,D104,D205,D212,D415"]
4343
docstring-convention = "google"
4444
# Check for properly formatted copyright header in each file
4545
copyright-check = "True"
4646
copyright-author = "Canonical Ltd."
4747
copyright-regexp = "Copyright\\s\\d{4}([-,]\\d{4})*\\s+%(author)s"
48+
49+
[tool.mypy]
50+
ignore_missing_imports = true

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pydiscourse>=1.3,<1.4

src/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Copyright 2022 Canonical Ltd.
2-
# Licensed under the GPLv3, see LICENCE file for details.
2+
# See LICENSE file for licensing details.
33

44
"""Library for uploading docs to charmhub."""

0 commit comments

Comments
 (0)