Skip to content

Commit

Permalink
Use GitHub variable to define OFT file patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
sophokles73 committed Aug 15, 2024
1 parent 8fc85ae commit 906436c
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 28 deletions.
87 changes: 63 additions & 24 deletions .github/actions/run-oft/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ inputs:
A whitespace separated list of glob patterns which specify the files to include in the OFT trace run.
default: "**/*.*"
required: false
java-version:
description: |
The version of Java to use for running OpenFastTrace.
default: "21"
required: false
outputs:
requirements-tracing-exit-code:
description: |
Expand All @@ -41,37 +36,81 @@ outputs:
runs:
using: "composite"
steps:
- name: Prepare Environment
shell: bash
- shell: bash
run: |
# Prepare Environment
echo "TRACING_REPORT_FILE_NAME=requirements-tracing-report.html" >> $GITHUB_ENV
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ inputs.java-version }}
- name: Download OpenFastTrace JARs
shell: bash
- shell: bash
env:
OFT_REPO_BASE: "https://github.com/itsallcode"
OFT_CORE_VERSION: "4.1.0"
OFT_ASCIIDOC_PLUGIN_VERSION: "0.2.0"
LIB_DIR: ${{ github.workspace }}/lib
run: |
# Download OpenFastTrace JARs
mkdir "${LIB_DIR}"
curl -L --output-dir "${LIB_DIR}" -O \
"${OFT_REPO_BASE}/openfasttrace/releases/download/${OFT_CORE_VERSION}/openfasttrace-${OFT_CORE_VERSION}.jar"
curl -L --output-dir "${LIB_DIR}" -O \
"${OFT_REPO_BASE}/openfasttrace-asciidoc-plugin/releases/download/${OFT_ASCIIDOC_PLUGIN_VERSION}/openfasttrace-asciidoc-plugin-${OFT_ASCIIDOC_PLUGIN_VERSION}-with-dependencies.jar"
- shell: bash
env:
CLASSPATH: ${{ github.workspace }}/lib/*
run: |
mkdir "${{ github.workspace }}/lib"
curl -L -o "${{ github.workspace }}/lib/openfasttrace.jar" \
"${{ env.OFT_REPO_BASE }}/openfasttrace/releases/download/${{ env.OFT_CORE_VERSION }}/openfasttrace-${{ env.OFT_CORE_VERSION }}.jar"
curl -L -o "${{ github.workspace }}/lib/openfasttrace-asciidoc-plugin.jar" \
"${{ env.OFT_REPO_BASE }}/openfasttrace-asciidoc-plugin/releases/download/${{ env.OFT_ASCIIDOC_PLUGIN_VERSION }}/openfasttrace-asciidoc-plugin-${{ env.OFT_ASCIIDOC_PLUGIN_VERSION }}-with-dependencies.jar"
- name: Run OpenFastTrace
id: run-oft
# Verify installed JRE is sufficient for running OFT
# by default, use latest Java version
required_java_version=22
minimum_class_file_format_version=66
javap_path=$(which javap)
# determine if the installed JRE is sufficient for running OFT
if [[ -n ${javap_path} ]]; then
installed_jre_class_file_format_version=$(javap -verbose java.lang.String | grep "major version" | cut -d " " -f5)
echo "Installed JRE supports class file format version ${installed_jre_class_file_format_version}"
oft_core_class_file_format_version=$(javap -verbose -cp "${CLASSPATH}" org.itsallcode.openfasttrace.core.cli.CliStarter | grep "major version" | cut -d " " -f5)
asciidoc_plugin_class_file_format_version=$(javap -verbose -cp "${CLASSPATH}" org.itsallcode.openfasttrace.importer.asciidoc.AsciiDocImporter | grep "major version" | cut -d " " -f5)
# determine the minimum class file format version needed for running OFT
if [[ ${oft_core_class_file_format_version} -ge ${asciidoc_plugin_class_file_format_version} ]]; then
minimum_class_file_format_version=${oft_core_class_file_format_version}
else
minimum_class_file_format_version=${asciidoc_plugin_class_file_format_version}
fi
echo "OpenFastTrace requires JRE supporting class file format version ${minimum_class_file_format_version}"
# check if the installed JRE is sufficient
if [[ ${installed_jre_class_file_format_version} -lt ${minimum_class_file_format_version} ]]; then
echo "OpenFastTrace cannot be run with installed JRE, requesting installation of JDK version ${required_java_version}"
echo "REQUIRED_JAVA_VERSION=${required_java_version}" >> $GITHUB_ENV
else
echo "Installed JRE is sufficient for running OpenFastTrace"
fi
else
echo "OpenFastTrace requires a JRE, requesting installation of Java version ${required_java_version}"
# install latest Java LTS and hope for the best
echo "REQUIRED_JAVA_VERSION=${required_java_version}" >> $GITHUB_ENV
fi
- name: Set up JDK
if: ${{ env.REQUIRED_JAVA_VERSION != '' }}
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ env.REQUIRED_JAVA_VERSION }}

- id: run-oft
shell: bash
env:
CLASSPATH: ${{ github.workspace }}/lib/*
INPUT_FILE_PATTERNS: ${{ inputs.file-patterns }}
run: |
if java -cp "${{ github.workspace }}/lib/*" \
# Run OpenFastTrace
if java -cp "${CLASSPATH}" \
org.itsallcode.openfasttrace.core.cli.CliStarter trace -o html \
-f "${{ env.TRACING_REPORT_FILE_NAME }}" \
${{ env.INPUT_FILE_PATTERNS }};
-f "${TRACING_REPORT_FILE_NAME}" \
${INPUT_FILE_PATTERNS};
then
echo "requirements-tracing-exit-code=0" >> $GITHUB_OUTPUT
echo "All requirements from uProtocol Specification are covered by crate." >> $GITHUB_STEP_SUMMARY
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/check-up-spec-compatibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
# *******************************************************************************/

# Verifies that this crate can be built using the uProtocol Core API from up-spec's main branch.
# Also performs requirements tracing using OpenFastTrace
# Also performs requirements tracing using OpenFastTrace. For that purpose, the workflow requires
# the UP_SPEC_OPEN_FAST_TRACE_FILE_PATTERNS variable to contain the file patterns to use for
# invoking the "run-oft" Action.

name: uP Spec Compatibility

Expand Down Expand Up @@ -51,6 +53,8 @@ jobs:
# a tracing report
- name: Run OpenFastTrace
uses: ./.github/actions/run-oft
with:
file-patterns: ${{ vars.UP_SPEC_OPEN_FAST_TRACE_FILE_PATTERNS }}

# now try to build and run the tests which may fail if incomaptible changes
# have been introduced in up-spec
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,20 @@ jobs:

coverage:
uses: ./.github/workflows/coverage.yaml

requirements-tracing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"

- name: Run OpenFastTrace
id: run-oft
uses: ./.github/actions/run-oft
with:
file-patterns: ${{ vars.UP_SPEC_OPEN_FAST_TRACE_FILE_PATTERNS }}

- name: "Determine exit code"
run: |
exit ${{ steps.run-oft.outputs.requirements-tracing-exit-code }}
12 changes: 9 additions & 3 deletions .github/workflows/requirements-tracing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ on:
oft-file-patterns:
description: |
A whitespace separated list of glob patterns which specify the files to include in the OFT trace run.
If not specified, defaults to all files relevant for checking up-rust against the uProtocol Specification.
If not specified, defaults to the value of the `UP_SPEC_OPEN_FAST_TRACE_FILE_PATTERNS` variable.
If that variable is empty, defaults to the _run-oft_ Action's default file pattern(s).
type: string
outputs:
tracing_report_url:
description: 'URL of the requirements tracing report'
description: |
URL of the requirements tracing report.
value: ${{ jobs.tracing.outputs.requirements-tracing-report-url }}
workflow_dispatch:
pull_request:
Expand All @@ -42,11 +44,15 @@ jobs:
with:
submodules: "recursive"

- run: |
echo "inputs:"
echo "${{ inputs }}"
echo "oft-file-patterns: ${{ inputs.oft-file-patterns || 'N/A' }}"
- name: Run OpenFastTrace
id: run-oft
uses: ./.github/actions/run-oft
with:
file-patterns: ${{ inputs.oft-file-patterns || '*.md *.rs .github examples src tests tools up-spec/*.adoc up-spec/*.md up-spec/basics up-spec/up-l2/api.adoc' }}
file-patterns: ${{ inputs.oft-file-patterns || vars.UP_SPEC_OPEN_FAST_TRACE_FILE_PATTERNS }}

- name: "Determine exit code"
run: |
Expand Down

0 comments on commit 906436c

Please sign in to comment.