Setup a CI pipeline¶
1. Obtain Personal access token and add it to GitHub secrets¶
Create a new personal access token for your GitHub repository. You may get it by going to
Settings
->Developer settings
page of your GitHub account. SelectPersonal access token
tab and create a new classic token. Give the token a meaningful name and provide the necessary permissions (e.g., repo and workflow).Add this token to your repository’s secrets. Go to
Settings
within your repository page and selectSecrets
. Add a new secret by pasting the access token in theValue
field and giving a meaning name (e.g.,PAT
).
2. Add your Designite key to secrets (optional)¶
Add your Designite key to your GitHub’s repository secrets, if you have Designite’s professional (or academic) license key. Let us call it D_KEY
.
If your codebase is less than 50,000 lines of code, it won’t impact you. If your project is larger, you will need to specify the license key with this action.
Check our licensing page for more information about Designite licenses.
3. Use DPy Action¶
In this step, we will use DPy Action. Create a folder .github
on your root directory of the project and create workflows
folder inside the .github
folder. Create a workflow file (say actions.yml
) in the newly created workflows folder. The contents of the action.yml
file depend upon your project language and tasks. A sample action file is provided below.
name: DPy Code Quality
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: DPy Action
uses: DesigniteTools/DPyAction@v1.0.0
with:
PAT: ${{ secrets.PAT }}
D_KEY: ${{ secrets.D_KEY }}
Tip
Check out our post on Streamlining Incremental Code Analysis with GitHub Actions for a more refined use-case.
What you will get?¶
Once configured, your Python project will be analyzed on each push in the main branch (can be configured differently), and the analysis report will be placed as an Actions artifact in your GitHub account. You can download the artifact later for further analysis.