Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧Replace client code with library #183

Merged
merged 48 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
d9339fe
config: add import maps
CalvinWilkinson Oct 14, 2023
28e48f4
refactor: update imports to use import maps
CalvinWilkinson Oct 14, 2023
4f9a6a5
Merge branch 'main' into feature/175-update-client-code
CalvinWilkinson Oct 29, 2023
ef6ac44
ide: remove extension recommendation
CalvinWilkinson Nov 19, 2023
02edace
deps: setup deps.ts file with imports and exports
CalvinWilkinson Nov 19, 2023
5a563f9
refactor: update add item to project runner to use kd_clients
CalvinWilkinson Nov 19, 2023
f086da4
ci: update cicd script to use kd_clients
CalvinWilkinson Nov 19, 2023
cd8de2b
refactor: update prepare release runner to use kd clients
CalvinWilkinson Nov 19, 2023
a0f4ade
chore: improve and move Directory class
CalvinWilkinson Nov 19, 2023
2a24eac
ci: create class to simplify cli command execution
CalvinWilkinson Nov 19, 2023
b04b12e
ci: set up deno build status check with local task setup
CalvinWilkinson Nov 19, 2023
916b641
ci: move script to different folder
CalvinWilkinson Nov 19, 2023
a966498
ci: move script to different folder
CalvinWilkinson Nov 19, 2023
0e13caf
ci,deps: improve core deps and fix imports
CalvinWilkinson Nov 19, 2023
8ca975c
refactor: update cs proj resolve runner to use kd_clients
CalvinWilkinson Nov 19, 2023
3b9e260
refactor: update sync bot status check runner to use kd_clients
CalvinWilkinson Nov 19, 2023
607bd52
refactor: update sync pr to issue runner to use kd_clients
CalvinWilkinson Nov 19, 2023
c65ef17
refactor: update imports for transpile readme runner
CalvinWilkinson Nov 19, 2023
3354c52
refactor: update imports for resolve cs proj runner
CalvinWilkinson Nov 19, 2023
bb57553
refactor: update the lose milestone script to use kd_clients
CalvinWilkinson Nov 19, 2023
9b6e069
refactor: update validate github release script to use kd_clients
CalvinWilkinson Nov 19, 2023
bac5154
refactor: update label if head branch script to use kd_clients
CalvinWilkinson Nov 19, 2023
0c2f9f9
refactor: update nuget pkg does not exist script to use kd_clients
CalvinWilkinson Nov 19, 2023
4a6c06e
refactor: update validate tag script to use kd_clients
CalvinWilkinson Nov 19, 2023
de0e23c
refactor: update release tweet builder to use kd_clients
CalvinWilkinson Nov 19, 2023
a33e6b1
refactor: update csharp version service script to use kd_client
CalvinWilkinson Nov 19, 2023
65bbf4a
refactor: update the milestone-exists script to use kd_clients
CalvinWilkinson Nov 19, 2023
3ef86f0
refactor: update the github var service to use kd_clients
CalvinWilkinson Nov 19, 2023
7568a47
refactor: update prepare release runner to use kd_clients
CalvinWilkinson Nov 20, 2023
f3ce170
fix: fix other build issues
CalvinWilkinson Nov 20, 2023
daf7e33
cleanup: remove all of the old used clients
CalvinWilkinson Nov 20, 2023
85109fb
cleanup: remove unused types
CalvinWilkinson Nov 20, 2023
cb4c13c
chore: pull in models to replace locally deleted ones
CalvinWilkinson Nov 20, 2023
c65876e
cleanup: remove unused types
CalvinWilkinson Nov 20, 2023
2275dba
ide: remove config files for unused vscode extension
CalvinWilkinson Nov 20, 2023
397bc72
chore: update add item to project runner
CalvinWilkinson Nov 20, 2023
e10750b
refactor: change name of utils function
CalvinWilkinson Nov 20, 2023
97f3b3f
refactor: refactor scripts to be imported into a single module
CalvinWilkinson Nov 20, 2023
79c9a59
ci: improve deno check process by running checks async
CalvinWilkinson Nov 20, 2023
7c5616c
cleanup: refactor code to meet deno formatting rules
CalvinWilkinson Nov 20, 2023
aaddc1d
deps: update deno lock
CalvinWilkinson Nov 20, 2023
ad6da70
ci: update reusable workflow versions
CalvinWilkinson Nov 20, 2023
e82157d
deps: update kd_clients from v1.0.0-preview.4 to v1.0.0-preview.5
CalvinWilkinson Nov 22, 2023
3c5b01c
fix: update imports to use deps.ts instead of import maps
CalvinWilkinson Nov 22, 2023
764ec58
ci: add deno permission to sync workflow
CalvinWilkinson Nov 22, 2023
1f2bf59
fix: fix issue with missing arg with org client
CalvinWilkinson Nov 22, 2023
1ddc237
ci: add allow -read permission to workflow
CalvinWilkinson Nov 26, 2023
ba0092f
ide: update tasks file
CalvinWilkinson Dec 5, 2023
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
96 changes: 96 additions & 0 deletions .github/internal-cicd/scripts/deno-check.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { Directory, CLI } from "../../../deps.ts";

const ignoreDirectories = [
"./vendor/",
"./node_modules/"
];

const files: string[] = Directory
.getFiles("/", true)
.filter(f => {
const isTypeScriptFile = f.endsWith(".ts");

const shouldNotIgnore = ignoreDirectories.every(ignoreDir => !f.startsWith(ignoreDir))

return isTypeScriptFile && shouldNotIgnore;
});

const cli: CLI = new CLI();
let failed = false;

console.clear();
console.log(`Checking ${files.length} files . . .`);

/**
* Represents the result of checking a file.
*/
interface CheckResult {
file: string;
result: string;
hasPassed: boolean;
}

/**
* Checks a file using deno check.
* @param file The file to check.
* @returns A promise that resolves to a CheckResult.
*/
const checkFile = async (file: string): Promise<CheckResult> => {
let checkResult: CheckResult = {
file: file,
result: "",
hasPassed: true // Default to passed
};

checkResult.result += `Checking ${file}`;

const result = await cli.runAsync(`deno check ${file}`);

let commandResult = "";

// If the result is an error type
if (result instanceof Error)
{
checkResult.hasPassed = false;
commandResult = "❌\n";

const lines = result.message.split("\n");

// Prefix each command output line with 3 spaces
lines.forEach(line => {
commandResult += ` ${line}\n`;
});
} else {
commandResult = "✅\n";
}

checkResult.result += commandResult;

return checkResult;
}

const filesToCheck: Promise<CheckResult>[] = [];

// Perform a deno check on all of the files
for await (let file of files) {
filesToCheck.push(checkFile(file));
};

// Wait for all of the checks to complete
const allCheckResults = await Promise.all(filesToCheck);

// Print all of the results
allCheckResults.forEach(checkResult => {
Deno.stdout.writeSync(new TextEncoder().encode(checkResult.result));
});

// Collect the total number of passed and failed checks
const totalPassed = allCheckResults.filter(r => r.hasPassed).length;
const totalFailed = allCheckResults.filter(r => !r.hasPassed).length;

const resultsMsg = new TextEncoder().encode(`\nTotal Checks Passed✅: ${totalPassed}\nTotal Checks Failed❌: ${totalFailed}\n`);
Deno.stdout.writeSync(resultsMsg);

if (failed) {
Deno.exit(1);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Input } from "https://deno.land/x/[email protected]/prompt/input.ts";
import chalk from "npm:[email protected]";
import { TagClient } from "../../cicd/clients/TagClient.ts";
import { Directory } from "../../cicd/core/Directory.ts";
import { File } from "../../cicd/core/File.ts";
import { Utils } from "../../cicd/core/Utils.ts";
import { RepoClient } from "../../cicd/clients/RepoClient.ts";
import {
TagClient, RepoClient, Directory, Input
} from "../../../deps.ts";
import chalk from "../../../deps.ts";
import { File } from "../../../cicd/core/File.ts";
import { Utils } from "../../../cicd/core/Utils.ts";

if (Deno.args.length != 2) {
let errorMsg = "Invalid number of arguments.";
Expand Down Expand Up @@ -43,12 +42,14 @@ const newVersion = await Input.prompt({
}
});

const ownerName = "KinsonDigital";
const repoName = "Infrastructure";
const allFiles = Directory.getFiles(baseDirPath, true);

const yamlFiles = allFiles.filter((file) => file.toLowerCase().endsWith(".yaml") || file.toLowerCase().endsWith(".yml"));
const tagClient: TagClient = new TagClient(token);
const allTags = (await tagClient.getAllTags(repoName)).map((t) => t.name);
const tagClient: TagClient = new TagClient(ownerName, repoName, token);

const allTags = (await tagClient.getAllTags()).map((t) => t.name);

// If the new tag already exists, throw an error
if (allTags.includes(newVersion)) {
Expand Down Expand Up @@ -106,15 +107,15 @@ if (noFilesUpdated) {
}

const repoVarName = "CICD_SCRIPTS_VERSION";
const repoClient = new RepoClient(token);
const repoClient = new RepoClient(ownerName, repoName, token);

if (!(await repoClient.repoVariableExists(repoName, repoVarName))) {
if (!(await repoClient.repoVariableExists(repoVarName))) {
console.log(chalk.red(`The repository variable '${repoVarName}' does not exist.`));
Deno.exit(0);
}

const scriptVersionVar = (await repoClient.getVariables(repoName)).find((v) => v.name == repoVarName);
const scriptVersionVar = (await repoClient.getVariables()).find((v) => v.name == repoVarName);

await repoClient.updateVariable(repoName, repoVarName, newVersion);
await repoClient.updateVariable(repoVarName, newVersion);

console.log(chalk.cyan(`Updated repository variable '${repoVarName}' from version '${scriptVersionVar?.value}' to '${newVersion}'.`));
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { RepoClient } from "../../cicd/clients/RepoClient.ts";
import { TagClient } from "../../cicd/clients/TagClient.ts";
import { Directory } from "../../cicd/core/Directory.ts";
import { File } from "../../cicd/core/File.ts";
import { Path } from "../../cicd/core/Path.ts";
import { Utils } from "../../cicd/core/Utils.ts";
import { RepoClient, TagClient } from "../../../deps.ts";
import { Directory } from "../../../deps.ts";
import { File } from "../../../cicd/core/File.ts";
import { Path } from "../../../cicd/core/Path.ts";
import { Utils } from "../../../cicd/core/Utils.ts";

if (Deno.args.length != 2) {
let errorMsg = "Invalid number of arguments.";
Expand All @@ -23,13 +22,14 @@ if (!Directory.Exists(baseDirPath)) {
Deno.exit(1);
}

const ownerName = "KinsonDigital";
const repoName = "Infrastructure";
const allFiles = Directory.getFiles(baseDirPath, true);

const yamlFiles = allFiles.filter((file) => file.toLowerCase().endsWith(".yaml") || file.toLowerCase().endsWith(".yml"));
const tagClient: TagClient = new TagClient(token);
const tagClient: TagClient = new TagClient(ownerName, repoName, token);

const latestTag = (await tagClient.getAllTags(repoName))[0].name;
const latestTag = (await tagClient.getAllTags())[0].name;

const workflowsToUpdate: WorkflowToUpdate[] = [];

Expand Down Expand Up @@ -94,12 +94,12 @@ workflowsToUpdate.forEach(workflowToUpdate => {
});

const repoVarName = "CICD_SCRIPTS_VERSION";
const repoClient = new RepoClient(token);
const repoClient = new RepoClient(ownerName, repoName, token);

if (!(await repoClient.repoVariableExists(repoName, repoVarName))) {
if (!(await repoClient.repoVariableExists(repoVarName))) {
errorMsgs.push(`The repository variable '${repoVarName}' does not exist.`);
} else {
const scriptVersionVar = (await repoClient.getVariables(repoName)).find((v) => v.name == repoVarName);
const scriptVersionVar = (await repoClient.getVariables()).find((v) => v.name == repoVarName);

if (scriptVersionVar?.value === latestTag) {
let errorMsg = `The repository variable '${repoVarName}' version value `;
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/add-item-to-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
5. PAT
#>
deno run `
--allow-net `
--allow-net --allow-read `
"$scriptUrl" `
"${{ inputs.org-name }}" `
"${{ inputs.org-project-name }}" `
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/add-new-item-to-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
add_new_item_to_project:
name: Add New Issue
needs: item_number
uses: KinsonDigital/Infrastructure/.github/workflows/add-item-to-project.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/add-item-to-project.yml@v13.4.0-preview
with:
org-name: "${{ vars.ORGANIZATION_NAME }}"
org-project-name: "${{ vars.ORG_PROJECT_NAME }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-csharp-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
resolve_proj_file_path:
name: Resolving ${{ inputs.project-name }} Project File Path
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.4.0-preview
with:
project-name: ${{ inputs.project-name }}
base-path: ${{ inputs.base-path }}
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/build-status-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: ✅Build Status Check
run-name: ✅Build Status Check (${{ github.base_ref }} branch)


defaults:
run:
shell: pwsh


on:
pull_request_target:
branches: main


jobs:
build_status_check:
name: Build Status Check
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.ref }}

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: ${{ vars.DENO_VERSION }}

- name: Run Build
run: |
deno run --allow-read --allow-run "./.github/internal-cicd/scripts/deno-check.ts";
10 changes: 5 additions & 5 deletions .github/workflows/dotnet-action-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ jobs:
validate_version:
name: Validate Version
needs: [print_validate_workflow, validate_branch]
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.4.0-preview
with:
project-name: "${{ inputs.project-name }}"
release-type: "${{ inputs.release-type }}"
Expand All @@ -168,7 +168,7 @@ jobs:
validate_tag:
name: Validate Tag
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.4.0-preview
with:
project-name: "${{ inputs.project-name }}"
release-type: "${{ inputs.release-type }}"
Expand Down Expand Up @@ -207,7 +207,7 @@ jobs:
validate_github_release:
name: GitHub Release Does Not Exist
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.4.0-preview
with:
project-name: "${{ inputs.project-name }}"
version: "${{ needs.validate_version.outputs.version }}"
Expand All @@ -218,7 +218,7 @@ jobs:
build_project:
name: Build Main Project (${{ inputs.project-name }})
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.4.0-preview
with:
project-name: "${{ inputs.project-name }}"
runs-on: "${{ inputs.runs-on }}"
Expand All @@ -231,7 +231,7 @@ jobs:
run_tests:
name: Run Tests
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.4.0-preview
with:
project-name: "${{ inputs.project-name }}Tests"
runs-on: "${{ inputs.runs-on }}"
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/dotnet-lib-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:

validate_version:
name: Validate Version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.4.0-preview
with:
project-name: "${{ inputs.project-name }}"
release-type: "${{ inputs.release-type }}"
Expand All @@ -193,7 +193,7 @@ jobs:
validate_tag:
name: Validate Tag
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.4.0-preview
with:
project-name: "${{ inputs.project-name }}"
release-type: "${{ inputs.release-type }}"
Expand All @@ -205,7 +205,7 @@ jobs:
nuget_pkg_does_not_exist:
name: Validate NuGet Package Does Not Exist
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/nuget-package-does-not-exist.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/nuget-package-does-not-exist.yml@v13.4.0-preview
with:
project-name: "${{ inputs.project-name }}"
version: "${{ needs.validate_version.outputs.version }}"
Expand All @@ -214,7 +214,7 @@ jobs:
validate_milestone_status:
name: Validate Milestone Status
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-milestone-status.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-milestone-status.yml@v13.4.0-preview
with:
project-name: "${{ inputs.project-name }}"
version: "${{ needs.validate_version.outputs.version }}"
Expand All @@ -225,7 +225,7 @@ jobs:
validate_github_release:
name: GitHub Release Does Not Exist
needs: [validate_version]
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.4.0-preview
with:
project-name: "${{ inputs.project-name }}"
version: "${{ needs.validate_version.outputs.version }}"
Expand All @@ -236,7 +236,7 @@ jobs:
build_project:
name: Build Main Project
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.4.0-preview
with:
project-name: "${{ inputs.project-name }}"
runs-on: "${{ inputs.runs-on }}"
Expand All @@ -249,7 +249,7 @@ jobs:
run_tests:
name: Run Tests
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.4.0-preview
with:
project-name: "${{ inputs.project-name }}Tests"
runs-on: "${{ inputs.runs-on }}"
Expand Down Expand Up @@ -358,6 +358,7 @@ jobs:
deno run `
--allow-read --allow-net `
"$scriptUrl" `
"${{ vars.ORGANIZATION_NAME }}" `
"${{ inputs.project-name }}" `
"${{ needs.validate_version.outputs.version }}" `
"${{ secrets.cicd-pat }}";
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/initial-manual-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
5. PAT
#>
deno run `
--allow-net `
--allow-net --allow-read `
"$scriptUrl" `
"${{ vars.ORGANIZATION_NAME }}" `
"${{ vars.PROJECT_NAME }}" `
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-csharp-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
resolve_proj_file_path:
name: Resolving ${{ inputs.project-name }} Project File Path
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.3.1
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.4.0-preview
with:
project-name: ${{ inputs.project-name }}
base-path: ${{ inputs.base-path }}
Expand Down
Loading
Loading