Compare commits

...

2 commits

Author SHA1 Message Date
1bd6d1adb0 chore: clean up output
All checks were successful
Test / checks (map[name:stable]) (push) Successful in 1m56s
Test / checks (map[name:nightly]) (push) Successful in 4m34s
2024-09-22 09:24:06 +01:00
6d2b750b65 build: Use codeberg mirror to self-test todo action
All checks were successful
Test / checks (map[name:stable]) (push) Successful in 2m19s
Test / checks (map[name:nightly]) (push) Successful in 4m6s
There is now a mirror of this repo at
https://codeberg.org/kemitix/todo-checker

We use both this original repo and that repo to verify
both are working as a valid actions.

Closes kemitix/forgejo-todo-checker#10
2024-09-22 09:24:06 +01:00
5 changed files with 49 additions and 21 deletions

View file

@ -27,9 +27,12 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Check TODOs - name: Check TODOs (Origin)
uses: https://git.kemitix.net/kemitix/forgejo-todo-checker@v1.0.0 uses: https://git.kemitix.net/kemitix/forgejo-todo-checker@v1.0.0
- name: Check TODOs (Mirror)
uses: kemitix/todo-checker@v1.0.0
- name: Machete - name: Machete
uses: https://git.kemitix.net/kemitix/rust@v2.1.0 uses: https://git.kemitix.net/kemitix/rust@v2.1.0
with: with:

View file

@ -1,14 +1,38 @@
# forgejo-todo-checker # forgejo-todo-checker
Checks your source files for TODO and FIXME comments, where they don't have an open issue number. Checks your source files for TODO and FIXME comments, failing your build where they don't have an open issue number.
A ForgeJo Action. - [A ForgeJo Action](https://forgejo.org/docs/next/user/actions/).
(Inspired by https://woodpecker-ci.org/plugins/TODO-Checker) (Inspired by https://woodpecker-ci.org/plugins/TODO-Checker)
## code.forgejo.org Mirror
Main development takes place on [git.kemitix.net](https://git.kemitix.net/kemitix/forgejo-todo-checker).
There is a mirror on Codeberg.org as [kemitix/todo-checker](https://code.forgejo.org/kemitix/todo-checker).
This mirror allows you to refer to the action as simply `kemitix/todo-checker@v1.0.0`.
## Usage
```yaml
jobs:
tests:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check TODOs
# Original:
# uses: https://git.kemitix.net/kemitix/forgejo-todo-checker@v1.0.0
# Codeberg mirror:
uses: kemitix/todo-checker@v1.0.0
```
## Comments Format ## Comments Format
This Action only pays attention to comments in a particular format. e.g: This Action looks for comments in the following formats:
``` ```
// TODO: (#19) This is the comment // TODO: (#19) This is the comment
@ -31,31 +55,27 @@ The `ISSUE_NUMBER` must correspond to an **OPEN** Issue in the repo that the Act
If the issue has been closed or can't be found then the comment is marked as an error and the Check with fail. If the issue has been closed or can't be found then the comment is marked as an error and the Check with fail.
## Example Use as a ForgeJo Action Step ## Example Output
```yaml
jobs:
tests:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check TODOs
uses: https://git.kemitix.net/kemitix/forgejo-todo-checker@v1.0.0
```
The output will be similar to the following if there are any errors: The output will be similar to the following if there are any errors:
``` ```
Forgejo TODO Checker! Forgejo TODO Checker!
Repo: kemitix/my-projext
Repo: kemitix/my-project
Prefix: (#|//)\s*(TODO|FIXME) Prefix: (#|//)\s*(TODO|FIXME)
Issues: ( |)(\(|\(#)(?P<ISSUE_NUMBER>\d+)(\)) Issues: \(#?(?P<ISSUE_NUMBER>\d+)\)
- Issue number missing: src/main.rs#38: - Issue number missing: src/main.rs#38:
// TODO: implement this cool feature and get rich! // TODO: implement this cool feature and get rich!
- Closed/Invalid Issue: (19) README.md#12:
>> 1 error in src/main.rs
- Closed/Invalid Issue: (19) src/model/line.rs#12:
// TODO: (#19) This is the comment // TODO: (#19) This is the comment
>> 1 error in src/model/line.rs
Error: Invalid or closed TODO/FIXMEs found Error: Invalid or closed TODO/FIXMEs found
``` ```

View file

@ -21,9 +21,11 @@ pub fn init_config(printer: &impl Printer, net: Network) -> Result<Config> {
.maybe_auth_token(std::env::var("REPO_TOKEN").ok()) .maybe_auth_token(std::env::var("REPO_TOKEN").ok())
.build(); .build();
printer.println("");
printer.println(format!("Repo: {}", config.repo())); printer.println(format!("Repo: {}", config.repo()));
printer.println(format!("Prefix: {}", config.prefix_pattern())); printer.println(format!("Prefix: {}", config.prefix_pattern()));
printer.println(format!("Issues: {}", config.issue_pattern())); printer.println(format!("Issues: {}", config.issue_pattern()));
printer.println("");
Ok(config) Ok(config)
} }

View file

@ -81,7 +81,10 @@ impl FileScanner for DefaultFileScanner {
_ => {} _ => {}
}); });
if errors > 0 { if errors > 0 {
printer.println(format!(">> {errors} errors in {}", file.to_string_lossy())); printer.println(format!(
">> {errors} errors in {}\n",
relative_path.to_string_lossy()
));
} }
Ok(errors) Ok(errors)

View file

@ -46,7 +46,7 @@ fn find_markers_in_dir() -> anyhow::Result<()> {
"- Issue number missing: file_with_invalids.txt#3:\n It contains a todo comment: // TODO: this is it\n", "- Issue number missing: file_with_invalids.txt#3:\n It contains a todo comment: // TODO: this is it\n",
"- Issue number missing: file_with_invalids.txt#5:\n It also contains a fix-me comment: // FIXME: and this is it\n", "- Issue number missing: file_with_invalids.txt#5:\n It also contains a fix-me comment: // FIXME: and this is it\n",
"- Closed/Invalid Issue: (3) file_with_invalids.txt#9:\n We also have a todo comment: // TODO: (#3) and it has an issue number, but it is closed\n", "- Closed/Invalid Issue: (3) file_with_invalids.txt#9:\n We also have a todo comment: // TODO: (#3) and it has an issue number, but it is closed\n",
format!(">> 3 errors in {}", file_with_invalids.to_string_lossy()).as_str() format!(">> 3 errors in {}\n", file_with_invalids.strip_prefix(fs.base())?.to_string_lossy()).as_str()
] ]
); );
assert_eq!(errors, 3); assert_eq!(errors, 3);