Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
d6f6b462
Commit
d6f6b462
authored
Oct 11, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add TODO issue checker
parent
5f2ad00c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
0 deletions
+133
-0
config.yml
.circleci/config.yml
+13
-0
todo-checker.sh
ops/scripts/todo-checker.sh
+120
-0
No files found.
.circleci/config.yml
View file @
d6f6b462
...
@@ -611,6 +611,18 @@ jobs:
...
@@ -611,6 +611,18 @@ jobs:
VITE_E2E_RPC_URL_L1
:
http://localhost:8545
VITE_E2E_RPC_URL_L1
:
http://localhost:8545
VITE_E2E_RPC_URL_L2
:
http://localhost:9545
VITE_E2E_RPC_URL_L2
:
http://localhost:9545
todo-issues
:
machine
:
image
:
ubuntu-2204:2022.07.1
steps
:
-
checkout
-
run
:
name
:
Install ripgrep
command
:
sudo apt-get install -y ripgrep
-
run
:
name
:
Check TODO issues
command
:
./ops/scripts/todo-checker.sh --verbose
bedrock-markdown
:
bedrock-markdown
:
machine
:
machine
:
image
:
ubuntu-2204:2022.07.1
image
:
ubuntu-2204:2022.07.1
...
@@ -1167,6 +1179,7 @@ workflows:
...
@@ -1167,6 +1179,7 @@ workflows:
-
fuzz-op-chain-ops
-
fuzz-op-chain-ops
-
fuzz-cannon
-
fuzz-cannon
-
bedrock-markdown
-
bedrock-markdown
-
todo-issues
-
go-lint
:
-
go-lint
:
name
:
op-batcher-lint
name
:
op-batcher-lint
module
:
op-batcher
module
:
op-batcher
...
...
ops/scripts/todo-checker.sh
0 → 100755
View file @
d6f6b462
#!/bin/bash
# Github API access token (Optional - necessary for private repositories.)
TOKEN
=
""
if
[[
$TOKEN
!=
""
]]
;
then
AUTH
=
"Authorization: token
$TOKEN
"
fi
# Default org and repo
ORG
=
"ethereum-optimism"
REPO
=
"client-pod"
# Counter for issues that were not found and issues that are still open.
NOT_FOUND_COUNT
=
0
MISMATCH_COUNT
=
0
OPEN_COUNT
=
0
declare
-a
OPEN_ISSUES
# Colors
RED
=
'\033[0;31m'
YELLOW
=
'\033[1;33m'
GREEN
=
'\033[0;32m'
GREY
=
'\033[1;30m'
CYAN
=
'\033[0;36m'
PURPLE
=
'\033[0;35m'
NC
=
'\033[0m'
# No Color
# Toggle strict mode; Will fail if any TODOs are found that don't match the expected
# formats:
# * TODO(<issue_number>): <description> (Default org & repo: "ethereum-optimism/client-pod")
# * TODO(repo#<issue_number>): <description> (Default org "ethereum-optimism")
# * TODO(org/repo#<issue_number>): <description>
for
arg
in
"
$@
"
;
do
case
$arg
in
--strict
)
FAIL_INVALID_FMT
=
true
shift
;;
--verbose
)
VERBOSE
=
true
shift
;;
esac
done
# Use ripgrep to search for the pattern in all files within the repo
todos
=
$(
rg
-o
--no-filename
--no-line-number
-g
'!ops/scripts/todo-checker.sh'
'TODO\(([^)]+)\): [^,;]*'
)
# Check each TODO comment in the repo
IFS
=
$'
\n
'
# Set Internal Field Separator to newline for iteration
for
todo
in
$todos
;
do
# Extract the text inside the parenthesis
ISSUE_REFERENCE
=
$(
echo
$todo
|
sed
-n
's/.*TODO(\([^)]*\)).*/\1/p'
)
# Check if it's just a number
if
[[
$ISSUE_REFERENCE
=
~ ^[0-9]+
$
]]
;
then
REPO_FULL
=
"
$ORG
/
$REPO
"
ISSUE_NUM
=
"
$ISSUE_REFERENCE
"
# Check for org_name/repo_name#number format
elif
[[
$ISSUE_REFERENCE
=
~ ^
([
^/]+
)
/
([
^#]+
)
#([0-9]+)$ ]]; then
REPO_FULL
=
"
${
BASH_REMATCH
[1]
}
/
${
BASH_REMATCH
[2]
}
"
ISSUE_NUM
=
"
${
BASH_REMATCH
[3]
}
"
# Check for repo_name#number format
elif
[[
$ISSUE_REFERENCE
=
~ ^
([
^#]+
)
#([0-9]+)$ ]]; then
REPO_FULL
=
"
$ORG
/
${
BASH_REMATCH
[1]
}
"
ISSUE_NUM
=
"
${
BASH_REMATCH
[2]
}
"
else
if
[[
$FAIL_INVALID_FMT
||
$VERBOSE
]]
;
then
echo
-e
"
$YELLOW
[Warning]:
$NC
Invalid TODO format:
$todo
"
if
[[
$FAIL_INVALID_FMT
]]
;
then
exit
1
fi
fi
((
MISMATCH_COUNT++
))
continue
fi
# Use GitHub API to fetch issue details
RESPONSE
=
$(
curl
-sL
-H
"
$AUTH
"
--request
GET
"https://api.github.com/repos/
$REPO_FULL
/issues/
$ISSUE_NUM
"
)
# Check if issue was found
if
echo
"
$RESPONSE
"
| rg
-q
"Not Found"
;
then
if
[[
$VERBOSE
]]
;
then
echo
-e
"
$YELLOW
[Warning]:
$NC
Issue not found:
$RED$REPO_FULL
/
$ISSUE_NUM$NC
"
fi
((
NOT_FOUND_COUNT++
))
continue
fi
# Check issue state
STATE
=
$(
echo
"
$RESPONSE
"
| jq
-r
.state
)
if
[[
"
$STATE
"
==
"closed"
]]
;
then
echo
-e
"
$RED
[Error]:
$NC
Issue #
$issue_num
is closed. Please remove the TODO:
$todo
"
exit
1
fi
((
OPEN_COUNT++
))
TITLE
=
$(
echo
"
$RESPONSE
"
| jq
-r
.title
)
OPEN_ISSUES+
=(
"
$REPO_FULL
/issues/
$ISSUE_NUM
|
$TITLE
"
)
done
# Print summary
if
[[
$NOT_FOUND_COUNT
-gt
0
]]
;
then
echo
-e
"
$YELLOW
[Warning]:
$NC
$NOT_FOUND_COUNT
TODOs referred to issues that were not found."
fi
if
[[
$MISMATCH_COUNT
-gt
0
]]
;
then
echo
-e
"
$YELLOW
[Warning]:
$NC
$MISMATCH_COUNT
TODOs did not match the expected pattern."
fi
if
[[
$OPEN_COUNT
-gt
0
]]
;
then
echo
-e
"
$GREEN
[Info]:
$NC
$OPEN_COUNT
TODOs refer to issues that are still open."
echo
-e
"
$GREEN
[Info]:
$NC
Open issue details:"
printf
"
\n
${
PURPLE
}
%-59s
${
NC
}
${
GREY
}
|
${
NC
}
${
GREEN
}
%-75s
${
NC
}
\n
"
"Repository & Issue"
"Title"
echo
-e
"
$GREY
------------------------------------------------------------+---------------------------------------------------------------------------
$NC
"
for
issue
in
"
${
OPEN_ISSUES
[@]
}
"
;
do
REPO_ISSUE
=
"
${
issue
%|*
}
"
TITLE
=
"
${
issue
#*|
}
"
printf
"
${
CYAN
}
%-59s
${
NC
}
${
GREY
}
|
${
NC
}
%-75s
\n
"
"https://github.com/
$REPO_ISSUE
"
"
$TITLE
"
done
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment