Skip to content

Commit ec9fe70

Browse files
committed
newly updated
1 parent 184af81 commit ec9fe70

File tree

12 files changed

+301
-183
lines changed

12 files changed

+301
-183
lines changed

.github/workflows/ci_workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI Report Workflow
1+
name: Nightly CI Report Workflow
22

33
on:
44
schedule:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.code-workspace
44
__pycache__/
55
*.egg-info
6+
.env

Dockerfile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@ WORKDIR /app
44

55
COPY requirements.txt .
66

7-
RUN pip install --no-cache-dir -r requirements.txt
7+
RUN pip install -r requirements.txt
88

9+
# Copy the code
910
COPY . .
1011

11-
EXPOSE 587
12-
13-
ENV EMAIL_SENDER=""
14-
ENV EMAIL_PASSWORD=""
15-
ENV GITHUB_TOKEN=""
16-
ENV MAINTAINERS=""
17-
18-
CMD ["python", "-m", "triager", "--bugs", "-c", "example-config.yaml", "--log", "--send-email"]
12+
# Run the command when the container starts
13+
CMD ["python", "-m", "triager"]

README.md

Lines changed: 102 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
2-
31
# Ansible Network Triager
42

53
Set repositories of interest and run with `triager -c /path/to/config.yaml`
64

7-
This tool assists in weekly bug triages by fetching all issues and pull-requests
8-
from repositories specified in the config file that were created (or updated)
9-
since a pre-defined number of days (`timedelta`). These are also filtered by the `labels`
10-
set in the config file. In case no `labels` are specified, then items that are
11-
currently unassigned are pulled.
5+
This tool assists in weekly bug triages and CI reports by fetching all issues, pull requests, and CI statuses from repositories specified in the configuration file. It retrieves items that were created (or updated) since a pre-defined number of days (`timedelta`). These are also filtered by the `labels` set in the config file. In case no `labels` are specified, then items that are currently unassigned are pulled.
126

137
By default, this prints out a table built from the fetched content to the console.
148
When run with `--send-email` it also emails this table to all the listed maintainers.
@@ -17,18 +11,118 @@ When run with `--send-email` it also emails this table to all the listed maintai
1711

1812
pip install git+https://github.com/ansible-network/ansible-network-triager.git@master
1913

14+
git clone https://github.com/ansible-network/ansible-network-triager.git
15+
16+
cd ansible-network-triager
17+
18+
pip install -r requirements.txt
19+
20+
## Configuration
21+
22+
1. add your details such as organization_name, workflow_name in `config.yaml` file:
23+
24+
25+
organization_name: "Ansible Networking"
26+
workflow_name: "tests.yml"
27+
repo_config: "repo_config.json"
28+
timedelta: 14
29+
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+
49+
50+
EMAIL_SENDER=[email protected]
51+
EMAIL_PASSWORD=your_email_password
52+
MAINTAINERS=[{"name": "Your Name", "email": "[email protected]"}]
53+
#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+
55+
2056
## Usage
57+
58+
### Local Usage
59+
60+
1. Run the bug scrub:
61+
62+
triager --bugs -c config.yaml --log --send-email
63+
64+
65+
2. Run the CI report:
66+
67+
triager --ci -c config.yaml --log --send-email
68+
69+
70+
### Docker Usage
71+
72+
1. Build the Docker image:
73+
74+
docker-compose build
75+
76+
77+
2. Run the bug scrub:
78+
79+
docker-compose run triager --bugs -c config.yaml --log --send-email
80+
81+
82+
3. Run the CI report:
83+
84+
docker-compose run triager --ci -c config.yaml --log --send-email
85+
86+
87+
### GitHub Actions
88+
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+
108+
109+
2. Use the provided workflow files in `.github/workflows/` to set up automated runs.
110+
111+
## Options
112+
21113
Options | Usage
22114
--- | ---
23115
'-c'|Path to config file (selects 'config.yaml' in current working directory by default)
116+
'--bugs'|Generate a bug scrub report
117+
'--ci'|Generate a CI report
24118
'--log'|Print logging information on the console (default level set to INFO)
25119
'--log-to-file'|Dump logging information to a specified file (if no file is specified, the data will be written to /tmp/triager_{{ timestamp }}.log)
26120
'--debug'|Bumps logging level to DEBUG
27121
'--send-email'|Send the triaged table as an email to the list of maintainers
28122

29123
## Notes
30124
- An example config file (example-config.yaml) has been placed in this repository for reference.
31-
- Tested with Python 3.6
125+
- Tested with Python 3.11
32126
- This tool gets installed as a part of `ansible-network-tools` package.
33127

34128
## Licensing

config.yaml

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

docker-compose.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
version: '3'
22
services:
33
triager:
4-
build: .
5-
environment:
6-
- EMAIL_SENDER=${EMAIL_SENDER}
7-
- EMAIL_PASSWORD=${EMAIL_PASSWORD}
8-
- GITHUB_TOKEN=${GITHUB_TOKEN}
9-
- MAINTAINERS=${MAINTAINERS}
10-
ports:
11-
- "587:587"
4+
build:
5+
context: ..
6+
dockerfile: Dockerfile
127
volumes:
138
- .:/app
14-
command: python -m triager --bugs -c example-config.yaml --log --send-email
15-
16-
ci-report:
17-
build: .
189
environment:
1910
- EMAIL_SENDER=${EMAIL_SENDER}
2011
- EMAIL_PASSWORD=${EMAIL_PASSWORD}
21-
- GITHUB_TOKEN=${GITHUB_TOKEN}
2212
- MAINTAINERS=${MAINTAINERS}
23-
ports:
24-
- "587:587"
25-
volumes:
26-
- .:/app
27-
command: python -m triager --ci -c example-config.yaml --log --send-email
13+
- GITHUB_TOKEN=${GITHUB_TOKEN:-} #GITHUB TOKEN OPTIONAL
14+

example-config.yaml

Lines changed: 53 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,54 @@
1-
#Sample Test Case for Ansible Tool Functionality
2-
3-
---
4-
organization_name: "Ansible Networking"
5-
6-
workflow_name: "tests.yml"
7-
8-
orgs:
9-
- name: ansible-collections
10-
ci_and_bug_repos:
11-
- name: cisco.nxos
12-
- name: cisco.ios
13-
- name: cisco.iosxr
14-
- name: arista.eos
15-
- name: junipernetworks.junos
16-
- name: cisco.asa
17-
- name: ansible.netcommon
18-
- name: ansible.snmp
19-
- name: ansible.security
20-
- name: ansible.network
21-
- name: ansible.utils
22-
- name: ibm.qradar
23-
- name: trendmicro.deepsec
24-
- name: splunk.es
25-
bug_specific_repos:
26-
- name: ansible.scm
27-
- name: vyos.vyos
28-
- name: frr.frr
29-
- name: openvswitch.openvswitch
30-
- name: community.yang
31-
- name: ansible
32-
bug_specific_repos:
33-
- name: pylibssh
34-
- name: redhat-cop
35-
ci_and_bug_repos:
36-
- name: network.interfaces
37-
- name: network.bgp
38-
- name: network.base
39-
- name: network.telemetry
40-
- name: network.vpn
41-
- name: network.acls
42-
- name: network.ospf
43-
bug_specific_repos:
44-
- name: network.backup
45-
46-
triager:
47-
address: ${EMAIL_SENDER}
48-
password: ${EMAIL_PASSWORD}
49-
50-
timedelta: 14
51-
52-
#github_token: ${GITHUB_TOKEN} #Use GITHUB_TOKEN if you have a GitHub Actions workflow configured, otherwise comment this line out for unauthenticated requests."
53-
54-
maintainers: ${MAINTAINERS}
55-
56-
# github_token: 'Manually enter your github token here to make authenticated requests or comment this line to make unauthenticated API requests'
57-
58-
59-
60-
61-
##Generic structure
62-
# ---
63-
# organization_name: "Organization Name" # Replace with your organization's name
64-
65-
# workflow_name: "workflow.yml" # Replace with your workflow file name, by default its tests.yml
66-
67-
# orgs:
68-
# - name: collections-group # Name of the first group of repositories
69-
# ci_and_bug_repos: # Repositories common between CI and bug tools
70-
# - name: collection1
71-
# - name: collection2
72-
# - name: collection3
73-
# bug_specific_repos: # Repositories only present in the bug tool
74-
# - name: collection4
75-
# - name: collection5
76-
# - name: another-org # Name of the second organization or group
77-
# bug_specific_repos: # Repositories only present in the bug tool
78-
# - name: repo1
79-
# - name: third-org # Name of the third organization or group
80-
# ci_and_bug_repos: # Repositories common between CI and bug tools
81-
# - name: repo2
82-
# - name: repo3
83-
# bug_specific_repos: # Bug tool-specific repositories
84-
# - name: repo4
85-
86-
# maintainers:
87-
# - name: Maintainer Name # Replace with maintainer details
88-
# email: [email protected] # Replace with actual email
89-
90-
# triager:
91-
# address: [email protected] # Replace with triager's email
92-
# password: secretPassword # Replace with an appropriate password
93-
94-
# timedelta: 14 # Time range in days for fetching relevant data (e.g., issues, pull requests), adjust as necessary
95-
96-
# github_token: 'your_github_token_here' # Replace with your GitHub token or comment this line out to make unauthenticated API requests
1+
# #Template for config.yaml
2+
3+
# # Organization name (used in email subject)
4+
# organization_name: "Your Organization Name"
5+
6+
# # Workflow name (used for logging and debugging)
7+
# workflow_name: "Your Workflow Name"
8+
9+
# # Path to repository configuration file (default: repo_config.json)
10+
# repo_config: "repo_config.json"
11+
12+
# # Time delta (in days) for triaging issues
13+
# timedelta: 14
14+
15+
16+
17+
# #Template for repo_config.json
18+
19+
# {
20+
# "organization1": {
21+
# "ci_and_bug_repos": [
22+
# "repo1",
23+
# "repo2",
24+
# "repo3"
25+
# ],
26+
# "bug_specific_repos": [
27+
# "repo4",
28+
# "repo5"
29+
# ]
30+
# },
31+
# "organization2": {
32+
# "ci_and_bug_repos": [
33+
# "repo6",
34+
# "repo7",
35+
# "repo8"
36+
# ],
37+
# "bug_specific_repos": [
38+
# "repo9",
39+
# "repo10"
40+
# ]
41+
# },
42+
# "organization3": {
43+
# "ci_and_bug_repos": [
44+
# "repo11",
45+
# "repo12",
46+
# "repo13"
47+
# ],
48+
# "bug_specific_repos": [
49+
# "repo14",
50+
# "repo15"
51+
# ]
52+
# }
53+
# }
9754

0 commit comments

Comments
 (0)