Skip to content

Commit cb57d29

Browse files
authored
Add Docker based GitHub OFT Action (#1)
1 parent 1f21efe commit cb57d29

File tree

6 files changed

+157
-1
lines changed

6 files changed

+157
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Requirements tracing
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
tracing:
8+
name: Run OpenFastTrace
9+
runs-on: ubuntu-latest
10+
outputs:
11+
tracing-report-url: ${{ steps.upload-report.outputs.artifact-url }}
12+
env:
13+
REPORT_FILENAME: "requirements-tracing-report.html"
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Run OpenFastTrace
18+
id: run-oft
19+
uses: ./
20+
with:
21+
report-filename: ${{ env.REPORT_FILENAME }}
22+
report-format: "html"
23+
file-patterns: "."
24+
25+
- name: Upload tracing report
26+
id: upload-report
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: tracing-report
30+
path: ${{ env.REPORT_FILENAME }}
31+
32+
- name: "Determine exit code"
33+
run: |
34+
exit ${{ steps.run-oft.outputs.oft-exit-code }}

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# [impl->req~run-oft-trace-command~1]
2+
FROM eclipse-temurin:22-jre-alpine
3+
4+
ARG OFT_CORE_VERSION=4.1.0
5+
ARG OFT_ASCIIDOC_PLUGIN_VERSION=0.2.0
6+
7+
ENV LIB_DIR=/opt/oft/lib
8+
9+
RUN <<EOF
10+
mkdir -p $LIB_DIR
11+
base_url=https://github.com/itsallcode
12+
wget -P $LIB_DIR ${base_url}/openfasttrace/releases/download/$OFT_CORE_VERSION/openfasttrace-$OFT_CORE_VERSION.jar
13+
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
14+
EOF
15+
16+
COPY run-oft.sh /opt/oft/run-oft.sh
17+
18+
ENTRYPOINT [ "/opt/oft/run-oft.sh" ]

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
# openfasttrace-github-action
2-
GitHub Action for tracing requirements using OpenFastTrace
2+
3+
A GitHub Action for tracing requirements using OpenFastTrace.
4+
5+
Runs OpenFastTrace CLI's `trace` command using Temurin JRE 22 on the local workspace.
6+
7+
The action has the following inputs:
8+
9+
| Name | Description |
10+
| :--- | :---------- |
11+
12+
13+
The action has the following outputs:
14+
15+
| Name | Description |
16+
| :------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- |
17+
| `requirements-tracing-exit-code` | 0: OFT has run successfully and all specification items are covered<br>1: OFT has either failed to run or at least one specification item is not covered. |

action.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Perform requirements tracing against specification documents and source code using OpenFastTrace (https://github.com/itsallcode/openfasttrace)
2+
# Returns the URL of the created HTML report as an output
3+
4+
# [impl->req~run-oft-trace-command~1]
5+
name: "Run OpenFastTrace"
6+
description: |
7+
Runs OpenFastTrace with the `trace` command on files in the local workspace.
8+
inputs:
9+
file-patterns:
10+
description: |
11+
A whitespace separated list of (Bash standard) glob patterns which specify the files and directories to include in the OFT trace run.
12+
If not specified, the local workspace directory is used.
13+
default: "."
14+
required: false
15+
report-filename:
16+
description: |
17+
The name of the file that OpenFastTrace should write the analysis results to.
18+
required: true
19+
report-format:
20+
description: The format of the report that OpenFastTrace should produce.
21+
default: "plain"
22+
required: false
23+
outputs:
24+
oft-exit-code:
25+
description: |
26+
The exit code indicating the outcome of running OpenFastTrace (0: success, 1: failure).
27+
The report is created in any case, as long as OpenFastTrace could be run at all.
28+
29+
runs:
30+
using: "docker"
31+
image: "Dockerfile"
32+
args:
33+
- ${{ inputs.report-filename }}
34+
- ${{ inputs.report-format }}
35+
- ${{ inputs.file-patterns }}

doc/spec/system_requirements.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# System Requirement Specification OpenFastTrace GitHub Action
2+
3+
## Introduction
4+
5+
[OpenFastTrace](https://github.com/itsallcode/openfasttrace) (OFT) is a requirement tracing suite written in Java.
6+
The OpenFastTrace Action wraps the execution of the OpenFastTrace `trace` command in a [GitHub Action](https://docs.github.com/en/actions).
7+
8+
### Goals
9+
10+
The main goal of the OFT Action is to provide an easy way to execute OpenFastTrace as part of [CI/CD pipelines implemented by means of GitHub Actions workflows](https://docs.github.com/en/actions/about-github-actions/about-continuous-integration-with-github-actions).
11+
12+
## Features
13+
14+
### Standard GitHub Action
15+
`feat~standard-github-action~1`
16+
17+
The OFT Action is a standard GitHub Action which allows running the OpenFastTrace `trace` command on files in the local workspace.
18+
19+
Rationale:
20+
21+
Verifying that all requirements are covered by the code base is an important aspect of a CI build. Projects hosted on GitHub often use GitHub Actions based CI workflows. It has always been possible to run OFT from within a shell script executed as part of a workflow job. However, the script code tends to be rather boilerplate so it seems reasonable to provide a standard GitHub Action that can be used as easily as other already existing Actions.
22+
23+
Needs: req
24+
25+
## Functional Requirements
26+
27+
### Run OFT trace command
28+
`req~run-oft-trace-command~1`
29+
30+
The OFT Action runs the OpenFastTrace `trace` command.
31+
32+
Needs: impl

run-oft.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
# [impl->req~run-oft-trace-command~1]
4+
5+
report_file_name=$1
6+
report_format=$2
7+
files=$3
8+
9+
echo "::notice::using OpenFastTrace JARs from: ${LIB_DIR}"
10+
11+
# Run OpenFastTrace
12+
if (java -cp "${LIB_DIR}/*" \
13+
org.itsallcode.openfasttrace.core.cli.CliStarter trace -o "${report_format}" \
14+
-f "${report_file_name}" \
15+
${files})
16+
then
17+
echo "oft-exit-code=0" >> "${GITHUB_OUTPUT}"
18+
echo "All specification items are covered." >> "${GITHUB_STEP_SUMMARY}"
19+
else
20+
echo "oft-exit-code=$?" >> "${GITHUB_OUTPUT}"
21+
echo "Some specification items are not covered. See created report (${report_file_name}) for details." >> "${GITHUB_STEP_SUMMARY}"
22+
fi

0 commit comments

Comments
 (0)