These actions are meant to be used for unifying lint, unit and functional tests, charm and snap releases, and sonar integration in GitHub workflows. At the same time, workflows that can be directly used will also be found in this repo.
This workflow builds and releases a snap to the Snap Store after passing lint, unit and functional tests. The triggering workflow (from the source repo) can specify one or multiple channel(s) as an input when calling the reusable workflow to properly release the snap.
For the workflow to be fully functional, you must complete the following steps.
- Go to sonarcloud and register with github.
- After registration, send username to one of the current administrators( Erhan Sunar Robert Gildein Sudeep Bhandari ).
- We will add you to bootstack-devops project as Admin
- From now on you will be able to add projects.
- From the top right corner press the (+) icon.
- Then press “Analyze new project”
- From the bottom right corner press “create a project manually”
- Select the bootstack-devops as organization and enter the “Project key” and “Display name” as our project name in github.
- Press “Set Up”
- Continue “With Github Actions”
- Go to Github project and add secret shown in previous page
- On the second step do not copy the file, but use the sonar.yaml from this repo
- On github, create an access token for yourself with following permissions
- pull-requests: read # allows SonarCloud to decorate PRs with analysis results
- Add this token as a secret in github project as
GH_TOKEN
like step 7
-
Change relevant parts to create coverage.xml with tests/unit/report/coverage.xml path
- First add --cov-report=xml to unit tests. Example (tox.ini)
[testenv:unit] commands = pytest {toxinidir}/tests/unit \ {posargs:-v --cov --cov-report=term-missing --cov-report=html --cov-report=xml}
- First add --cov-report=xml to unit tests. Example (tox.ini)
-
Then add coverage parts to you configuration. Example (pyproject.yaml)
[tool.coverage.run] relative_files = true [tool.coverage.xml] output = "tests/unit/report/coverage.xml"
-
Add sonar-project.properties file. Example:
sonar.python.version=3 sonar.projectKey=your-project-name sonar.organization=bootstack-devops sonar.python.coverage.reportPaths=tests/unit/report/coverage.xml sonar.sources = src/ sonar.tests = tests/ sonar.test.inclusions = test/** sonar.coverage.exclusions=tests/**, docs/**, contrib/**, snap/**, *