-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start work for issue #201 * config: replace deno check with deno check command * refactor: update code to meet coding standards * ci: remove unnecessary env vars * ci: create scripts for release workflow * config: add item to gitignore for script output during dev testing * ci: improve build status check workflow * config: improve deno tasks * ci: create release workflow * ci: update all setup deno actions to version 2
- Loading branch information
1 parent
ca3e15f
commit f4afdd6
Showing
42 changed files
with
565 additions
and
329 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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,35 @@ | ||
import getEnvVar from "../../../cicd/core/GetEnvVar.ts"; | ||
import { Utils } from "../../../cicd/core/Utils.ts"; | ||
import DenoConfig from "../../../deno.json" with { type: "json" }; | ||
|
||
const scriptFileName = new URL(import.meta.url).pathname.split("/").pop(); | ||
|
||
if (Utils.isNothing(DenoConfig.version)) { | ||
Utils.printAsGitHubError(`The Deno version is not defined in the deno.json file.\n${scriptFileName}`); | ||
Deno.exit(1); | ||
} | ||
|
||
const githubOutputFilePath = getEnvVar("GITHUB_OUTPUT", scriptFileName); | ||
|
||
const version = (DenoConfig.version.startsWith("v") | ||
? DenoConfig.version.trim().toLocaleLowerCase() | ||
: `v${DenoConfig.version}`).trim().toLocaleLowerCase(); | ||
|
||
const versionRegex = /^v([1-9]\d*|0)\.([1-9]\d*|0)\.([1-9]\d*|0)(-preview\.([1-9]\d*))?$/gm; | ||
|
||
if (!versionRegex.test(version)) { | ||
Utils.printAsGitHubError(`The version '${version}' is not valid.\n\t\n${scriptFileName}`); | ||
Deno.exit(1); | ||
} | ||
|
||
try { | ||
Deno.writeTextFileSync(githubOutputFilePath, `version=${version}\n`, { append: true }); | ||
} catch (error) { | ||
if (error instanceof Error) { | ||
Utils.printAsGitHubError(`${error.message}\n${scriptFileName}`); | ||
} else { | ||
Utils.printAsGitHubError(`An unknown error occurred.\n${scriptFileName}`); | ||
} | ||
|
||
Deno.exit(1); | ||
} |
This file contains 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 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
101 changes: 1 addition & 100 deletions
101
.github/internal-cicd/scripts/workflow-version-status-check.ts
This file contains 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 |
---|---|---|
@@ -1,100 +1 @@ | ||
import { walkSync } from "@std/fs/walk"; | ||
import { exists } from "@std/fs/exists"; | ||
import { basename } from "@std/path/basename"; | ||
import { TagClient } from "../../../deps.ts"; | ||
import { Utils } from "../../../cicd/core/Utils.ts"; | ||
import getEnvVar from "../../../cicd/core/GetEnvVar.ts"; | ||
import { validateOrgExists, validateRepoExists } from "../../../cicd/core/Validators.ts"; | ||
|
||
const scriptFileName = new URL(import.meta.url).pathname.split("/").pop(); | ||
|
||
const ownerName = getEnvVar("OWNER_NAME", scriptFileName); | ||
const repoName = getEnvVar("REPO_NAME", scriptFileName); | ||
let baseDirPath = getEnvVar("BASE_DIR_PATH", scriptFileName); | ||
baseDirPath = Utils.normalizePath(baseDirPath); | ||
const token = getEnvVar("GITHUB_TOKEN", scriptFileName); | ||
|
||
await validateOrgExists(scriptFileName); | ||
await validateRepoExists(scriptFileName); | ||
|
||
if (!exists(baseDirPath)) { | ||
Utils.printAsGitHubError(`Directory '${baseDirPath}' does not exist.`); | ||
Deno.exit(1); | ||
} | ||
|
||
const yamlFiles = [...walkSync(baseDirPath, { | ||
includeDirs: false, | ||
includeFiles: true, | ||
exts: [".yaml", ".yml"], | ||
})].map((e) => e.path); | ||
|
||
const tagClient: TagClient = new TagClient(ownerName, repoName, token); | ||
|
||
const existingReleaseTags = (await tagClient.getAllTags()).map((t) => t.name); | ||
|
||
const workflowsToUpdate: WorkflowToUpdate[] = []; | ||
|
||
const reusableWorkflowRegex = /uses: .+.(yml|yaml)@v([1-9]\d*|0)\.([1-9]\d*|0)\.([1-9]\d*|0)(-preview\.([1-9]\d*))?/gm; | ||
|
||
type WorkflowToUpdate = { | ||
/** | ||
* The file path to the workflow. | ||
*/ | ||
filePath: string; | ||
|
||
/** | ||
* The reusable workflow references that need to be updated. | ||
*/ | ||
workflowRefs: string[]; | ||
}; | ||
|
||
// Search for workflow references with a version that has not been updated | ||
yamlFiles.forEach(yamlFile => { | ||
const workflowToUpdate: WorkflowToUpdate = { | ||
filePath: yamlFile, | ||
workflowRefs: [] | ||
}; | ||
|
||
const fileContent = Deno.readTextFileSync(yamlFile); | ||
|
||
const possibleUpdates = fileContent.match(reusableWorkflowRegex)?.map((w) => w) ?? []; | ||
|
||
// Check each reusable workflow reference version | ||
possibleUpdates.forEach(possibleUpdate => { | ||
const fullRef = possibleUpdate.split("uses:")[1].trim(); | ||
const workflowRefVersion = possibleUpdate.split("@")[1]; | ||
|
||
// If the workflow version has not been updated | ||
if (existingReleaseTags.includes(workflowRefVersion)) { | ||
workflowToUpdate.workflowRefs.push(fullRef); | ||
} | ||
}); | ||
|
||
if (workflowToUpdate.workflowRefs.length > 0) { | ||
workflowsToUpdate.push(workflowToUpdate); | ||
} | ||
}); | ||
|
||
// If there are no workflows to update, then exit | ||
if (workflowsToUpdate.length === 0) { | ||
Utils.printAsGitHubNotice("No workflows to update."); | ||
Deno.exit(0); | ||
} | ||
|
||
const errorMsgs: string[] = []; | ||
|
||
// Print out all of the workflows that need to be updated as an error | ||
workflowsToUpdate.forEach(workflowToUpdate => { | ||
const filePath = basename(workflowToUpdate.filePath); | ||
|
||
const workflowErrors: string[] = workflowToUpdate.workflowRefs.map((workflowRef) => { | ||
return `Workflow reference '${workflowRef}' in file '${filePath}' needs to be updated.`; | ||
}); | ||
|
||
errorMsgs.push(...workflowErrors); | ||
}); | ||
|
||
if (errorMsgs.length > 0) { | ||
Utils.printAsGitHubErrors(errorMsgs); | ||
Deno.exit(1); | ||
} | ||
import "../../../cicd/scripts/check-workflow-versions.ts"; |
This file contains 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 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 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 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 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
Oops, something went wrong.