Skip to content

Commit 0a53b76

Browse files
committed
addressed reviews (pre-commit hooks bypassed)
1 parent ec9fe70 commit 0a53b76

File tree

10 files changed

+270
-194
lines changed

10 files changed

+270
-194
lines changed

.github/workflows/bug_triager_workflow.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,32 @@ name: Bug Triage Workflow
33
on:
44
schedule:
55
# Run bug triage every Wednesday at 2:30 PM IST (9:00 AM UTC)
6-
- cron: '0 9 * * 3'
7-
workflow_dispatch: # for manual triggering of the workflow
6+
- cron: "0 9 * * 3"
7+
workflow_dispatch: # for manual triggering of the workflow
88

99
jobs:
1010
run-bug-triage:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Check out repository
1414
uses: actions/checkout@v2
15-
15+
1616
- name: Set up Python
1717
uses: actions/setup-python@v2
1818
with:
19-
python-version: '3.x'
20-
19+
python-version: "3.x"
20+
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
2424
pip install -r requirements.txt
25-
25+
2626
- name: Run Bug Triage
2727
env:
2828
EMAIL_SENDER: ${{ secrets.EMAIL_SENDER }}
2929
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
3030
GITHUB_TOKEN: ${{ github.token }}
3131
MAINTAINERS: ${{ secrets.MAINTAINERS }}
32+
REPO_CONFIG: ${{ secrets.REPO_CONFIG }}
3233
run: |
3334
python -m triager --bugs -c example-config.yaml --log --send-email

.github/workflows/ci_workflow.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,32 @@ name: Nightly CI Report Workflow
33
on:
44
schedule:
55
# Run CI report daily at 12:00 PM IST (6:30 AM UTC)
6-
- cron: '30 6 * * *'
7-
workflow_dispatch: # for manual triggering of the workflow
6+
- cron: "30 6 * * *"
7+
workflow_dispatch: # for manual triggering of the workflow
88

99
jobs:
1010
run-ci-report:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Check out repository
1414
uses: actions/checkout@v2
15-
15+
1616
- name: Set up Python
1717
uses: actions/setup-python@v2
1818
with:
19-
python-version: '3.x'
20-
19+
python-version: "3.x"
20+
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
2424
pip install -r requirements.txt
25-
25+
2626
- name: Run CI Report
2727
env:
2828
EMAIL_SENDER: ${{ secrets.EMAIL_SENDER }}
2929
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
3030
GITHUB_TOKEN: ${{ github.token }}
3131
MAINTAINERS: ${{ secrets.MAINTAINERS }}
32+
REPO_CONFIG: ${{ secrets.REPO_CONFIG }}
3233
run: |
3334
python -m triager --ci -c example-config.yaml --log --send-email

.pre-commit-config.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v4.6.0
5+
hooks:
6+
- id: check-merge-conflict
7+
- id: check-symlinks
8+
- id: debug-statements
9+
- id: end-of-file-fixer
10+
- id: trailing-whitespace
11+
12+
- repo: https://github.com/asottile/add-trailing-comma
13+
rev: v3.1.0
14+
hooks:
15+
- id: add-trailing-comma
16+
17+
- repo: https://github.com/pycontribs/mirrors-prettier
18+
rev: "v3.3.3"
19+
hooks:
20+
- id: prettier
21+
entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec"
22+
pass_filenames: false
23+
args: []
24+
additional_dependencies:
25+
- prettier
26+
- prettier-plugin-toml
27+
28+
- repo: https://github.com/PyCQA/isort
29+
rev: 5.13.2
30+
hooks:
31+
- id: isort
32+
name: Sort import statements using isort
33+
args: ["--filter-files"]
34+
35+
- repo: https://github.com/psf/black
36+
rev: 24.8.0
37+
hooks:
38+
- id: black
39+
40+
- repo: https://github.com/pycqa/flake8
41+
rev: 7.1.1
42+
hooks:
43+
- id: flake8

Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
FROM python:3.9-slim
1+
FROM python:3.11-slim
22

33
WORKDIR /app
44

55
COPY requirements.txt .
6+
RUN pip install --no-cache-dir -r requirements.txt
67

7-
RUN pip install -r requirements.txt
8-
9-
# Copy the code
108
COPY . .
119

12-
# Run the command when the container starts
13-
CMD ["python", "-m", "triager"]
10+
RUN useradd -m myuser && chown -R myuser:myuser /app
11+
USER myuser
12+
13+
ENV PYTHONPATH=/app
14+
15+
CMD ["python", "-m", "triager"]

README.md

Lines changed: 113 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,22 @@ pip install -r requirements.txt
2121

2222
1. add your details such as organization_name, workflow_name in `config.yaml` file:
2323

24-
2524
organization_name: "Ansible Networking"
2625
workflow_name: "tests.yml"
27-
repo_config: "repo_config.json"
2826
timedelta: 14
2927

30-
31-
2. update the `repo_config.json` file with your repos:
32-
33-
34-
{
35-
"ansible-collections": {
36-
"ci_and_bug_repos": [
37-
"cisco.nxos",
38-
"cisco.ios"
39-
],
40-
"bug_specific_repos": [
41-
"ansible.scm"
42-
]
43-
}
44-
}
45-
46-
47-
3. Create a `.env` file in the root of your directory and add these details:
48-
28+
2. Create a `.env` file in the root of your directory and add these details:
4929

5030
EMAIL_SENDER=[email protected]
5131
EMAIL_PASSWORD=your_email_password
5232
MAINTAINERS=[{"name": "Your Name", "email": "[email protected]"}]
5333
#GITHUB_TOKEN=your_github_token (optional - enter your github token here to make authenticated requests or comment this line to make unauthenticated API requests)
54-
34+
REPO_CONFIG = {
35+
<organization>: {
36+
"ci_and_bug_repos": [<list of repositories>],
37+
"bug_specific_repos": [<list of repositories>]
38+
}
39+
}
5540

5641
## Usage
5742

@@ -61,52 +46,105 @@ MAINTAINERS=[{"name": "Your Name", "email": "[email protected]"}]
6146

6247
triager --bugs -c config.yaml --log --send-email
6348

64-
6549
2. Run the CI report:
6650

6751
triager --ci -c config.yaml --log --send-email
6852

69-
7053
### Docker Usage
7154

7255
1. Build the Docker image:
7356

74-
docker-compose build
75-
57+
sudo docker-compose build
7658

7759
2. Run the bug scrub:
7860

79-
docker-compose run triager --bugs -c config.yaml --log --send-email
80-
61+
sudo docker-compose run triager
8162

8263
3. Run the CI report:
8364

84-
docker-compose run triager --ci -c config.yaml --log --send-email
85-
65+
sudo docker-compose run ci_report
8666

8767
### GitHub Actions
8868

89-
1. Store your secrets (EMAIL_SENDER, EMAIL_PASSWORD, MAINTAINERS, GITHUB_TOKEN) in GitHub Actions secrets.
90-
91-
To securely store sensitive information like email passwords and recipients, we'll use GitHub Secrets:
92-
a) Go to your GitHub repository.
93-
b) Click on "Settings" tab.
94-
c) In the left sidebar, click on "Secrets and variables", then "Actions".
95-
d) Click on "New repository secret".
96-
e) Add the following secrets:
97-
98-
Name: EMAIL_SENDER (Your tools email address from which you want to send emails)
99-
Name: EMAIL_PASSWORD (Your tools email password)
100-
MAINTAINERS: A JSON string containing the maintainers information.
101-
102-
For example:
103-
104-
EMAIL_SENDER=[email protected]
105-
EMAIL_PASSWORD=your-email-password
106-
MAINTAINERS=[{"name": "John Doe", "email": "[email protected]"}, {"name": "Jane Doe", "email": "[email protected]"}]
107-
69+
This tool uses GitHub Actions for automated reporting. To set up the workflows:
70+
71+
1. Store your secrets in GitHub Actions:
72+
a) Go to your GitHub repository
73+
b) Click on "Settings" tab
74+
c) In the left sidebar, click on "Secrets and variables", then "Actions"
75+
d) Click on "New repository secret"
76+
e) Add the following secrets:
77+
78+
- `EMAIL_SENDER`: Your tool's email address for sending reports
79+
- `EMAIL_PASSWORD`: Your tool's email password
80+
- `MAINTAINERS`: A JSON string containing the maintainers' information
81+
- `REPO_CONFIG`: A JSON string containing the repository configuration
82+
83+
2. The following workflows are available in `.github/workflows/`:
84+
85+
- `bug_triager_workflow.yml`: Runs weekly bug triage
86+
- `ci_workflow.yml`: Runs daily CI status report
87+
88+
### Workflow Details
89+
90+
#### Bug Triage Workflow
91+
92+
This workflow runs every Wednesday at 2:30 PM IST (9:00 AM UTC) and can also be triggered manually.
93+
94+
```yaml
95+
name: Bug Triage Workflow
96+
97+
on:
98+
schedule:
99+
- cron: '0 9 * * 3'
100+
workflow_dispatch:
101+
102+
jobs:
103+
run-bug-triage:
104+
runs-on: ubuntu-latest
105+
steps:
106+
- uses: actions/checkout@v2
107+
- uses: actions/setup-python@v2
108+
with:
109+
python-version: '3.x'
110+
- run: pip install -r requirements.txt
111+
- run: python -m triager --bugs -c example-config.yaml --log --send-email
112+
env:
113+
EMAIL_SENDER: ${{ secrets.EMAIL_SENDER }}
114+
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
115+
GITHUB_TOKEN: ${{ github.token }}
116+
MAINTAINERS: ${{ secrets.MAINTAINERS }}
117+
REPO_CONFIG: ${{ secrets.REPO_CONFIG }}
118+
119+
#### CI Report Workflow
120+
121+
This workflow runs daily at 12:00 PM IST (6:30 AM UTC) and can also be triggered manually.
122+
123+
''''yaml
124+
name: Nightly CI Report Workflow
125+
126+
on:
127+
schedule:
128+
- cron: '30 6 * * *'
129+
workflow_dispatch:
130+
131+
jobs:
132+
run-ci-report:
133+
runs-on: ubuntu-latest
134+
steps:
135+
- uses: actions/checkout@v2
136+
- uses: actions/setup-python@v2
137+
with:
138+
python-version: '3.x'
139+
- run: pip install -r requirements.txt
140+
- run: python -m triager --ci -c example-config.yaml --log --send-email
141+
env:
142+
EMAIL_SENDER: ${{ secrets.EMAIL_SENDER }}
143+
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
144+
GITHUB_TOKEN: ${{ github.token }}
145+
MAINTAINERS: ${{ secrets.MAINTAINERS }}
146+
REPO_CONFIG: ${{ secrets.REPO_CONFIG }}
108147

109-
2. Use the provided workflow files in `.github/workflows/` to set up automated runs.
110148

111149
## Options
112150

@@ -120,6 +158,30 @@ Options | Usage
120158
'--debug'|Bumps logging level to DEBUG
121159
'--send-email'|Send the triaged table as an email to the list of maintainers
122160

161+
## Pre-commit Hooks
162+
163+
This tool uses pre-commit hooks to ensure code quality. The hooks perform the following checks:
164+
165+
- Check for merge conflicts
166+
- Verify symlinks
167+
- Detect debug statements
168+
- Fix end of files
169+
- Remove trailing whitespace
170+
- Add trailing commas
171+
- Format code with Prettier
172+
- Sort import statements with isort
173+
- Format Python code with Black
174+
- Lint Python code with Flake8
175+
176+
To use pre-commit:
177+
178+
1. Install pre-commit: `pip install pre-commit`
179+
2. Install the git hook scripts: `pre-commit install`
180+
3. (Optional) Run against all files: `pre-commit run --all-files`
181+
182+
Pre-commit will now run automatically on `git commit`. You can also run it manually on staged files with `pre-commit run`.
183+
184+
123185
## Notes
124186
- An example config file (example-config.yaml) has been placed in this repository for reference.
125187
- Tested with Python 3.11
@@ -130,3 +192,4 @@ Options | Usage
130192
GNU General Public License v3.0 or later.
131193

132194
See [LICENSE](https://www.gnu.org/licenses/gpl-3.0.txt) to see the full text.
195+
```

config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
organization_name: "Ansible Networking"
22
workflow_name: "tests.yml"
3-
repo_config: "repo_config.json"
4-
timedelta: 14
3+
timedelta: 14

docker-compose.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
version: '3'
1+
version: "3"
22
services:
33
triager:
4-
build:
5-
context: ..
6-
dockerfile: Dockerfile
7-
volumes:
8-
- .:/app
9-
environment:
10-
- EMAIL_SENDER=${EMAIL_SENDER}
11-
- EMAIL_PASSWORD=${EMAIL_PASSWORD}
12-
- MAINTAINERS=${MAINTAINERS}
13-
- GITHUB_TOKEN=${GITHUB_TOKEN:-} #GITHUB TOKEN OPTIONAL
4+
build: .
5+
env_file: .env
6+
command: python -m triager --bugs -c config.yaml --log --send-email
147

8+
ci_report:
9+
build: .
10+
env_file: .env
11+
command: python -m triager --ci -c config.yaml --log --send-email

0 commit comments

Comments
 (0)