Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ jobs:
# Add any other essential files here

echo "Copying built artifacts..."
ACTIONS=("build-docker-image" "run-build-script-in-docker" "setup-cmake" "setup-vcpkg")
ACTIONS=("build-and-prep-ort-files" "build-docker-image" "build-minimal-ort-and-run-tests" "format-lint-check" "run-build-script-in-docker" "setup-build-tools")
BUILD_DIR_RELATIVE="build" # Relative to MAIN_REPO_PATH

for action_name in "${ACTIONS[@]}"; do
echo "Processing action: $action_name"
DEST_ACTION_DIR="actions/$action_name"
DEST_ACTION_DIR="$action_name"
DEST_DIST_DIR="$DEST_ACTION_DIR/dist"
SRC_ACTION_PATH="$MAIN_REPO_PATH/$BUILD_DIR_RELATIVE/$action_name"

Expand Down
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Ignore build output and coverage reports
build/
coverage/

# Ignore test C++ code if any
test/cpp/

# Ignore lock files (though Prettier usually skips them anyway)
package-lock.json
yarn.lock
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"tabWidth": 2,
"printWidth": 120,
"arrowParens": "always"
}
5 changes: 5 additions & 0 deletions actions/build-and-prep-ort-files/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: 'Build Full ORT and Prepare Test Files'
description: 'Installs requirements, builds full ORT wheel, installs it, and generates ORT format models and config files for minimal build tests in $RUNNER_TEMP.'
runs:
using: 'node20'
main: 'dist/index.js'
33 changes: 33 additions & 0 deletions actions/build-minimal-ort-and-run-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'Build Minimal ORT and Run Tests'
description: 'Builds minimal ORT using either a reduced Ops config file (downloaded from test_data artifact) or globally allowed types. Runs tests and uploads a binary size report.'
inputs:
reduced-ops-config-file:
description: 'Path (relative to downloaded test_data artifact) to the reduced Ops config file. Mutually exclusive with `globally_allowed_types`.'
required: false
default: ''
globally_allowed_types:
description: 'Comma-separated list of globally allowed types (e.g., "float,int32_t"). If specified, a config file is generated, and artifact download is skipped. Mutually exclusive with `reduced-ops-config-file`.'
required: false
default: ''
enable-type-reduction:
description: 'Build with type reduction enabled. Note: Type reduction happens based on the config file content (`--enable_type_reduction` during config creation), not this flag directly during the minimal build.'
required: false
default: 'false'
enable-custom-ops:
description: 'Build with custom op support enabled.'
required: false
default: 'false'
skip-model-tests:
description: 'Skip running the E2E model tests with onnx_test_runner.'
required: false
default: 'false'
binary-size-report-name-prefix:
description: 'Optional prefix for the uploaded binary size artifact name.'
required: false
default: ''
size-threshold:
description: 'Optional threshold in bytes passed to check_build_binary_size.py.'
required: false
runs:
using: 'node20'
main: 'dist/index.js'
15 changes: 15 additions & 0 deletions actions/format-lint-check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# actions/format-lint-check/README.md

# Format and Lint Check Action

## Description

This GitHub Action runs on Linux runners and performs the following tasks:

1. **Installs LLVM/Clang:** Downloads a specific version of the official LLVM release binaries (`LLVM-<version>-Linux-X64.tar.xz`) from GitHub Releases, verifies its SHA256 hash, extracts it, caches it using `@actions/tool-cache`, and adds the `bin` directory to the `PATH`.
2. **Checks C/C++ Formatting:** Uses the installed `clang-format` to verify if C/C++ source files (`.h`, `.cc`, `.cpp`) within the specified directories adhere to the formatting rules defined by `.clang-format` files (searched upwards from file locations). It fails the action if any file needs formatting.


TODO in the future it will also:
3. **Checks Shell Script Permissions:** Verifies that all found shell scripts (`.sh`) have at least one execute bit set.
4. **Checks Source/Text File Permissions:** Verifies that common source and text files (`.h`, `.cc`, `.cpp`, `.md`, `.txt`) do **not** have any execute bits set.
18 changes: 18 additions & 0 deletions actions/format-lint-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Format and Lint Check'
description: 'Installs LLVM/Clang, checks C/C++/Shell formatting and permissions on Linux.'

inputs:
llvm-version:
description: 'Required. The LLVM release tag to download (e.g., llvmorg-18.1.8).'
required: true
llvm-sha256-hash:
description: 'Required. The expected SHA256 hash of the LLVM Linux X64 tar.xz archive for verification.'
required: true
ignore-patterns:
description: 'Optional. Newline-separated list of glob patterns to ignore during file search (e.g., build/**\n**/external/**).'
required: false
default: ''

runs:
using: 'node20'
main: 'dist/index.js' # This will point to the built file later
60 changes: 60 additions & 0 deletions actions/setup-build-tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Setup Build Tools (CMake & vcpkg) Action

## Description

This GitHub Action streamlines the setup of essential C/C++ build tools by downloading, verifying, extracting, and caching specified versions of both **CMake** and **vcpkg**.

It performs the setup for CMake first, followed by vcpkg. It leverages `@actions/tool-cache` for efficiency across workflow runs. Additionally, it can automatically add the required CMake version to the system `PATH` and sets the `VCPKG_INSTALLATION_ROOT` environment variable for use in subsequent build steps.

This action combines and replaces the functionality of the previous separate `setup-cmake` and `setup-vcpkg` actions.

## Features

- Installs specific versions of CMake (including `latest`) and vcpkg (by tag).
- Supports Windows, Linux, and macOS runners.
- Verifies downloads using provided SHA512 hashes (optional for CMake, required for vcpkg).
- Integrates with GitHub Actions tool cache (`@actions/tool-cache`).
- Optionally uses the `TerrapinRetrievalTool` for accelerated and verified downloads on Windows (when hashes are provided).
- Optionally adds the installed CMake `bin` directory to the `PATH`.
- Sets the `VCPKG_INSTALLATION_ROOT` environment variable.

## Inputs

| Input | Description | Required | Default |
| :------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------: | :-------------------------------------------- |
| `cmake-version` | The CMake version to download (e.g., `3.29.0`) or the string `"latest"` to fetch the newest release via GitHub API. | `true` | - |
| `cmake-hash` | **Optional.** The expected SHA512 hash (hex) of the CMake archive for the target platform/architecture. Required for download verification and enabling Terrapin usage for CMake. | `false` | - |
| `add-cmake-to-path` | If `'true'`, adds the `bin` directory of the installed CMake version to the `PATH` environment variable. | `false` | `'true'` |
| `vcpkg-version` | The vcpkg tag version to download (e.g., `2023.10.19`). Find tags on the [vcpkg releases page](https://github.com/microsoft/vcpkg/tags). | `true` | - |
| `vcpkg-hash` | The expected SHA512 hash (hex) for the specified vcpkg tag's `.zip` archive. Required for download verification and enabling Terrapin usage for vcpkg. | `true` | - |
| `terrapin-tool-path` | Path to the `TerrapinRetrievalTool.exe` executable. Used for both CMake and vcpkg downloads on Windows if applicable (hashes provided, Terrapin not disabled). | `false` | `C:/local/Terrapin/TerrapinRetrievalTool.exe` |
| `disable-terrapin` | If set to `'true'`, Terrapin usage will be bypassed for both CMake and vcpkg, forcing direct downloads via `@actions/tool-cache`. | `false` | `'false'` |
| `github-token` | GitHub token used for fetching the `"latest"` CMake version via the GitHub API. Defaults to the workflow's token. | `false` | `${{ github.token }}` |

**Finding Hashes:** You typically need to download the specific release archive (e.g., CMake `.tar.gz`/`.zip` or vcpkg `.zip` for a tag) and calculate its SHA512 hash locally using tools like `sha512sum` (Linux/macOS) or `Get-FileHash -Algorithm SHA512` (PowerShell).

**⚠️ SECURITY WARNING:** Omitting the `cmake-hash` significantly increases the risk of supply chain attacks, as the integrity of the downloaded CMake artifact will not be checked, and Terrapin cannot be used for CMake. It is **strongly recommended** to provide `cmake-hash` whenever possible, especially for production workflows. Pinning to a specific `cmake-version` and providing its corresponding hash is the most secure approach. The `vcpkg-hash` is **required**.

## Outputs

| Output | Description |
| :----------- | :----------------------------------------------------------------------------------------------------- |
| `cmake-root` | The absolute path to the root directory of the cached CMake installation. |
| `cmake-path` | The absolute path to the directory containing the CMake executables (e.g., `.../cmake-<version>/bin`). |
| `vcpkg-root` | The absolute path to the root directory of the cached and bootstrapped vcpkg instance. |

## Environment Variables

This action sets the following environment variable for subsequent steps in the job:

- **`VCPKG_INSTALLATION_ROOT`**: The absolute path to the cached vcpkg installation directory (same value as the `vcpkg-root` output). This is commonly used by build systems like CMake (`-DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake`).

Additionally, if `add-cmake-to-path` is `'true'` (the default), the action adds the path specified by the `cmake-path` output to the system `PATH`.

## Caching

- The action utilizes `@actions/tool-cache` for caching both CMake and vcpkg installations.
- The **CMake** cache key is based on the tool name (`cmake`), the resolved `cmake-version`, and the runner's platform/architecture (e.g., `linux-x86_64`).
- The **vcpkg** cache key is based on the tool name (`vcpkg`) and the `vcpkg-version`.
- It caches the **bootstrapped** version of vcpkg, meaning the `vcpkg` executable should be present and ready to use within the cached directory.
- Subsequent workflow runs hitting the cache will be significantly faster as they skip download, verification, extraction, and bootstrapping (for vcpkg).
Loading
Loading