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
52 changes: 52 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name-template: "MQP API $RESOLVED_VERSION Release"
tag-template: "v$RESOLVED_VERSION"
categories:
- title: "🚀 Features and Enhancements"
labels:
- "enhancement"
- "feature"
- "refactor"
- "usability"
- title: "🐛 Bug Fixes"
labels:
- "bug"
- "fix"
- title: "📄 Documentation"
labels:
- "documentation"
- title: "🤖 CI"
labels:
- "continuous integration"
- title: "📦 Packaging"
labels:
- "packaging"
- title: "🧹 Code Quality"
labels:
- "code quality"
- title: "⬆️ Dependencies"
collapse-after: 5
labels:
- "dependencies"
- "github-actions"
- "pre-commit"
- "submodules"
change-template: "- $TITLE ([#$NUMBER]($URL)) (**@$AUTHOR**)"
change-title-escapes: '\<*_&'
version-resolver:
major:
labels:
- "major"
minor:
labels:
- "minor"
patch:
labels:
- "patch"
default: patch

template: |
## 👀 What Changed

$CHANGES

**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
56 changes: 56 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
$schema: "https://docs.renovatebot.com/renovate-schema.json",
extends: [
"config:recommended",
":gitSignOff",
"helpers:pinGitHubActionDigestsToSemver",
":automergeDigest",
":automergeStableNonMajor",
":combinePatchMinorReleases",
":configMigration",
":enablePreCommit",
":prConcurrentLimitNone",
":prHourlyLimitNone",
],
enabledManagers: ["dockerfile", "github-actions", "pep621", "pre-commit"],
lockFileMaintenance: {
enabled: true,
automerge: true,
},
labels: ["dependencies"],
schedule: ["every weekend"],
packageRules: [
{
matchManagers: ["dockerfile"],
addLabels: ["docker"],
commitMessagePrefix: "⬆\uFE0F\uD83D\uDC33",
},
{
matchManagers: ["github-actions"],
addLabels: ["github-actions"],
commitMessagePrefix: "⬆\uFE0F\uD83D\uDC68\u200D\uD83D\uDCBB",
},
{
matchManagers: ["pep621"],
addLabels: ["python"],
commitMessagePrefix: "⬆\uFE0F\uD83D\uDC0D",
},
{
matchManagers: ["pre-commit"],
addLabels: ["pre-commit"],
commitMessagePrefix: "⬆\uFE0F\uD83E\uDE9D",
versioning: "pep440",
},
{
matchUpdateTypes: ["lockFileMaintenance"],
commitMessagePrefix: "⬆\uFE0F\uD83D\uDD12\uFE0F",
},
{
description: "Group and automerge all patch updates",
groupName: "patch updates",
groupSlug: "all-patch",
matchUpdateTypes: ["patch"],
automerge: true,
},
],
}
99 changes: 99 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CI
on:
push:
branches:
- develop
pull_request:
merge_group:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
lint:
name: 🐍 Lint
runs-on: ubuntu-26.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: "3.11"
- name: Install PDM and the project
run: |
python -m pip install pdm
pdm install -G dev -G test
# Runs the hooks in .pre-commit-config.yaml: black, isort, mypy, pylint,
# file checks and the zizmor workflow security check.
- name: Run pre-commit
run: pdm run pre-commit run --all-files --show-diff-on-failure

tests:
name: 🐍 Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-26.04
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
permissions:
contents: read
id-token: write # Codecov upload via OIDC
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ matrix.python-version }}
- name: Install PDM and the project
run: |
python -m pip install pdm
pdm install -G test
- name: Run tests
run: pdm run pytest --cov --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
# Do not fail the build while the repository is not yet registered with
# Codecov; switch to true (as in QDMI) once the Codecov app is installed.
with:
fail_ci_if_error: false
flags: python
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }}

docker:
name: 🐳 Docker image
runs-on: ubuntu-26.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Build image (not pushed)
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
push: false
tags: bqp-api:ci

required-checks-pass: # This job does nothing and is only used for branch protection
name: 🚦 Check
if: always()
needs:
- lint
- tests
- docker
runs-on: ubuntu-26.04
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # v1.3.0
with:
jobs: ${{ toJSON(needs) }}
25 changes: 16 additions & 9 deletions .github/workflows/jira-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@ on:
issues:
types: [opened, closed]

permissions:
issues: write
permissions: {}

jobs:
create-jira-issue:
if: github.event.action == 'opened'
permissions:
issues: write # comment the Jira key on the GitHub issue
runs-on: ubuntu-latest
steps:
- name: Log in to Jira
uses: atlassian/gajira-login@v3
uses: atlassian/gajira-login@45fd029b9f1d6d8926c6f04175aa80c0e42c9026 # v3.0.1
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

- name: Create Issue in Jira
id: create_jira
uses: atlassian/gajira-create@v3
uses: atlassian/gajira-create@59e177c4f6451399df5b4911c2211104f171e669 # v3.0.1
with:
project: QSI
issuetype: Task
Expand All @@ -31,23 +32,29 @@ jobs:
${{ github.event.issue.body }}

- name: Comment Jira Key on GitHub Issue
uses: actions/github-script@v7
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
env:
JIRA_ISSUE: ${{ steps.create_jira.outputs.issue }}
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
with:
script: |
const { JIRA_ISSUE, JIRA_BASE_URL } = process.env;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `Tracked in Jira: [${{ steps.create_jira.outputs.issue }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create_jira.outputs.issue }})`
body: `Tracked in Jira: [${JIRA_ISSUE}](${JIRA_BASE_URL}/browse/${JIRA_ISSUE})`
})

close-jira-issue:
if: github.event.action == 'closed'
permissions:
issues: read # read the Jira key from the issue comments
runs-on: ubuntu-latest
steps:
- name: Find Jira key in issue comments
id: key
uses: actions/github-script@v7
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
with:
script: |
const comments = await github.paginate(github.rest.issues.listComments, {
Expand All @@ -62,14 +69,14 @@ jobs:
core.setFailed('No Jira key found in the issue comments');

- name: Login to Jira
uses: atlassian/gajira-login@v3
uses: atlassian/gajira-login@45fd029b9f1d6d8926c6f04175aa80c0e42c9026 # v3.0.1
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

- name: Move Jira item to Done
uses: atlassian/gajira-transition@v3
uses: atlassian/gajira-transition@38fc9cd61b03d6a53dd35fcccda172fe04b36de3 # v3.0.1
with:
issue: ${{ steps.key.outputs.key }}
transition: Done
17 changes: 17 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Release Drafter

on:
push:
branches:
- develop

permissions: {}

jobs:
update_release_draft:
name: Run
permissions:
contents: write
runs-on: ubuntu-26.04
steps:
- uses: release-drafter/release-drafter@d1a19e60e81a7e650d00a7de9277f87e439117ea # v7.11.0
16 changes: 15 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,18 @@ repos:
entry: pdm run python -m pylint bqp_api/
language: system
always_run: true
pass_filenames: false
pass_filenames: false

## Check GitHub workflow and Renovate schemas
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.39.0
hooks:
- id: check-github-workflows
- id: check-renovate
additional_dependencies: [json5]

## Check for security issues in GitHub Actions workflows
- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: v1.33.0
hooks:
- id: zizmor
2 changes: 1 addition & 1 deletion bqp_api/version_1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from flask import Blueprint

from . import hamiltonian_jobs, jobs, resources, job_metrics
from . import hamiltonian_jobs, job_metrics, jobs, resources

blueprint = Blueprint("version_1", __name__, url_prefix="/v1")
blueprint.register_blueprint(resources.blueprint)
Expand Down
9 changes: 5 additions & 4 deletions bqp_api/version_1/job_metrics.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from typing import Optional

import bqp_database_access as database # type: ignore
from eliot import log_call # type: ignore
from flask import Blueprint, g, request
from flask import Blueprint

blueprint = Blueprint("job_metrics", __name__)

Expand All @@ -11,8 +9,11 @@
@log_call
def job_metrics(uuid):
try:
# TODO: bqp_database_access has no job_metrics module yet, so this lookup
# always raises and the endpoint returns 404.
# pylint: disable-next=no-member
_job_metrics = database.job_metrics.fetch_timestamp_data_by_job_id(uuid)[0]
except Exception as e:
except Exception:
return "JOB METRICS NOT FOUND", 404

if _job_metrics is None:
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dev = [
test = [
"pytest>=7.4.0",
"pytest-env>=0.8.2",
"pytest-cov>=6.0.0",
]

[tool.pylint.'MESSAGES CONTROL']
Expand All @@ -50,6 +51,11 @@ env = [
"QUANTUM_DB_FILENAME=test_db.sqlite",
"QUANTUM_DB_USER=",
"QUANTUM_DB_PASS=",
"QUANTUM_DB_HOST="
"QUANTUM_DB_HOST=",
"D:QUANTUM_DB_PEPPER=test-pepper",
"D:QUANTUM_DB_TOKEN_PEPPER=test-token-pepper",
]

[tool.coverage.run]
source = ["bqp_api"]
pythonpath = ["."]
Loading
Loading