Skip to content

Commit e4bb73b

Browse files
committed
[#10] Add support for filtering spec items using OFT tags
The OFT Action has been extended to support a new input parameter for specifying tag values which are passed on to the run-oft.sh script.
1 parent d63677c commit e4bb73b

File tree

6 files changed

+47
-25
lines changed

6 files changed

+47
-25
lines changed

.github/workflows/requirements-tracing.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
report-filename: ${{ env.REPORT_FILENAME }}
2525
report-format: "html"
26-
file-patterns: "."
26+
file-patterns: ${{ github.workspace }}
2727

2828
- name: Upload tracing report
2929
id: upload-report

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# [impl->req~run-oft-trace-command~1]
22
FROM eclipse-temurin:22-jre-alpine
3+
# alpine comes with sh only, by default
4+
RUN apk add --no-cache bash
35

46
ARG OFT_CORE_VERSION=4.1.0
57
ARG OFT_ASCIIDOC_PLUGIN_VERSION=0.2.0
@@ -13,6 +15,6 @@ wget -P $LIB_DIR ${base_url}/openfasttrace/releases/download/$OFT_CORE_VERSION/o
1315
wget -P $LIB_DIR ${base_url}/openfasttrace-asciidoc-plugin/releases/download/$OFT_ASCIIDOC_PLUGIN_VERSION/openfasttrace-asciidoc-plugin-$OFT_ASCIIDOC_PLUGIN_VERSION-with-dependencies.jar
1416
EOF
1517

16-
COPY run-oft.sh /opt/oft/run-oft.sh
18+
COPY run-oft.sh /opt/oft/run-oft.sh
1719

1820
ENTRYPOINT [ "/opt/oft/run-oft.sh" ]

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ Runs OpenFastTrace CLI's `trace` command using Temurin JRE 22 on the local works
66

77
The action has the following inputs:
88

9-
| Name | Required | Description |
10-
| :---------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
11-
| `file-patterns` | `false` | A whitespace separated list of (Bash standard) glob patterns which specify the files and directories to include in the OFT trace run.<br>If not specified, the local workspace directory is used. |
12-
| `report-filename` | `true` | The name of the file that OpenFastTrace should write the analysis results to. |
13-
| `report-format` | `false` | The format of the report that OpenFastTrace should produce. Default value is `plain`. |
14-
| `fail-on-error` | `false` | By default, the action will never fail but indicate the result of running the trace command in the `oft-exit-code` output variable.<br>Setting this parameter to `true` will let the Action return the exit code produced by running OpenFastTrace. |
9+
| Name | Required | Description |
10+
| :---------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
11+
| `file-patterns` | `false` | A whitespace separated list of (Bash standard) glob patterns which specify the files and directories to include in the OFT trace run.<br>If not specified, the local workspace directory is used. |
12+
| `report-filename` | `true` | The name of the file that OpenFastTrace should write the analysis results to. |
13+
| `report-format` | `false` | The format of the report that OpenFastTrace should produce. Default value is `plain`. |
14+
| `tags` | `false` | A comma separated list of tags to use for [filtering specification items](https://github.com/itsallcode/openfasttrace/blob/main/doc/user_guide.md#distributing-the-detailing-work).<br>If not set explicitly, all specification items from files matching the file patterns are considered. |
15+
| `fail-on-error` | `false` | By default, the action will never fail but indicate the result of running the trace command in the `oft-exit-code` output variable.<br>Setting this parameter to `true` will let the Action return the exit code produced by running OpenFastTrace. |
1516

1617
The action has the following outputs:
1718

action.yaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: |
88
inputs:
99
file-patterns:
1010
description: |
11-
A whitespace separated list of (Bash standard) glob patterns which specify the files and directories to include in the OFT trace run.
11+
A whitespace separated list of (standard Bash) glob patterns which specify the files and directories to include in the OFT trace run.
1212
If not specified, the local workspace directory is used.
1313
default: "."
1414
required: false
@@ -20,6 +20,10 @@ inputs:
2020
description: The format of the report that OpenFastTrace should produce.
2121
default: "plain"
2222
required: false
23+
tags:
24+
description: |
25+
A comma separated list of tags to use for filtering specification items.
26+
required: false
2327
fail-on-error:
2428
description: |
2529
By default, the action will never fail but indicate the result of running the trace command in the "oft-exit-code" output variable.
@@ -35,8 +39,9 @@ outputs:
3539
runs:
3640
using: "docker"
3741
image: "Dockerfile"
38-
args:
39-
- ${{ inputs.fail-on-error }}
40-
- ${{ inputs.report-filename }}
41-
- ${{ inputs.report-format }}
42-
- ${{ inputs.file-patterns }}
42+
env:
43+
OFT_FILE_PATTERNS: ${{ inputs.file-patterns }}
44+
OFT_REPORT_FORMAT: ${{ inputs.report-format }}
45+
OFT_REPORT_FILENAME: ${{ inputs.report-filename }}
46+
OFT_TAGS: ${{ inputs.tags }}
47+
OFT_FAIL_ON_ERROR: ${{ inputs.fail-on-error }}

doc/spec/system_requirements.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,13 @@ Covers:
3333
- feat~standard-github-action~1
3434

3535
Needs: impl
36+
37+
### Filter specification items based on tags
38+
`req~filter-specitems-using-tags~1`
39+
40+
The OFT Action supports filtering relevant specification items using OFT Tags.
41+
42+
Covers:
43+
- feat~standard-github-action~1
44+
45+
Needs: impl

run-oft.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

3-
# [impl->req~run-oft-trace-command~1]
4-
fail_on_error=$1
5-
report_file_name=$2
6-
report_format=$3
7-
files=$4
3+
fail_on_error=${OFT_FAIL_ON_ERROR:-"false"}
4+
report_file_name=${OFT_REPORT_FILENAME:-"trace-report.txt"}
5+
report_format=${OFT_REPORT_FORMAT:-"plain"}
6+
tags=${OFT_TAGS:-""}
7+
file_patterns=${OFT_FILE_PATTERNS:-"."}
8+
9+
options=(-o "$report_format" -f "$report_file_name")
10+
# [impl->req~filter-specitems-using-tags~1]
11+
if [[ -n "$tags" ]]; then
12+
options=("${options[@]}" -t "$tags")
13+
fi
814

915
echo "::notice::using OpenFastTrace JARs from: ${LIB_DIR}"
16+
echo "::notice::running OpenFastTrace for file patterns: $file_patterns"
1017

11-
# Run OpenFastTrace
18+
# [impl->req~run-oft-trace-command~1]
1219
# shellcheck disable=SC2086
1320
# we need to provide the file patterns unquoted in order for the shell to expand any glob patterns like "*.md"
14-
if (java -cp "${LIB_DIR}/*" \
15-
org.itsallcode.openfasttrace.core.cli.CliStarter trace -o "${report_format}" \
16-
-f "${report_file_name}" \
17-
${files})
21+
if (java -cp "${LIB_DIR}/*" org.itsallcode.openfasttrace.core.cli.CliStarter trace "${options[@]}" $file_patterns)
1822
then
1923
echo "oft-exit-code=0" >> "${GITHUB_OUTPUT}"
2024
echo "All specification items are covered." >> "${GITHUB_STEP_SUMMARY}"

0 commit comments

Comments
 (0)