Skip to content

Commit

Permalink
Merge pull request #68 from milaboratory/v4-merge-09-10-2024
Browse files Browse the repository at this point in the history
v4-beta -> v4
  • Loading branch information
DenKoren authored Oct 9, 2024
2 parents 7809581 + 31573b2 commit 862d7ce
Show file tree
Hide file tree
Showing 22 changed files with 1,039 additions and 48 deletions.
708 changes: 708 additions & 0 deletions .github/workflows/node-simple.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion actions/aws/prefix-delete/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ runs:
fi
done
echo "Deleted all objects under the prefix ${PREFIX}"
echo "Deleted all objects under the prefix ${PREFIX}"
15 changes: 5 additions & 10 deletions actions/detect-version/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand Down Expand Up @@ -57,7 +53,7 @@ function prepareRepository(depth) {
function genDevVersion(baseVersion, baseRef) {
return __awaiter(this, void 0, void 0, function* () {
const currentRefName = process.env.GITHUB_REF_NAME;
const sanitizedRefName = utils.sanitizeVersionInput(currentRefName);
const sanitizedRefName = milib_1.version.sanitize(currentRefName);
const count = yield milib_1.git.countCommits(baseRef, 'HEAD');
return {
major: baseVersion.major,
Expand All @@ -76,8 +72,7 @@ function loadBranchVersions(targetBranch) {
const runNumber = process.env.GITHUB_RUN_NUMBER;
const currentSha = yield milib_1.git.resolveRef('HEAD');
const currentVersionStr = `${runNumber}-${currentSha.substring(0, 8)}`;
const sanitizedRefName = utils.sanitizeVersionInput(currentVersionStr);
const currentVersion = milib_1.version.parse(sanitizedRefName);
const currentVersion = milib_1.version.sanitize(currentVersionStr);
const isRelease = refType === 'branch' && refName === targetBranch;
const isBranchHead = yield utils.isBranchHead();
setOutputs({
Expand Down Expand Up @@ -107,8 +102,7 @@ function getSanitizedVersion(tag, knownVersions) {
return __awaiter(this, void 0, void 0, function* () {
const originalVersion = knownVersions[tag];
if (originalVersion && originalVersion.original) {
const sanitizedStr = utils.sanitizeVersionInput(originalVersion.original);
return milib_1.version.parse(sanitizedStr);
return milib_1.version.sanitize(originalVersion.original);
}
// Handle the case where version parsing fails or original is missing
return null;
Expand Down Expand Up @@ -242,3 +236,4 @@ function run() {
});
}
run();
// loadTagVersions(200)
17 changes: 2 additions & 15 deletions actions/detect-version/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand All @@ -32,7 +28,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.sortTagsBySemver = exports.sanitizeVersionInput = exports.isLatestMajor = exports.isBranchHead = exports.latestVersionTag = exports.getVersions = void 0;
exports.sortTagsBySemver = exports.isLatestMajor = exports.isBranchHead = exports.latestVersionTag = exports.getVersions = void 0;
const milib_1 = require("milib");
const semver = __importStar(require("semver"));
/**
Expand Down Expand Up @@ -110,15 +106,6 @@ function isLatestMajor(knownVersions, current) {
return false;
}
exports.isLatestMajor = isLatestMajor;
/**
Check an input string and replace all characters that
do not conform to semantic versioning (semver) criteria with the - character
*/
function sanitizeVersionInput(input) {
const regex = /[^0-9A-Za-z.+-]/g;
return input.replace(regex, '-');
}
exports.sanitizeVersionInput = sanitizeVersionInput;
/**
Filter out tags that are not valid semantic versions
Sort tags in descending order (newest first)
Expand Down
1 change: 1 addition & 0 deletions actions/detect-version/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,4 @@ async function run(): Promise<void> {
}

run()
// loadTagVersions(200)
2 changes: 1 addition & 1 deletion actions/docker/pl-compose/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ runs:
docker compose --file ${{ github.action_path }}/docker-compose.yaml up --detach --force-recreate
echo "Wait for the Platforma to start"
sleep "${PL_SLEEP_TIME}"
sleep "${PL_SLEEP_TIME}"
4 changes: 2 additions & 2 deletions actions/milab-shell-utils/bin/gcloud-kms-sign
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ gcloud kms asymmetric-sign \
--key ${GCP_KMS_KEY_NAME} \
--keyring ${GCP_KMS_KEYRING} \
--location ${GCP_KMS_LOCATION} \
--digest-algorithm ${GCP_KMS_DIGEST_ALGORITHM}\
--digest-algorithm ${GCP_KMS_DIGEST_ALGORITHM} \
--input-file "${file_path}" \
--signature-file "${file_sig_path}"
--signature-file "${file_sig_path}"
2 changes: 1 addition & 1 deletion actions/node/npm-pkg-status/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ runs:
uses: milaboratory/github-ci/actions/shell@v4
with:
run: |
echo "${{ fromJSON(steps.npm-pkg-status.outputs.data).exist }}"
echo "${{ fromJSON(steps.npm-pkg-status.outputs.data).exist }}"
2 changes: 1 addition & 1 deletion actions/node/prepare-pnpm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ runs:
with:
cache-hashfiles-search-path: ${{ inputs.cache-hashfiles-search-path }}
cache-version: ${{ inputs.cache-version }}
cache-save-always: ${{ inputs.cache-save-always }}
cache-save-always: ${{ inputs.cache-save-always }}
12 changes: 6 additions & 6 deletions actions/python/cache/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: |
Setup cache for a Python application
inputs:
cache-version:
version:
description: |
Simple hack, that allows to 'reset' cache for particular job.
Expand All @@ -14,13 +14,13 @@ inputs:
required: false
default: 'v1'

cache-hashfiles-search-path:
hashfiles-search-path:
description: |
Hashfiles search path for requirements.txt
required: false
default: '**/requirements.txt'

cache-save-always:
save-always:
description: |
Run the post step to save the cache even if another step before fails.
required: false
Expand All @@ -38,8 +38,8 @@ runs:
- name: Cache Python modules
uses: actions/cache@v4
with:
save-always: ${{ inputs.cache-save-always }}
save-always: ${{ inputs.save-always }}
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-${{ runner.arch }}-cache-pip-${{ inputs.cache-version }}-${{ hashFiles(inputs.cache-hashfiles-search-path) }}
key: ${{ runner.os }}-${{ runner.arch }}-cache-pip-${{ inputs.version }}-${{ hashFiles(inputs.hashfiles-search-path) }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-cache-pip-${{ inputs.cache-version }}-
${{ runner.os }}-${{ runner.arch }}-cache-pip-${{ inputs.version }}-
8 changes: 4 additions & 4 deletions actions/python/prepare/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ runs:
- name: Install Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: '${{ inputs.python-version }}
python-version: '${{ inputs.python-version }}'

- name: Setup Cache for Python project
uses: milaboratory/github-ci/actions/python/cache@v4
with:
cache-version: ${{ inputs.cache-version }}
cache-hashfiles-search-path: ${{ inputs.cache-hashfiles-search-path }}
cache-save-always: ${{ inputs.cache-save-always }}
version: ${{ inputs.cache-version }}
hashfiles-search-path: ${{ inputs.cache-hashfiles-search-path }}
save-always: ${{ inputs.cache-save-always }}
2 changes: 1 addition & 1 deletion actions/rust/prepare/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ runs:
with:
cache-version: ${{ inputs.cache-version }}
cache-hashfiles-search-path: ${{ inputs.cache-hashfiles-search-path }}
cache-save-always: ${{ inputs.cache-save-always }}
cache-save-always: ${{ inputs.cache-save-always }}
1 change: 0 additions & 1 deletion actions/setup-ninja/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ inputs:
runs:
using: 'node20'
main: 'dist/index.js'

2 changes: 1 addition & 1 deletion blocks/node/build-and-test-pnpm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ runs:
done <<<"${PNPM_ARGS}"
pnpm run ${{ inputs.test-script-name }} "${set_args[@]}"
fi
fi
118 changes: 118 additions & 0 deletions blocks/node/build/generic/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Build NodeJS application
author: 'MiLaboratories'
description: |
Prepare agent for building a NodeJS project.
Install NodeJS specific version, download package, create cache e.t.c
inputs:
build-version:
description: |
Set version number in 'package.json' file to given value.
required: false

build-script-name:
description: |
Name of script for application build
required: true
default: 'build'

node-version:
description: |
Node version to use.
Examples: '16.x', '14.x'
required: true

cache-version:
description: |
Simple hack, that allows to 'reset' cache for particular job.
Just change the value of this parameter and the next run will
not find build cache and will have to start from scratch.
required: false
default: 'v1'

hashfiles-search-path:
description: |
Hashfiles search path for package-lock.json
required: false
default: '**/package-lock.json'

is-electron-application:
description: |
If 'true' enables cache for an Electron application,
if 'false', enables cache for a generic NodeJS application.
required: false
default: 'false'

registry-url:
description: |
The npm registry url to set up for auth
and publication of the node js package.
required: false
default: 'https://npm.pkg.github.com'

scope:
description: |
Scope for authenticating against npm registries.
required: false
default: ${{ format('{0}{1}', '@', github.repository_owner) }}

npm-auth-token:
description: |
npm private registry auth token
required: false

always-auth:
description: |
Set always-auth in npmrc.
required: false
default: 'false'

runs:
using: "composite"

steps:
- name: Prepare environment for building a NodeJS application
uses: milaboratory/github-ci/actions/node/prepare@v4
with:
node-version: ${{ inputs.node-version }}
cache-version: ${{ inputs.cache-version }}
hashfiles-search-path: ${{ inputs.hashfiles-search-path }}
is-electron-application: ${{ inputs.is-electron-application }}
registry-url: ${{ inputs.registry-url }}
scope: ${{ inputs.scope }}
always-auth: ${{ inputs.always-auth }}

- name: Update npm to latest available version
uses: milaboratory/github-ci/actions/shell@v4
with:
run: |
npm i -g npm@latest
- name: Install NodeJS packages with npm
uses: milaboratory/github-ci/actions/shell@v4
env:
NODE_AUTH_TOKEN: ${{ inputs.npm-auth-token }}
with:
run: |
npm ci
- name: Patch package version
uses: milaboratory/github-ci/actions/node/patch-version@v4
with:
version: ${{ inputs.build-version }}

- name: Run build on (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
npm run ${{ inputs.build-script-name }}
- name: Run build on (macOS and Linux)
uses: milaboratory/github-ci/actions/shell@v4
if: runner.os == 'macOS' || runner.os == 'Linux'
with:
run: |
npm run ${{ inputs.build-script-name }}
2 changes: 1 addition & 1 deletion blocks/node/sign-and-publish/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,4 @@ runs:
with:
run: |
cd "${WORKING_DIRECTORY}"
npm run ${{ inputs.release-script-name }}
npm run ${{ inputs.release-script-name }}
Loading

0 comments on commit 862d7ce

Please sign in to comment.