Skip to content
Open
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
1 change: 0 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ The Deploy Course Action is a composite GitHub Action that automates the deploym
|-------|------|---------|-------------|
| `course-json-path` | string | `course.json` | Path to course configuration file |
| `article-type` | string | `course` | Type of article (`course` or `blog`) |
| `force-duplicate-questions` | string | `false` | Force upload duplicate questions (`true` or `false`) |
| `draft` | string | `false` | Create draft course (`true` or `false`) |

### Outputs
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ jobs:
| `repo-read-token` | GitHub token with read access to the repository | **Yes** | N/A |
| `course-json-path` | Path to `course.json` file | No | `course.json` |
| `article-type` | Type of article to create (`course` or `blog`) | No | `course` |
| `force-duplicate-questions` | Whether to force upload duplicate questions (`true` or `false`) | No | `false` |
| `max-poll-attempts` | Maximum polling attempts before timing out | No | `20` |
| `poll-interval-seconds` | Seconds to wait between polling attempts | No | `15` |
| `max-consecutive-errors` | Maximum consecutive polling errors before failing | No | `5` |
Expand Down
10 changes: 2 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ inputs:
description: 'Type of article (course or blog)'
required: false
default: 'course'
force-duplicate-questions:
description: 'Whether to force duplicate questions'
required: false
default: 'false'
draft:
description: 'Whether to create a draft course (true or false)'
required: false
Expand Down Expand Up @@ -115,8 +111,7 @@ runs:
--repo-read-token '${{ inputs.repo-read-token }}' \
--repo-url '${{ github.server_url }}/${{ github.repository }}' \
--commit-sha '${{ github.sha }}' \
--article-type '${{ inputs.article-type }}' \
--force-duplicate-questions '${{ inputs.force-duplicate-questions }}'
--article-type '${{ inputs.article-type }}'

- name: Stage 5b - Update Course
if: inputs.mode == 'update'
Expand All @@ -129,8 +124,7 @@ runs:
--repo-read-token '${{ inputs.repo-read-token }}' \
--repo-url '${{ github.server_url }}/${{ github.repository }}' \
--commit-sha '${{ github.sha }}' \
--article-type '${{ inputs.article-type }}' \
--force-duplicate-questions '${{ inputs.force-duplicate-questions }}'
--article-type '${{ inputs.article-type }}'

- name: Stage 6 - Poll status end point for completion
id: poll-status
Expand Down
3 changes: 0 additions & 3 deletions examples/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ jobs:

# Optional: Type of article to create (course or blog, defaults to 'course')
article-type: 'course'

# Optional: Whether to force upload duplicate questions (defaults to 'false')
force-duplicate-questions: 'false'

# Optional: Operation mode ('create' or 'update', defaults to 'create')
# Can be dynamic based on workflow inputs or variables
Expand Down
3 changes: 0 additions & 3 deletions examples/test-workflow-unpublished.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ jobs:

# Optional: Type of article to create (course or blog, defaults to 'course')
article-type: 'course'

# Optional: Whether to force upload duplicate questions (defaults to 'false')
force-duplicate-questions: 'false'

- name: Show Results
if: success()
Expand Down
3 changes: 0 additions & 3 deletions examples/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ jobs:

# Optional: Type of article to create (course or blog, defaults to 'course')
article-type: 'course'

# Optional: Whether to force upload duplicate questions (defaults to 'false')
force-duplicate-questions: 'false'

- name: Show deployment results
if: success()
Expand Down
12 changes: 1 addition & 11 deletions src/scripts/create_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
CourseDeployer,
validate_api_key,
validate_article_type,
validate_boolean,
validate_commit_sha,
validate_repo_token,
validate_repo_url,
Expand All @@ -28,11 +27,8 @@ def __init__(
repo_url: str,
commit_sha: str,
article_type: str = "course",
force_duplicate_questions: bool = True,
):
super().__init__(
api_key, repo_read_token, repo_url, commit_sha, force_duplicate_questions
)
super().__init__(api_key, repo_read_token, repo_url, commit_sha)
try:
self.article_type = ArticleType(article_type)
except ValueError:
Expand Down Expand Up @@ -66,7 +62,6 @@ def create_course(
repo_url: str,
commit_sha: str,
article_type: str = "course",
force_duplicate_questions: bool = True,
):
"""Wrapper for execution."""
creator = CourseCreator(
Expand All @@ -75,7 +70,6 @@ def create_course(
repo_url,
commit_sha,
article_type,
force_duplicate_questions,
)
try:
creator.run()
Expand All @@ -92,9 +86,6 @@ def create_course(
parser.add_argument("--repo-url", required=True, type=validate_repo_url)
parser.add_argument("--commit-sha", required=True, type=validate_commit_sha)
parser.add_argument("--article-type", required=True, type=validate_article_type)
parser.add_argument(
"--force-duplicate-questions", required=True, type=validate_boolean
)

try:
args = parser.parse_args()
Expand All @@ -104,7 +95,6 @@ def create_course(
args.repo_url,
args.commit_sha,
args.article_type,
args.force_duplicate_questions,
)
except (ValidationError, argparse.ArgumentError) as e:
logger.error(f"Validation error: {e}")
Expand Down
19 changes: 1 addition & 18 deletions src/scripts/deploy_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@ def validate_article_type(article_type: str) -> str:
return article_type


def validate_boolean(value: str) -> bool:
"""Validate and convert string to boolean."""
if not value:
raise ValidationError("Boolean value cannot be empty")
value_lower = value.strip().lower()
if value_lower in ("true", "1", "yes", "on"):
return True
elif value_lower in ("false", "0", "no", "off"):
return False
else:
raise ValidationError(
f"Invalid boolean value '{value}'. Must be one of: true, false, 1, 0, yes, no, on, off"
)


def validate_repo_token(token: str) -> str:
"""Validate repository read token is not empty."""
if not token or not token.strip():
Expand Down Expand Up @@ -114,13 +99,11 @@ def __init__(
repo_read_token: str,
repo_url: str,
commit_sha: str,
force_duplicate_questions: bool = True,
):
self.api_key = api_key
self.repo_read_token = repo_read_token
self.repo_url = repo_url
self.commit_sha = commit_sha
self.force_duplicate_questions = force_duplicate_questions
self.session = QbraidSessionV1(api_key=api_key)
self.session.base_url = Config.API_BASE_URL

Expand All @@ -144,7 +127,7 @@ def get_common_payload(self) -> Dict[str, Any]:
run_attempt = os.getenv("GITHUB_RUN_ATTEMPT")
payload = {
"data": course_data,
"forceDuplicateQuestions": self.force_duplicate_questions,
"forceDuplicateQuestions": False,
"repoReadToken": self.repo_read_token,
"repoUrl": self.repo_url,
"commitSha": self.commit_sha,
Expand Down
12 changes: 1 addition & 11 deletions src/scripts/update_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
CourseDeployer,
validate_api_key,
validate_article_type,
validate_boolean,
validate_commit_sha,
validate_course_id,
validate_repo_token,
Expand All @@ -30,11 +29,8 @@ def __init__(
repo_url: str,
commit_sha: str,
article_type: str = "course",
force_duplicate_questions: bool = True,
):
super().__init__(
api_key, repo_read_token, repo_url, commit_sha, force_duplicate_questions
)
super().__init__(api_key, repo_read_token, repo_url, commit_sha)
self.course_custom_id = course_custom_id
try:
self.article_type = ArticleType(article_type)
Expand Down Expand Up @@ -76,7 +72,6 @@ def update_course(
repo_url: str,
commit_sha: str,
article_type: str = "course",
force_duplicate_questions: bool = True,
):
"""Wrapper for execution."""
updater = CourseUpdater(
Expand All @@ -86,7 +81,6 @@ def update_course(
repo_url,
commit_sha,
article_type,
force_duplicate_questions,
)
try:
updater.run()
Expand All @@ -104,9 +98,6 @@ def update_course(
parser.add_argument("--repo-url", required=True, type=validate_repo_url)
parser.add_argument("--commit-sha", required=True, type=validate_commit_sha)
parser.add_argument("--article-type", required=True, type=validate_article_type)
parser.add_argument(
"--force-duplicate-questions", required=True, type=validate_boolean
)

try:
args = parser.parse_args()
Expand All @@ -117,7 +108,6 @@ def update_course(
args.repo_url,
args.commit_sha,
args.article_type,
args.force_duplicate_questions,
)
except (ValidationError, argparse.ArgumentError) as e:
logger.error(f"Validation error: {e}")
Expand Down
5 changes: 2 additions & 3 deletions test/unit/test_create_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def setup_method(self):
self.creator = CourseCreator(
api_key=self.api_key,
article_type="course",
force_duplicate_questions=True,
repo_read_token=self.token,
repo_url=self.url,
commit_sha=self.sha,
Expand All @@ -45,7 +44,7 @@ def test_run_success(self):

payload = json.loads(kwargs["data"])
assert payload["repoReadToken"] == self.token
assert payload["forceDuplicateQuestions"] is True
assert payload["forceDuplicateQuestions"] is False
assert kwargs["headers"]["X-API-Key"] == self.api_key
assert args[0] == "POST"
assert "/learn/articles/course/ingest" in args[1]
Expand All @@ -69,7 +68,7 @@ def test_run_success_jsend_response(self):

payload = json.loads(kwargs["data"])
assert payload["repoReadToken"] == self.token
assert payload["forceDuplicateQuestions"] is True
assert payload["forceDuplicateQuestions"] is False
assert kwargs["headers"]["X-API-Key"] == self.api_key
assert args[0] == "POST"
assert "/learn/articles/course/ingest" in args[1]
Expand Down
1 change: 0 additions & 1 deletion test/unit/test_deploy_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def setup_method(self):
repo_read_token="token",
repo_url="https://github.com/qBraid/upload-course-action",
commit_sha="abc1234",
force_duplicate_questions=False,
)

def test_get_common_payload_includes_integer_run_attempt(self, monkeypatch):
Expand Down
Loading