Page MenuHomePhabricator

Automate docs generation for Device Analytics
Closed, ResolvedPublic

Description

Currently, the command to generate the OpenAPI spec for Device Analytics must be run manually before submitting a patch. To make this system more robust, add a command to build the docs to the Makefile.

Command to generate the docs:

swag init --markdownFiles .

Ideas for ideal workflows

(To be published as a separate task once this task is resolved.)

Assuming the ability to install and run swag in CI, run the command to generate the docs as part of CI checks, and check if the output matches the committed files. If not, fail the check.

Event Timeline

VirginiaPoundstone moved this task from Incoming to Sprint 05 on the API Platform board.

Change 894742 had a related patch set uploaded (by Alex Paskulin; author: Alex Paskulin):

[generated-data-platform/aqs/device-analytics@main] docs: Automate docs generation

https://gerrit.wikimedia.org/r/894742

apaskulin renamed this task from Add docs build to Makefile for Device Analytics to Automate docs generation for Device Analytics.Mar 6 2023, 11:22 PM

Change 894742 abandoned by Alex Paskulin:

[generated-data-platform/aqs/device-analytics@main] docs: Automate docs generation

Reason:

git difficulties

https://gerrit.wikimedia.org/r/894742

Change 899884 had a related patch set uploaded (by Alex Paskulin; author: Alex Paskulin):

[generated-data-platform/aqs/device-analytics@main] docs: Automate docs generation

https://gerrit.wikimedia.org/r/899884

This patch needs review and help with a few outstanding questions I left on the patch. I'll unassign myself so a reviewer can pick it up.

JArguello-WMF lowered the priority of this task from Medium to Low.Mar 17 2023, 1:54 PM
JArguello-WMF moved this task from Needs Grooming to Sprint 06 on the API Platform board.
JArguello-WMF edited projects, added API Platform (Sprint 06); removed API Platform.

Hi @apaskulin I've posted on the gerrit the error I get when trying to test this locally

Note: I thought I posted this awhile back, and found it in drafts instead. I don't recall now why I didn't post it. Maybe there's something in there that I wasn't sure about? Anyway, here it is:

One of the open question regards this new line in the Makefile:

swag init --markdownFiles .

The question is:

I'd like to add this to one of the other commands in the Makefile that is used as part of the normal development workflow so that we don't have to remember to run a separate command for the docs. I tried adding this to make build but it caused CI to fail. Ideas? run? test?

The relevant console log is here:
https://integration.wikimedia.org/ci/job/device-analytics-pipeline-test/8/console

To save a few clicks for other reviewers, and to make sure the console log doesn't get purged, here is the error (along with some preceding lines for context:

step: build, config: ['name':'candidate', 'build':['variant':'production', 'context':'.', 'imagePullPolicy':'always']]
[Pipeline] fileExists
[Pipeline] readFile
[Pipeline] writeFile
[Pipeline] pwd
[Pipeline] sh
+ mktemp -d
[Pipeline] writeJSON
[Pipeline] sh
+ DOCKER_BUILDKIT=1
+ docker --config /tmp/tmp.L3T1OlxYQV build --pull --force-rm=true --label jenkins.job=device-analytics-pipeline-test --label jenkins.build=8 --label zuul.commit=ccd4c5cc7255b41940a24c1b79af9da06a854396 --label ci.project=generated-data-platform/aqs/device-analytics --label ci.pipeline=test --iidfile .pipeline/docker.iid.6tvxeaqf --file .pipeline/blubber.yaml.dcqq5mo0 --target production .
#1 [internal] load build definition from blubber.yaml.dcqq5mo0
#1 sha256:3df361440a41867f9868e4f0ff51fb60b396dcc33ce46d59ae89f0fdba689cee
#1 transferring dockerfile: 877B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 sha256:bdeec8ddedfd33a2aab364cced62a401559e17277d86d39f7e91856cc10dfe40
#2 transferring context: 57B done
#2 DONE 0.0s

#3 resolve image config for docker-registry.wikimedia.org/wikimedia/blubber-buildkit:v0.11.1
#3 sha256:2ffb91a3ce4dba2549125bcbe1b3c747437d830952d3ff5f934dcc06026e8b2f
#3 DONE 0.2s

#4 docker-image://docker-registry.wikimedia.org/wikimedia/blubber-buildkit:v0.11.1@sha256:e9b2163f0d25c31efa5607922c5f1a46453812e0d6a010d64aa9c2799f29a2d0
#4 sha256:0384c1da5df35ebb3e25d997ea59c4f04d1aa87a080a61b9a8334611d72c2284
#4 CACHED

#5 local://dockerfile
#5 sha256:16f8e71fc364425d91f7918ab77215ba4b3dc1d5c676413210723edd5b437383
#5 transferring dockerfile: 877B done
#5 DONE 0.0s

#6 local://context
#6 sha256:316959360fb46101f0632a54bd67f8ec655864489b76499f65fb8ddda569baa6
#6 DONE 0.0s
failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: rpc error: code = Unknown desc = failed to compile to LLB state: docker-registry.wikimedia.org/wikimedia-bullseye:latest: docker-registry.wikimedia.org/wikimedia-bullseye:latest: not found

This is from abandoned patchset https://gerrit.wikimedia.org/r/c/generated-data-platform/aqs/device-analytics/+/894742

Change 899884 abandoned by Alex Paskulin:

[generated-data-platform/aqs/device-analytics@main] docs: Automate docs generation

Reason:

Abandoning due to git issues

https://gerrit.wikimedia.org/r/899884

Change 903773 had a related patch set uploaded (by Alex Paskulin; author: Alex Paskulin):

[generated-data-platform/aqs/device-analytics@main] docs: Automate docs generation

https://gerrit.wikimedia.org/r/903773

I spoke with Bill about this during code mob today. To summarize, we do not currently have a way to install swag as part of the service image (as configured in .pipeline/blubber.yaml), so we are unable to run swag as part of CI. In addition, the commands in the Makefile that we currently use for local development are also used in CI, so we cannot consolidate any of them with the docs command. Therefore our best incremental step for now is to create a make docs command and encourage its use through the README and wiki page. Since swag must be installed locally in order to generate the docs, I've added an error message that prompts the user to install swag if make docs fails.

I had some git issues, so I opened a new patch: https://gerrit.wikimedia.org/r/903773 (Apologies for the noise!)

Change 903773 merged by BPirkle:

[generated-data-platform/aqs/device-analytics@main] docs: Automate docs generation

https://gerrit.wikimedia.org/r/903773

QA needs: the change merged for this task adds a make command to make it more convenient for developers to create the swagger spec. It should not change the runtime behavior of the service. Developers are expected to generate the swagger spec locally after making any relevant change to the code, so there is no expected change to CI behavior.

Therefore, all we need to test for this task is that we didn't someone introduce a regression. It should be sufficient to confirm that tests still pass.

@BPirkle thanks a lot for that clarification. Did really help

Test Status: QA PASS

Tests are passing locally and scenarios ( Positive and Negatives) are working as expected