Repository navigation
Add GetClangVersion and AddClangPackage workflows #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Malcolmnixon
merged 2 commits into
demaconsulting:main
from
lunarcloud:feature/45-clang-workflows
Sep 29, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
| "LINQ", | ||
| "libgcj", | ||
| "libstdc", | ||
| "llvmorg", | ||
| "maintainer", | ||
| "markdownlint", | ||
| "mermaid", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # AddClangPackage | ||
| # | ||
| # This SpdxTool workflow file adds a Clang/LLVM package entry to an SPDX | ||
| # document. The Clang/LLVM package information was attained from: | ||
| # - https://clang.llvm.org/ | ||
| # - https://github.com/llvm/llvm-project/blob/main/LICENSE.TXT | ||
| # | ||
| # Parameters: | ||
| # - spdx # SPDX document file name | ||
| # - id # Clang Package ID | ||
| # - version # Clang Package version | ||
| # | ||
| # Outputs: | ||
| # none | ||
|
|
||
| parameters: | ||
| spdx: '' | ||
| version: '' | ||
| id: 'SPDXRef-Package-Clang' | ||
|
|
||
|
|
||
| steps: | ||
|
|
||
| # Add the Clang package | ||
| - command: add-package | ||
| inputs: | ||
| spdx: ${{ spdx }} | ||
| package: | ||
| id: ${{ id }} | ||
| name: Clang | ||
| download: NOASSERTION | ||
| license: 'Apache-2.0 WITH LLVM-exception' | ||
| copyright: 'Copyright (c) LLVM Project contributors' | ||
| version: ${{ version }} | ||
| supplier: 'Organization: LLVM Project' | ||
| originator: 'Organization: LLVM Project' | ||
| homepage: https://clang.llvm.org/ | ||
| summary: >- | ||
| Clang is a C, C++, Objective-C, and Objective-C++ compiler front end built on the | ||
| LLVM compiler infrastructure, commonly used for cross-compiling embedded targets. | ||
| purl: pkg:github/llvm/llvm-project@llvmorg-${{ version }} | ||
| relationships: [] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # GetClangVersion | ||
| # | ||
| # This SpdxTool workflow file gets the version of the clang compiler. By | ||
| # default this runs 'clang' from the system path, but the 'path' parameter | ||
| # can be set to the full path of a vendor distribution binary (e.g. the Arm | ||
| # Toolchain for Embedded 'clang' executable). | ||
| # | ||
| # Parameters: | ||
| # path: # Clang program name or full path (default 'clang') | ||
| # | ||
| # Outputs: | ||
| # - version # Version of the clang compiler | ||
|
|
||
| parameters: | ||
| path: 'clang' | ||
|
|
||
|
|
||
| steps: | ||
|
|
||
| # Query the version of clang | ||
| - command: query | ||
| inputs: | ||
| output: version | ||
| pattern: 'clang version (?<value>\S+)' | ||
| program: '${{ path }}' | ||
| arguments: | ||
| - '--version' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
test/DemaConsulting.SpdxWorkflows.Tests/AddClangPackage.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| namespace DemaConsulting.SpdxWorkflows.Tests; | ||
|
|
||
| [TestClass] | ||
| public class AddClangPackage : AddPackageTest | ||
| { | ||
| [TestMethod, TestCategory("AnyOS")] | ||
| public void AddClangPackage_WithValidParameters_AddsPackageToDocument() | ||
| { | ||
| var doc = RunAddPackageWorkflow( | ||
| "AddClangPackage.yaml", | ||
| "spdx=spdx.json", | ||
| "id=SPDXRef-Package-Clang-16.0.0", | ||
| "version=16.0.0"); | ||
|
|
||
| // Verify the package was added | ||
| var package = Array.Find(doc.Packages, p => p.Id == "SPDXRef-Package-Clang-16.0.0"); | ||
| Assert.IsNotNull(package); | ||
|
|
||
| // Verify the information | ||
| Assert.AreEqual("Clang", package.Name); | ||
| Assert.AreEqual("Apache-2.0 WITH LLVM-exception", package.ConcludedLicense); | ||
| Assert.AreEqual("Copyright (c) LLVM Project contributors", package.CopyrightText); | ||
| Assert.AreEqual("16.0.0", package.Version); | ||
| Assert.AreEqual("Organization: LLVM Project", package.Supplier); | ||
| Assert.AreEqual("Organization: LLVM Project", package.Originator); | ||
| Assert.AreEqual("https://clang.llvm.org/", package.HomePage); | ||
| Assert.AreEqual( | ||
| "Clang is a C, C++, Objective-C, and Objective-C++ compiler front end built on the LLVM compiler infrastructure, commonly used for cross-compiling embedded targets.", | ||
| package.Summary); | ||
|
|
||
| // Verify the PURL | ||
| Assert.HasCount(1, package.ExternalReferences); | ||
| Assert.AreEqual(SpdxModel.SpdxReferenceCategory.PackageManager, package.ExternalReferences[0].Category); | ||
| Assert.AreEqual("purl", package.ExternalReferences[0].Type); | ||
| Assert.AreEqual("pkg:github/llvm/[email protected]", package.ExternalReferences[0].Locator); | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
test/DemaConsulting.SpdxWorkflows.Tests/GetClangVersion.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| using System.Text.RegularExpressions; | ||
|
|
||
| namespace DemaConsulting.SpdxWorkflows.Tests; | ||
|
|
||
| [TestClass] | ||
| public partial class GetClangVersion : WorkflowTest | ||
| { | ||
| [TestMethod, TestCategory("AnyOS")] | ||
| public void GetClangVersion_OnAnyOS_ReturnsVersion() | ||
| { | ||
| // Run the workflow | ||
| var exitCode = RunWorkflow( | ||
| out var output, | ||
| "GetClangVersion.yaml", | ||
| "--verbose"); | ||
|
Malcolmnixon marked this conversation as resolved.
|
||
|
|
||
| // Verify we found a valid Clang version | ||
| Assert.AreEqual(0, exitCode); | ||
| Assert.MatchesRegex(VersionRegex(), output); | ||
| } | ||
|
|
||
| [GeneratedRegex(@"version = \d+\.\d+")] | ||
| private static partial Regex VersionRegex(); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.