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
2 changes: 1 addition & 1 deletion .github.jsonnet
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local util = import '.github/jsonnet/index.jsonnet';

util.workflowJavascriptPackage(
repositories=['github', 'gynzy'],
repositories=['github'],
packageManager='pnpm',
branch='main',
isPublicFork=true,
Expand Down
2 changes: 1 addition & 1 deletion .github/jsonnet/GIT_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
48fa11c3a7d9df1e16a1cf7e86505945b0b7b6a2
545ab086d65446b210d470713a69ba3beecf28e9
10 changes: 5 additions & 5 deletions .github/jsonnet/complete-workflows.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ local yarn = import 'yarn.jsonnet';
* 2. 'publish-prod' - Production package publishing on branch push
* 3. 'pr' - Pull request preview publishing and testing
*
* @param {array} [repositories=['gynzy']] - The repositories to publish to
* @param {array} [repositories=['github']] - The repositories to publish to
* @param {boolean} [isPublicFork=true] - Whether the repository is a public fork (affects runner selection)
* @param {boolean} [checkVersionBump=true] - Whether to assert if the version was bumped (recommended)
* @param {jobs} [testJob=null] - A job to be run during PR to assert tests. Can be an array of jobs
* @param {string} [branch='main'] - The branch to run the publish-prod job on
* @param {string} [branch='main'] - The branch that triggers the publish-prod job; publishes the package <VERSION> specified in package.json and sets latest tag
* @param {string} [packageManager='yarn'] - Package manager to use ('yarn' or 'pnpm')
* @param {string} [image=null] - Docker image override for publish jobs; null uses the PM-specific default
* @param {array} [buildSteps=null] - Build steps override; null uses the PM-specific default. Pass `[]` to skip build.
* @returns {workflows} - Complete set of GitHub Actions workflows for JavaScript package lifecycle
*/
workflowJavascriptPackage(
repositories=['gynzy'],
repositories=['github'],
isPublicFork=true,
checkVersionBump=true,
testJob=null,
Expand All @@ -37,8 +37,8 @@ local yarn = import 'yarn.jsonnet';
else [base.step('build', 'yarn build')];
local effectiveBuildSteps = if buildSteps != null then buildSteps else defaultBuildSteps;
local publishJob = if packageManager == 'pnpm'
then pnpm.pnpmPublishJob(repositories=repositories, runsOn=runsOn, image=image, buildSteps=effectiveBuildSteps)
else yarn.yarnPublishJob(repositories=repositories, runsOn=runsOn, image=image, buildSteps=effectiveBuildSteps);
then pnpm.pnpmPublishJob(repositories=repositories, runsOn=runsOn, image=image, buildSteps=effectiveBuildSteps, publishBranch=branch)
else yarn.yarnPublishJob(repositories=repositories, runsOn=runsOn, image=image, buildSteps=effectiveBuildSteps, publishBranch=branch);
local previewJob = if packageManager == 'pnpm'
then pnpm.pnpmPublishPreviewJob(repositories=repositories, runsOn=runsOn, checkVersionBump=checkVersionBump, image=image, buildSteps=effectiveBuildSteps)
else yarn.yarnPublishPreviewJob(repositories=repositories, runsOn=runsOn, checkVersionBump=checkVersionBump, image=image, buildSteps=effectiveBuildSteps);
Expand Down
4 changes: 2 additions & 2 deletions .github/jsonnet/newrelic.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local pnpm = import 'pnpm.jsonnet';
*
* @param {array} apps - Array of application objects containing deployment information
* @param {string} [cacheName=null] - Name of the cache to use for yarn/pnpm dependencies
* @param {string} [source='gynzy'] - Registry source ('gynzy' or 'github') for npm packages
* @param {string} [source='github'] - Registry source ('gynzy' or 'github') for npm packages
* @param {string} [image='mirror.gcr.io/node:20.17'] - Docker image to use for the job
* @param {boolean} [useCredentials=false] - Whether to use Docker registry credentials
* @param {string} [packageManager='yarn'] - Package manager to use ('yarn' or 'pnpm')
Expand All @@ -20,7 +20,7 @@ local pnpm = import 'pnpm.jsonnet';
postReleaseToNewRelicJob(
apps,
cacheName=null,
source='gynzy',
source='github',
image='mirror.gcr.io/node:20.17',
useCredentials=false,
packageManager='yarn',
Expand Down
39 changes: 25 additions & 14 deletions .github/jsonnet/pnpm.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ local yarn = import 'yarn.jsonnet';
* @param {string} [ref=null] - Git ref to checkout (branch, tag, or commit)
* @param {boolean} [prod=false] - Whether to install only production dependencies
* @param {string} [workingDirectory=null] - Directory to run operations in
* @param {string} [source='gynzy'] - Registry source ('gynzy' or 'github')
* @param {string} [source='github'] - Registry source ('gynzy' or 'github')
* @param {array} [pnpmInstallArgs=[]] - Additional arguments for pnpm install command
* @param {boolean} [setupPnpm=true] - Whether to set up and install pnpm itself before installing all packages
* @param {boolean} [blobless=null] - Whether to perform a blobless clone (--filter=blob:none); null uses checkout default
Expand All @@ -77,7 +77,7 @@ local yarn = import 'yarn.jsonnet';
ref=null,
prod=false,
workingDirectory=null,
source='gynzy',
source='github',
pnpmInstallArgs=[],
setupPnpm=true,
blobless=null,
Expand Down Expand Up @@ -182,12 +182,13 @@ local yarn = import 'yarn.jsonnet';
* @param {array} [pnpmInstallArgs=[]] - Additional arguments for pnpm install
* @param {string} [auditLevel='moderate'] - Minimum severity level to fail the job ('low', 'moderate', 'high', 'critical')
* @param {string} [runsOn=null] - GitHub Actions runner to use for the job
* @param {string} [source='github'] - Where to install @gynzy packages from ('github', 'gynzy')
* @param {boolean} [blobless=null] - Whether to perform a blobless clone (--filter=blob:none); null uses checkout default
* @param {number} [retryAttempts=null] - Number of additional checkout attempts on failure; null uses checkout default
* @param {number} [cloneTimeout=null] - Timeout for git clone operation in minutes; null uses checkout default
* @returns {workflows} - Complete GitHub Actions pipeline configuration
*/
pnpmAuditPipeline(cacheName=null, image=null, setupPnpm=true, pnpmInstallArgs=[], auditLevel='moderate', runsOn=null, blobless=null, retryAttempts=null, cloneTimeout=null)::
pnpmAuditPipeline(cacheName=null, image=null, setupPnpm=true, pnpmInstallArgs=[], auditLevel='moderate', runsOn=null, source=null, blobless=null, retryAttempts=null, cloneTimeout=null)::
base.pipeline(
'pnpm-audit',
[
Expand All @@ -201,6 +202,7 @@ local yarn = import 'yarn.jsonnet';
ref='${{ github.event.pull_request.head.sha }}',
setupPnpm=setupPnpm,
pnpmInstallArgs=pnpmInstallArgs,
source=source,
blobless=blobless,
retryAttempts=retryAttempts,
cloneTimeout=cloneTimeout,
Expand All @@ -217,9 +219,15 @@ local yarn = import 'yarn.jsonnet';
*
* @param {boolean} [isPr=true] - Whether this is a PR build (affects versioning)
* @param {string} [ifClause=null] - Conditional expression to determine if step should run
* @param {string} [publishBranch=null] - The branch that triggers the publish-prod job; publishes the package <VERSION> specified in package.json and sets latest tag. When null, defaults to `main`/`master`
* @returns {steps} - Array containing a single step object
*/
pnpmPublish(isPr=true, ifClause=null)::
pnpmPublish(isPr=true, ifClause=null, publishBranch=null)::
local branchCheck =
if publishBranch == null then
'( "${GITHUB_REF_NAME}" == "main" || "${GITHUB_REF_NAME}" == "master" )'
else
'"${GITHUB_REF_NAME}" == "' + publishBranch + '"';
base.step(
'publish',
|||
Expand All @@ -240,7 +248,7 @@ local yarn = import 'yarn.jsonnet';
echo "Setting tag/version for release/tag build.";
PUBLISHVERSION=$VERSION;
TAG="latest";
elif [[ "${GITHUB_REF_TYPE}" == "branch" && ( "${GITHUB_REF_NAME}" == "main" || "${GITHUB_REF_NAME}" == "master" ) ]] || [[ "${GITHUB_EVENT_NAME}" == "deployment" ]]; then
elif [[ "${GITHUB_REF_TYPE}" == "branch" && %s ]] || [[ "${GITHUB_EVENT_NAME}" == "deployment" ]]; then
echo "Setting tag/version for release/tag build.";
PUBLISHVERSION=$VERSION;
TAG="latest";
Expand All @@ -253,7 +261,7 @@ local yarn = import 'yarn.jsonnet';

mv package.json.bak package.json;
';
|||,
||| % branchCheck,
env={} + (if isPr then { PR_NUMBER: '${{ github.event.number }}' } else {}),
ifClause=ifClause,
),
Expand All @@ -264,12 +272,13 @@ local yarn = import 'yarn.jsonnet';
* @param {boolean} isPr - Whether this is a PR build (affects versioning)
* @param {array} repositories - List of repository types ('gynzy' or 'github')
* @param {string} [ifClause=null] - Conditional expression to determine if steps should run
* @param {string} [publishBranch=null] - The branch that triggers the publish-prod job; publishes the package <VERSION> specified in package.json and sets latest tag. When null, defaults to `main`/`master`
* @returns {steps} - Array of step objects for publishing to all repositories
*/
pnpmPublishToRepositories(isPr, repositories, ifClause=null)::
pnpmPublishToRepositories(isPr, repositories, ifClause=null, publishBranch=null)::
(std.flatMap(function(repository)
if repository == 'gynzy' then [yarn.setGynzyNpmToken(ifClause=ifClause), self.pnpmPublish(isPr=isPr, ifClause=ifClause)]
else if repository == 'github' then [yarn.setGithubNpmToken(ifClause=ifClause), self.pnpmPublish(isPr=isPr, ifClause=ifClause)]
if repository == 'gynzy' then [yarn.setGynzyNpmToken(ifClause=ifClause), self.pnpmPublish(isPr=isPr, ifClause=ifClause, publishBranch=publishBranch)]
else if repository == 'github' then [yarn.setGithubNpmToken(ifClause=ifClause, tokenSecret='GITHUB_TOKEN'), self.pnpmPublish(isPr=isPr, ifClause=ifClause, publishBranch=publishBranch)]
else error 'Unknown repository type given.',
repositories)),

Expand All @@ -281,7 +290,7 @@ local yarn = import 'yarn.jsonnet';
* @param {string} [gitCloneRef='${{ github.event.pull_request.head.sha }}'] - Git reference to checkout
* @param {array} [buildSteps=null] - Build steps; null defaults to `[pnpm run build]`. Pass `[]` to skip build.
* @param {boolean} [checkVersionBump=true] - Whether to check if package version was bumped
* @param {array} [repositories=['gynzy']] - List of repositories to publish to
* @param {array} [repositories=['github']] - List of repositories to publish to
* @param {boolean|string} [onChangedFiles=false] - Whether to only run on changed files (or glob pattern)
* @param {string} [changedFilesHeadRef=null] - Head reference for changed files comparison
* @param {string} [changedFilesBaseRef=null] - Base reference for changed files comparison
Expand All @@ -294,7 +303,7 @@ local yarn = import 'yarn.jsonnet';
gitCloneRef='${{ github.event.pull_request.head.sha }}',
buildSteps=null,
checkVersionBump=true,
repositories=['gynzy'],
repositories=['github'],
onChangedFiles=false,
changedFilesHeadRef=null,
changedFilesBaseRef=null,
Expand Down Expand Up @@ -327,25 +336,27 @@ local yarn = import 'yarn.jsonnet';
* @param {boolean} [useCredentials=false] - Whether to use Docker registry credentials
* @param {string} [gitCloneRef='${{ github.sha }}'] - Git reference to checkout
* @param {array} [buildSteps=null] - Build steps; null defaults to `[pnpm run build]`. Pass `[]` to skip build.
* @param {array} [repositories=['gynzy']] - List of repositories to publish to
* @param {array} [repositories=['github']] - List of repositories to publish to
* @param {boolean|string} [onChangedFiles=false] - Whether to only run on changed files (or glob pattern)
* @param {string} [changedFilesHeadRef=null] - Head reference for changed files comparison
* @param {string} [changedFilesBaseRef=null] - Base reference for changed files comparison
* @param {string} [ifClause=null] - Conditional expression to determine if job should run
* @param {string} [runsOn=null] - Runner type to use
* @param {string} [publishBranch=null] - The branch that triggers the publish-prod job; publishes the package <VERSION> specified in package.json and sets latest tag. When null, defaults to `main`/`master`
* @returns {jobs} - GitHub Actions job definition
*/
pnpmPublishJob(
image='mirror.gcr.io/node:24',
useCredentials=false,
gitCloneRef='${{ github.sha }}',
buildSteps=null,
repositories=['gynzy'],
repositories=['github'],
onChangedFiles=false,
changedFilesHeadRef=null,
changedFilesBaseRef=null,
ifClause=null,
runsOn=null,
publishBranch=null,
)::
local effectiveBuildSteps = if buildSteps == null then [base.step('build', 'pnpm run build')] else buildSteps;
local stepIfClause = (if onChangedFiles != false then "steps.changes.outputs.package == 'true'" else null);
Expand All @@ -358,7 +369,7 @@ local yarn = import 'yarn.jsonnet';
[self.checkoutAndPnpm(ref=gitCloneRef, fullClone=false, source=repositories[0], pnpmInstallArgs=['--frozen-lockfile'])] +
(if onChangedFiles != false then misc.testForChangedFiles({ package: onChangedFiles }, headRef=changedFilesHeadRef, baseRef=changedFilesBaseRef) else []) +
(if onChangedFiles != false then std.map(function(step) std.map(function(s) s { 'if': stepIfClause }, step), effectiveBuildSteps) else effectiveBuildSteps) +
self.pnpmPublishToRepositories(isPr=false, repositories=repositories, ifClause=stepIfClause),
self.pnpmPublishToRepositories(isPr=false, repositories=repositories, ifClause=stepIfClause, publishBranch=publishBranch),
permissions={ packages: 'write', contents: 'read', 'pull-requests': 'read' },
ifClause=ifClause,
),
Expand Down
Loading
Loading