Package: rabbitmq-email-notifier
rabbitmq-email-notifierpython template for etd projectsUsing this RepositoryRead the wiki in the rabbitmq-email-notifier repo for instructions on how to set up the template and badge for your repository:https://github.com/harvard-lts/rabbitmq-email-notifier/wikiLocal setupMake a copy of the .env.example to .env and modify the user and password variables.Start the containerdocker-compose -f docker-compose-local.yml up -d --build --force-recreateTestingStart the container up as described in theLocal Setupinstructions.Exec into the container:docker exec -it rabbitmq-email-notifier bashRun the testspytestStop the container:Start the containerdocker-compose -f docker-compose-local.yml downThis command stops and removes all containers specified in the docker-compose-local.yml configuration. This command can be used in place of the 'stop' and 'rm' commands.docker-compose -f docker-compose-local.yml downDeploymentDevDev deployment will occur using Jenkins.  To trigger the development deployment, commit and push to the 'trial' or 'main' branch.QAQA is hosted on servers that contain L4 data.  Jenkins is not permitted to deploy to these servers so for QA, Jenkins will only perform the build.  To deploy:Commit and push to 'main'.If any IF changes happened, use ansible deploy commands from the ETD-IF project.  Otherwise, manually restart the stack on the server that hosts QA.ProdDeploying to prod requires that the code be tagged in 'main'.  That means the code should be stable and ready for a release.Create the tag and push to the repo if this hasn't been done.
2.Open Jenkins
3.Click on the "Branches" tab.
NOTE: you should see a pipeline with your new tag.  (if not, click on the "scan repository now" link in the sidebar.)
4.Click on the green play (triangle) button to start the build
5.Follow the build progress using the blue ocean view
6.The build process should end with a green status. the docker image is now ready for deployment to prod.
7.Work with ops to deploy to prod using the ETD-IF project.Prerequisites to running docker locallyRequires telemetry/jaeger docker runningMake sure .env has JAEGER_NAME and JAEGER_SERVICE_NAME (see .env.example)Note JAEGER_NAME must have local ip (if on vpn go to Cisco Icon -> Show Statistics Window -> CLient Address (IPv4)start jaeger dockerdocker pull jaegertracing/all-in-one:latestfollowed bydocker run -d --name jaeger  -e COLLECTOR_ZIPKIN_HOST_PORT=:9411  -e COLLECTOR_OTLP_ENABLED=true  -p 6831:6831/udp  -p 6832:6832/udp  -p 5778:5778  -p 16686:16686  -p 4317:4317  -p 4318:4318  -p 14250:14250  -p 14268:14268  -p 14269:14269  -p 9411:9411  jaegertracing/all-in-one:latestYou can now run hello world, and do testingRun hello world example locallyClone this repo from githubCreate the .env by copying the .example.envcp .env.example .envReplace rabbit connect value with dev values (found in 1Password LTS-ETD)Replace theCONSUME_QUEUE_NAMEandPUBLISH_QUEUE_NAMEwith a unique name for local testing (eg - add your initials to the end of the queue names)Start up dockerdocker-compose -f docker-compose-local.yml up --build -d --force-recreateBring up DEV ETD Rabbit UILook forCONSUME_QUEUE_NAMEqueueExec into the docker containerdocker exec -it rabbitmq-email-notifier bashRun invoke task python scriptpython3 scripts/invoke-task.pyLook forPUBLISH_QUEUE_NAMEqueue, and get the message in the RabbitMQ UIand/or tail  to see activityManually placing a message on the queueOpen the queue in the RabbitMQ UIClick on theCONSUME_QUEUE_NAMEqueue (the name that you assigned this env value to)Open Publish MessageSet a property ofcontent_typetoapplication/jsonSet the Payload to the following JSON content{"id": "da28b429-e006-49a5-ae77-da41b925bd85","task": "rabbitmq-email-notifier.tasks.send_to_base","args": [{"hello":"world"}]}Unit Testingexec into docker> pytest tests/unitNote, integration tests are run as part of github actions, not locallyUsing OpenTelemetry for tracingThis app uses OpenTelemetry (https://opentelemetry.io/) for live tracing. To see how it is implemented in the application, refer to this wiki:https://wiki.harvard.edu/confluence/display/LibraryTechServices/OpenTelemetryBuild and publish the packagePrepare the distributionUpdate the version number insetup.pyTo publish a pre-release version, add a letter and a number after the version number e.g.0.0.1a1Remove the olddist/directory from the previous build if necessaryBuild the distributionOnce inside the container, build the distribution.python3 setup.py sdist bdist_wheelA new directorydistwill be created in the container.Register for an accountRegister for an accounton the test python package repository. Enable two-factor authentication for logins.Create a token.Upload package to the test repositoryPublish the package to the test repositorytestpypibefore publishing it to the production repository.python3 -m twine upload --repository testpypi dist/*Test the packageOpen the package in the repository and view the version history.https://test.pypi.org/project/rabbitmq-email-notifier/0.0.4/More informationRead the documenation for more information on building and publishing the distribution.Generating distribution archivesUploading the distribution archiveshttps://tom-christie.github.io/articles/pypi/