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
8 changes: 7 additions & 1 deletion .github/actions/setup-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ inputs:
runs:
using: composite
steps:
# Read the package's minimum supported runtime so CI validates the lowest common denominator.
- name: Read Required Node.JS Runtime
id: node-runtime
shell: bash
run: echo "runtime=$(node ./scripts/get-minimum-node-runtime.ts)" >> "$GITHUB_OUTPUT"

# Enable Node.JS in the build environment
- name: Install - Node.JS Runtime
uses: actions/setup-node@v6
with:
node-version: 24
node-version: ${{ steps.node-runtime.outputs.runtime }}

# Set up the socket firewall binary
- name: Install - Socket Firewall
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ on:
packageName:
description: 'The name of the generated NPM package.'
value: ${{ jobs.Build-Prod.outputs.packageName }}
nodeRuntime:
description: 'The Node.JS runtime version required by the project.'
value: ${{ jobs.Metadata.outputs.nodeRuntime }}

# Define each session of execution that should be executed
jobs:
Expand All @@ -49,8 +52,8 @@ jobs:
# Execute the workflow
uses: ./.github/workflows/Metadata.yml
with:
isRelease: ${{ github.event_name == 'workflow_call' && inputs.isRelease || false }}
isPrerelease: ${{ github.event_name == 'workflow_call' && inputs.isPrerelease || false }}
isRelease: ${{ inputs.isRelease || false }}
isPrerelease: ${{ inputs.isPrerelease || false }}

# Execution session that builds the artifacts that are used for deployment
Build-Prod:
Expand Down Expand Up @@ -106,7 +109,7 @@ jobs:
# Update the version of SHIELD being uploaded to have a different version number to avoid SDG version conflict
- name: Tattoo Version - Experimental Channel
if: ${{ needs.Metadata.outputs.channel != 'stable' }}
run: npm version --no-commit-hooks --no-git-tag-version "${{ needs.Metadata.outputs.version }}-${{ needs.Metadata.outputs.channel }}.${{ needs.Metadata.outputs.shortSha }}"
run: npm version --no-commit-hooks --no-git-tag-version "${{ needs.Metadata.outputs.semver }}"

# Validate package integrity before publishing (tests, coverage, and production build).
- name: Validate Package Before Publish
Expand Down
47 changes: 36 additions & 11 deletions .github/workflows/Metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ on:
version:
description: 'The version of the project that is being built.'
value: ${{ jobs.Deploy-Metadata.outputs.version }}
semver:
description: 'The semantic version of the project that is being built.'
value: ${{ jobs.Deploy-Metadata.outputs.semver }}
nodeRuntime:
description: 'The Node.JS runtime version required by the project.'
value: ${{ jobs.Deploy-Metadata.outputs.nodeRuntime }}

# Define each session of execution that should be executed
jobs:
Expand All @@ -58,13 +64,25 @@ jobs:
environment: ${{ steps.computedGitHubEnvironment.outputs.environment }}
shortSha: ${{ steps.shortSha.outputs.shortSha }}
version: ${{ steps.computedVersion.outputs.version }}
nodeRuntime: ${{ steps.computedNodeRuntime.outputs.runtime }}

# Set of actions to perform for this execution sandbox
steps:
# Download the source code
- name: Checkout Files from Repo
uses: actions/checkout@v7

# Extract the minimum supported Node.JS runtime before setting it up.
- name: Extract Required Node.JS Runtime
id: computedNodeRuntime
run: echo "runtime=$(node ./scripts/get-minimum-node-runtime.ts)" >> "$GITHUB_OUTPUT"

# Ensure npm commands run with the Node version required by the package.
- name: Set up Node.JS Runtime
uses: actions/setup-node@v7
with:
node-version: ${{ steps.computedNodeRuntime.outputs.runtime }}

# Extract the project version from the package.json
- name: Extract Project Version
id: computedVersion
Expand All @@ -84,17 +102,6 @@ jobs:
echo "channel=alpha" >> "$GITHUB_OUTPUT"
fi

# Compute the GitHub Environment to be used by the deployment
- name: Compute GitHub Environment
id: computedGitHubEnvironment
background: true
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "environment=Azure-Privileged" >> "$GITHUB_OUTPUT"
else
echo "environment=Azure-Alpha" >> "$GITHUB_OUTPUT"
fi

# Get the first 7 chars of the SHA hash that represents the current commit that the build is operating off of.
- name: Compute Short SHA - Experimental Channel
id: shortSha
Expand All @@ -104,3 +111,21 @@ jobs:
# Bring job back to sync execution by awaiting for all async jobs to finish before continuing
- name: Steps - Convert Back To Synchronous Execution
wait-all: true

# Concatenates all previous computed values to generate the semver
- name: Calculate Final Semver
id: semver
run: |
if [ "${{ steps.computedChannel.outputs.channel }}" != "stable" ]; then
echo "semver=${{ steps.computedVersion.outputs.version }}-${{ steps.computedChannel.outputs.channel }}.${{ steps.shortSha.outputs.shortSha }}" >> "$GITHUB_OUTPUT"
else
echo "semver=${{ steps.computedVersion.outputs.version }}" >> "$GITHUB_OUTPUT"
fi

# Publish the resolved project version to the GitHub Actions job summary.
- name: Publish Metadata Summary
run: |
echo "## Build Metadata" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "Project version: \`${{ steps.semver.outputs.semver }}\`" >> "$GITHUB_STEP_SUMMARY"
echo "Channel: \`${{ steps.computedChannel.outputs.channel }}\`" >> "$GITHUB_STEP_SUMMARY"
2 changes: 1 addition & 1 deletion .github/workflows/Publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
uses: actions/setup-node@v6
background: true
with:
node-version: 24
node-version: ${{ needs.Build.outputs.nodeRuntime }}

# Download the compiled server binary
- name: Download Artifact From Build Job
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/Security-Reachability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,21 @@ jobs:
# Downloads the repo at the specified depth calculated previously
- name: Clone Repo
uses: actions/checkout@v7
background: true
with:
# For PRs, fetch one additional commit for proper diff analysis
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}

# Read the package's minimum supported runtime so CI validates the lowest common denominator.
- name: Read Required Node.JS Runtime
id: node-runtime
run: echo "runtime=$(node ./scripts/get-minimum-node-runtime.ts)" >> "$GITHUB_OUTPUT"

# Set up NodeJS on the build host with caching support to optimize execution
- name: Set up Node.js
uses: actions/setup-node@v6
background: true
with:
node-version: 24
node-version: ${{ steps.node-runtime.outputs.runtime }}

# Set up Python runtime on the build host
- name: Set up Python
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.0.6",
"version": "0.0.7",
"name": "@software-hardware-integration-lab/log-engine",
"description": "Logging engine with ability to add plugins for any destination",
"author": {
Expand Down
22 changes: 22 additions & 0 deletions scripts/get-minimum-node-runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* This script is used github workflows to ensure that they run on the minimum version
* allowed in the package JSON. This centralizes node version control.
*/

import { readFileSync } from 'node:fs';

/** Gets the Node.JS runtime range declared by the package. */
const runtimeRange = JSON.parse(
readFileSync(new URL('../package.json', import.meta.url), 'utf8')
).devEngines?.runtime?.version;
if (typeof runtimeRange !== 'string') {
throw new TypeError('package.json must declare devEngines.runtime.version.');
}

/** Gets the minimum complete semantic version within the declared range. */
const minimumRuntime = runtimeRange.match(/\d+\.\d+\.\d+/)?.[0];
if (!minimumRuntime) {
throw new TypeError(`Unable to determine a minimum Node.JS runtime from "${ runtimeRange }".`);
}

process.stdout.write(minimumRuntime);
Loading