Skip to content

Commit bdf6ff6

Browse files
🚧Replace client code with library (#183)
* config: add import maps * refactor: update imports to use import maps * ide: remove extension recommendation * deps: setup deps.ts file with imports and exports * refactor: update add item to project runner to use kd_clients * ci: update cicd script to use kd_clients * refactor: update prepare release runner to use kd clients * chore: improve and move Directory class * ci: create class to simplify cli command execution * ci: set up deno build status check with local task setup * ci: move script to different folder * ci: move script to different folder * ci,deps: improve core deps and fix imports * refactor: update cs proj resolve runner to use kd_clients * refactor: update sync bot status check runner to use kd_clients * refactor: update sync pr to issue runner to use kd_clients * refactor: update imports for transpile readme runner * refactor: update imports for resolve cs proj runner * refactor: update the lose milestone script to use kd_clients * refactor: update validate github release script to use kd_clients * refactor: update label if head branch script to use kd_clients * refactor: update nuget pkg does not exist script to use kd_clients * refactor: update validate tag script to use kd_clients * refactor: update release tweet builder to use kd_clients * refactor: update csharp version service script to use kd_client * refactor: update the milestone-exists script to use kd_clients * refactor: update the github var service to use kd_clients * refactor: update prepare release runner to use kd_clients * fix: fix other build issues * cleanup: remove all of the old used clients * cleanup: remove unused types * chore: pull in models to replace locally deleted ones * cleanup: remove unused types * ide: remove config files for unused vscode extension * chore: update add item to project runner * refactor: change name of utils function * refactor: refactor scripts to be imported into a single module * ci: improve deno check process by running checks async * cleanup: refactor code to meet deno formatting rules * deps: update deno lock * ci: update reusable workflow versions * deps: update kd_clients from v1.0.0-preview.4 to v1.0.0-preview.5 * fix: update imports to use deps.ts instead of import maps * ci: add deno permission to sync workflow * fix: fix issue with missing arg with org client * ci: add allow -read permission to workflow * ide: update tasks file
1 parent 9af4e2b commit bdf6ff6

File tree

121 files changed

+1703
-5704
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+1703
-5704
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import { Directory, CLI } from "../../../deps.ts";
2+
3+
const ignoreDirectories = [
4+
"./vendor/",
5+
"./node_modules/"
6+
];
7+
8+
const files: string[] = Directory
9+
.getFiles("/", true)
10+
.filter(f => {
11+
const isTypeScriptFile = f.endsWith(".ts");
12+
13+
const shouldNotIgnore = ignoreDirectories.every(ignoreDir => !f.startsWith(ignoreDir))
14+
15+
return isTypeScriptFile && shouldNotIgnore;
16+
});
17+
18+
const cli: CLI = new CLI();
19+
let failed = false;
20+
21+
console.clear();
22+
console.log(`Checking ${files.length} files . . .`);
23+
24+
/**
25+
* Represents the result of checking a file.
26+
*/
27+
interface CheckResult {
28+
file: string;
29+
result: string;
30+
hasPassed: boolean;
31+
}
32+
33+
/**
34+
* Checks a file using deno check.
35+
* @param file The file to check.
36+
* @returns A promise that resolves to a CheckResult.
37+
*/
38+
const checkFile = async (file: string): Promise<CheckResult> => {
39+
let checkResult: CheckResult = {
40+
file: file,
41+
result: "",
42+
hasPassed: true // Default to passed
43+
};
44+
45+
checkResult.result += `Checking ${file}`;
46+
47+
const result = await cli.runAsync(`deno check ${file}`);
48+
49+
let commandResult = "";
50+
51+
// If the result is an error type
52+
if (result instanceof Error)
53+
{
54+
checkResult.hasPassed = false;
55+
commandResult = "❌\n";
56+
57+
const lines = result.message.split("\n");
58+
59+
// Prefix each command output line with 3 spaces
60+
lines.forEach(line => {
61+
commandResult += ` ${line}\n`;
62+
});
63+
} else {
64+
commandResult = "✅\n";
65+
}
66+
67+
checkResult.result += commandResult;
68+
69+
return checkResult;
70+
}
71+
72+
const filesToCheck: Promise<CheckResult>[] = [];
73+
74+
// Perform a deno check on all of the files
75+
for await (let file of files) {
76+
filesToCheck.push(checkFile(file));
77+
};
78+
79+
// Wait for all of the checks to complete
80+
const allCheckResults = await Promise.all(filesToCheck);
81+
82+
// Print all of the results
83+
allCheckResults.forEach(checkResult => {
84+
Deno.stdout.writeSync(new TextEncoder().encode(checkResult.result));
85+
});
86+
87+
// Collect the total number of passed and failed checks
88+
const totalPassed = allCheckResults.filter(r => r.hasPassed).length;
89+
const totalFailed = allCheckResults.filter(r => !r.hasPassed).length;
90+
91+
const resultsMsg = new TextEncoder().encode(`\nTotal Checks Passed✅: ${totalPassed}\nTotal Checks Failed❌: ${totalFailed}\n`);
92+
Deno.stdout.writeSync(resultsMsg);
93+
94+
if (failed) {
95+
Deno.exit(1);
96+
}

.github/internal-cicd/update-workflow-versions.ts renamed to .github/internal-cicd/scripts/update-workflow-versions.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { Input } from "https://deno.land/x/[email protected]/prompt/input.ts";
2-
import chalk from "npm:[email protected]";
3-
import { TagClient } from "../../cicd/clients/TagClient.ts";
4-
import { Directory } from "../../cicd/core/Directory.ts";
5-
import { File } from "../../cicd/core/File.ts";
6-
import { Utils } from "../../cicd/core/Utils.ts";
7-
import { RepoClient } from "../../cicd/clients/RepoClient.ts";
1+
import {
2+
TagClient, RepoClient, Directory, Input
3+
} from "../../../deps.ts";
4+
import chalk from "../../../deps.ts";
5+
import { File } from "../../../cicd/core/File.ts";
6+
import { Utils } from "../../../cicd/core/Utils.ts";
87

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

45+
const ownerName = "KinsonDigital";
4646
const repoName = "Infrastructure";
4747
const allFiles = Directory.getFiles(baseDirPath, true);
4848

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

5354
// If the new tag already exists, throw an error
5455
if (allTags.includes(newVersion)) {
@@ -106,15 +107,15 @@ if (noFilesUpdated) {
106107
}
107108

108109
const repoVarName = "CICD_SCRIPTS_VERSION";
109-
const repoClient = new RepoClient(token);
110+
const repoClient = new RepoClient(ownerName, repoName, token);
110111

111-
if (!(await repoClient.repoVariableExists(repoName, repoVarName))) {
112+
if (!(await repoClient.repoVariableExists(repoVarName))) {
112113
console.log(chalk.red(`The repository variable '${repoVarName}' does not exist.`));
113114
Deno.exit(0);
114115
}
115116

116-
const scriptVersionVar = (await repoClient.getVariables(repoName)).find((v) => v.name == repoVarName);
117+
const scriptVersionVar = (await repoClient.getVariables()).find((v) => v.name == repoVarName);
117118

118-
await repoClient.updateVariable(repoName, repoVarName, newVersion);
119+
await repoClient.updateVariable(repoVarName, newVersion);
119120

120121
console.log(chalk.cyan(`Updated repository variable '${repoVarName}' from version '${scriptVersionVar?.value}' to '${newVersion}'.`));

.github/internal-cicd/workflow-version-status-check.ts renamed to .github/internal-cicd/scripts/workflow-version-status-check.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { RepoClient } from "../../cicd/clients/RepoClient.ts";
2-
import { TagClient } from "../../cicd/clients/TagClient.ts";
3-
import { Directory } from "../../cicd/core/Directory.ts";
4-
import { File } from "../../cicd/core/File.ts";
5-
import { Path } from "../../cicd/core/Path.ts";
6-
import { Utils } from "../../cicd/core/Utils.ts";
1+
import { RepoClient, TagClient } from "../../../deps.ts";
2+
import { Directory } from "../../../deps.ts";
3+
import { File } from "../../../cicd/core/File.ts";
4+
import { Path } from "../../../cicd/core/Path.ts";
5+
import { Utils } from "../../../cicd/core/Utils.ts";
76

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

25+
const ownerName = "KinsonDigital";
2626
const repoName = "Infrastructure";
2727
const allFiles = Directory.getFiles(baseDirPath, true);
2828

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

32-
const latestTag = (await tagClient.getAllTags(repoName))[0].name;
32+
const latestTag = (await tagClient.getAllTags())[0].name;
3333

3434
const workflowsToUpdate: WorkflowToUpdate[] = [];
3535

@@ -94,12 +94,12 @@ workflowsToUpdate.forEach(workflowToUpdate => {
9494
});
9595

9696
const repoVarName = "CICD_SCRIPTS_VERSION";
97-
const repoClient = new RepoClient(token);
97+
const repoClient = new RepoClient(ownerName, repoName, token);
9898

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

104104
if (scriptVersionVar?.value === latestTag) {
105105
let errorMsg = `The repository variable '${repoVarName}' version value `;

.github/workflows/add-item-to-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
5. PAT
8787
#>
8888
deno run `
89-
--allow-net `
89+
--allow-net --allow-read `
9090
"$scriptUrl" `
9191
"${{ inputs.org-name }}" `
9292
"${{ inputs.org-project-name }}" `

.github/workflows/add-new-item-to-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
add_new_item_to_project:
3737
name: Add New Issue
3838
needs: item_number
39-
uses: KinsonDigital/Infrastructure/.github/workflows/add-item-to-project.yml@v13.3.1
39+
uses: KinsonDigital/Infrastructure/.github/workflows/add-item-to-project.yml@v13.4.0-preview
4040
with:
4141
org-name: "${{ vars.ORGANIZATION_NAME }}"
4242
org-project-name: "${{ vars.ORG_PROJECT_NAME }}"

.github/workflows/build-csharp-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
resolve_proj_file_path:
9191
name: Resolving ${{ inputs.project-name }} Project File Path
9292
needs: print_validate_workflow
93-
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.3.1
93+
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.4.0-preview
9494
with:
9595
project-name: ${{ inputs.project-name }}
9696
base-path: ${{ inputs.base-path }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: ✅Build Status Check
2+
run-name: ✅Build Status Check (${{ github.base_ref }} branch)
3+
4+
5+
defaults:
6+
run:
7+
shell: pwsh
8+
9+
10+
on:
11+
pull_request_target:
12+
branches: main
13+
14+
15+
jobs:
16+
build_status_check:
17+
name: Build Status Check
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout Repository
21+
uses: actions/checkout@v4
22+
with:
23+
repository: ${{ github.repository }}
24+
ref: ${{ github.ref }}
25+
26+
- name: Setup Deno
27+
uses: denoland/setup-deno@v1
28+
with:
29+
deno-version: ${{ vars.DENO_VERSION }}
30+
31+
- name: Run Build
32+
run: |
33+
deno run --allow-read --allow-run "./.github/internal-cicd/scripts/deno-check.ts";

.github/workflows/dotnet-action-release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ jobs:
157157
validate_version:
158158
name: Validate Version
159159
needs: [print_validate_workflow, validate_branch]
160-
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.3.1
160+
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.4.0-preview
161161
with:
162162
project-name: "${{ inputs.project-name }}"
163163
release-type: "${{ inputs.release-type }}"
@@ -168,7 +168,7 @@ jobs:
168168
validate_tag:
169169
name: Validate Tag
170170
needs: validate_version
171-
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.3.1
171+
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.4.0-preview
172172
with:
173173
project-name: "${{ inputs.project-name }}"
174174
release-type: "${{ inputs.release-type }}"
@@ -207,7 +207,7 @@ jobs:
207207
validate_github_release:
208208
name: GitHub Release Does Not Exist
209209
needs: validate_version
210-
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.3.1
210+
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.4.0-preview
211211
with:
212212
project-name: "${{ inputs.project-name }}"
213213
version: "${{ needs.validate_version.outputs.version }}"
@@ -218,7 +218,7 @@ jobs:
218218
build_project:
219219
name: Build Main Project (${{ inputs.project-name }})
220220
needs: print_validate_workflow
221-
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.3.1
221+
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.4.0-preview
222222
with:
223223
project-name: "${{ inputs.project-name }}"
224224
runs-on: "${{ inputs.runs-on }}"
@@ -231,7 +231,7 @@ jobs:
231231
run_tests:
232232
name: Run Tests
233233
needs: print_validate_workflow
234-
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.3.1
234+
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.4.0-preview
235235
with:
236236
project-name: "${{ inputs.project-name }}Tests"
237237
runs-on: "${{ inputs.runs-on }}"

.github/workflows/dotnet-lib-release.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ jobs:
182182
183183
validate_version:
184184
name: Validate Version
185-
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.3.1
185+
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.4.0-preview
186186
with:
187187
project-name: "${{ inputs.project-name }}"
188188
release-type: "${{ inputs.release-type }}"
@@ -193,7 +193,7 @@ jobs:
193193
validate_tag:
194194
name: Validate Tag
195195
needs: validate_version
196-
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.3.1
196+
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.4.0-preview
197197
with:
198198
project-name: "${{ inputs.project-name }}"
199199
release-type: "${{ inputs.release-type }}"
@@ -205,7 +205,7 @@ jobs:
205205
nuget_pkg_does_not_exist:
206206
name: Validate NuGet Package Does Not Exist
207207
needs: validate_version
208-
uses: KinsonDigital/Infrastructure/.github/workflows/nuget-package-does-not-exist.yml@v13.3.1
208+
uses: KinsonDigital/Infrastructure/.github/workflows/nuget-package-does-not-exist.yml@v13.4.0-preview
209209
with:
210210
project-name: "${{ inputs.project-name }}"
211211
version: "${{ needs.validate_version.outputs.version }}"
@@ -214,7 +214,7 @@ jobs:
214214
validate_milestone_status:
215215
name: Validate Milestone Status
216216
needs: validate_version
217-
uses: KinsonDigital/Infrastructure/.github/workflows/validate-milestone-status.yml@v13.3.1
217+
uses: KinsonDigital/Infrastructure/.github/workflows/validate-milestone-status.yml@v13.4.0-preview
218218
with:
219219
project-name: "${{ inputs.project-name }}"
220220
version: "${{ needs.validate_version.outputs.version }}"
@@ -225,7 +225,7 @@ jobs:
225225
validate_github_release:
226226
name: GitHub Release Does Not Exist
227227
needs: [validate_version]
228-
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.3.1
228+
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.4.0-preview
229229
with:
230230
project-name: "${{ inputs.project-name }}"
231231
version: "${{ needs.validate_version.outputs.version }}"
@@ -236,7 +236,7 @@ jobs:
236236
build_project:
237237
name: Build Main Project
238238
needs: print_validate_workflow
239-
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.3.1
239+
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.4.0-preview
240240
with:
241241
project-name: "${{ inputs.project-name }}"
242242
runs-on: "${{ inputs.runs-on }}"
@@ -249,7 +249,7 @@ jobs:
249249
run_tests:
250250
name: Run Tests
251251
needs: print_validate_workflow
252-
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.3.1
252+
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.4.0-preview
253253
with:
254254
project-name: "${{ inputs.project-name }}Tests"
255255
runs-on: "${{ inputs.runs-on }}"
@@ -358,6 +358,7 @@ jobs:
358358
deno run `
359359
--allow-read --allow-net `
360360
"$scriptUrl" `
361+
"${{ vars.ORGANIZATION_NAME }}" `
361362
"${{ inputs.project-name }}" `
362363
"${{ needs.validate_version.outputs.version }}" `
363364
"${{ secrets.cicd-pat }}";

.github/workflows/initial-manual-sync.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
5. PAT
104104
#>
105105
deno run `
106-
--allow-net `
106+
--allow-net --allow-read `
107107
"$scriptUrl" `
108108
"${{ vars.ORGANIZATION_NAME }}" `
109109
"${{ vars.PROJECT_NAME }}" `

.github/workflows/run-csharp-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
resolve_proj_file_path:
9393
name: Resolving ${{ inputs.project-name }} Project File Path
9494
needs: print_validate_workflow
95-
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.3.1
95+
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.4.0-preview
9696
with:
9797
project-name: ${{ inputs.project-name }}
9898
base-path: ${{ inputs.base-path }}

0 commit comments

Comments
 (0)