Skip to content

Commit 1c76bd0

Browse files
committed
RunCommandShell
1 parent f88102c commit 1c76bd0

File tree

7 files changed

+36
-93
lines changed

7 files changed

+36
-93
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
# To get started with Dependabot version updates, you'll need to specify which
2-
# package ecosystems to update and where the package manifests are located.
3-
# Please see the documentation for all configuration options:
4-
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5-
61
version: 2
72
updates:
8-
- package-ecosystem: "gomod" # See documentation for possible values
9-
directory: "/" # Location of package manifests
3+
- package-ecosystem: "gomod"
4+
directory: "/"
105
schedule:
116
interval: "daily"

.github/workflows/c-cpp.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
name: C/C++ CI
2-
# This workflow uses actions that are not certified by GitHub.
3-
# They are provided by a third-party and are governed by
4-
# separate terms of service, privacy policy, and support
5-
# documentation.
6-
7-
#name: Build
82

93
on:
104
push:
115
branches: ["master"]
126
pull_request:
137
branches: ["master"]
148

15-
# Path to the solution file relative to the root of the project.
16-
17-
# Configuration type to build.
18-
# You can convert this to a build matrix if you need coverage of multiple configuration types.
19-
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
20-
219
permissions:
2210
contents: read
2311

@@ -41,12 +29,11 @@ jobs:
4129
key: ${{ runner.os }}-vcpkg-${{ hashFiles('**/xmake.lua') }}
4230
- uses: actions/cache@v3
4331
with:
32+
key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}-${{ hashFiles('**/import_map.json') }}
4433
path: |
4534
~/.deno
4635
~/Library/Caches/deno
4736
48-
key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}
49-
5037
- name: install
5138

5239
run: |

.github/workflows/deno.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
6-
# This workflow will install Deno then run Deno lint and test.
7-
# For more information see: https://github.com/denoland/setup-deno
8-
91
name: Deno
102

113
on:
@@ -29,8 +21,8 @@ jobs:
2921
with:
3022
path: |
3123
~/.deno
32-
~/.cache/deno
33-
key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}
24+
~/.cache/deno
25+
key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}-${{ hashFiles('**/import_map.json') }}
3426

3527
- name: Setup Deno
3628

.github/workflows/go.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,3 @@ jobs:
2020

2121
- name: Test
2222
run: go test -v ./...
23-
24-
#- name: main
25-
# run: go run main.go

.github/workflows/maven.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3-
41
name: Java CI with Maven
52

63
on:

.github/workflows/udd.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
path: |
1818
~/.deno
1919
~/.cache/deno
20-
key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}
20+
key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}-${{ hashFiles('**/import_map.json') }}
2121
- uses: denoland/setup-deno@v1
2222
with:
2323
deno-version: v1.32.1
@@ -53,8 +53,8 @@ jobs:
5353
cache: maven
5454

5555
- run: |
56-
mkdir -p ./temp/ktlint
57-
wget -O ./temp/ktlint/ktlint.jar https://github.com/pinterest/ktlint/releases/download/0.49.0/ktlint
56+
mkdir -p ./temp/ktlint
57+
wget -O ./temp/ktlint/ktlint.jar https://github.com/pinterest/ktlint/releases/download/0.49.0/ktlint
5858
5959
- name: ktlint
6060
continue-on-error: true

xmake.ts

Lines changed: 28 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,22 @@ async function RunXmake(file: string, toolchain: string, sdk: string) {
4545
}
4646

4747
async function RunXmakeConfig(file: string, toolchain: string, sdk: string) {
48-
const os = Deno.build.os;
4948
console.log({ file });
50-
// console.log({ os });
51-
const cmd = os === "windows" ? "powershell.exe" : "bash";
49+
const cwd = path.dirname(file);
5250
const others = [
5351
`xmake clean `,
5452
` xmake f ${toolchain ? "--toolchain=" + toolchain : ""} ${
5553
sdk ? "--sdk=" + sdk : ""
5654
} -y -v `,
5755
];
56+
await RunCommandShell(others, cwd);
57+
}
58+
59+
async function RunCommandShell(others: string[], cwd: string) {
60+
const os = Deno.build.os;
61+
// console.log({ os });
62+
const cmd = os === "windows" ? "powershell.exe" : "bash";
63+
5864
const args = os === "windows"
5965
? [
6066
"-command",
@@ -64,78 +70,47 @@ async function RunXmakeConfig(file: string, toolchain: string, sdk: string) {
6470
"-c",
6571
others.join(" && "),
6672
];
67-
const cwd = path.dirname(file);
73+
6874
console.log(JSON.stringify({ cmd, cwd, args }));
6975
const command = new Deno.Command(cmd, { cwd: cwd, args });
7076

7177
const { success, stderr, stdout, code } = await command.output();
72-
console.log(new TextDecoder().decode(stdout));
73-
console.error(new TextDecoder().decode(stderr));
78+
const decoded = {
79+
stdout: new TextDecoder().decode(stdout),
80+
stderr: new TextDecoder().decode(stderr),
81+
};
82+
console.log(decoded.stdout);
83+
console.error(decoded.stderr);
7484
console.log({ success, code });
7585
// await writeAll(Deno.stdout, stdout);
7686
//await writeAll(Deno.stderr, stderr);
77-
assertEquals(success, true);
78-
assertEquals(code, 0);
87+
try {
88+
assertEquals(success, true);
89+
assertEquals(code, 0);
90+
} catch (error) {
91+
Object.assign(error, { success, code, ...decoded });
92+
throw error;
93+
}
7994
}
8095

8196
async function RunXmakeBuild(file: string) {
82-
const os = Deno.build.os;
97+
const cwd = path.dirname(file);
98+
8399
console.log({ file });
84100
// console.log({ os });
85-
const cmd = os === "windows" ? "powershell.exe" : "bash";
101+
86102
const others = [
87103
` xmake build -v -y -w test`,
88104
];
89-
const args = os === "windows"
90-
? [
91-
"-command",
92-
others.join(" \n "),
93-
]
94-
: [
95-
"-c",
96-
others.join(" && "),
97-
];
98-
const cwd = path.dirname(file);
99-
console.log(JSON.stringify({ cmd, cwd, args }));
100-
const command = new Deno.Command(cmd, { cwd: cwd, args });
101-
102-
const { success, stderr, stdout, code } = await command.output();
103-
console.log(new TextDecoder().decode(stdout));
104-
console.error(new TextDecoder().decode(stderr));
105-
console.log({ success, code });
106-
// await writeAll(Deno.stdout, stdout);
107-
//await writeAll(Deno.stderr, stderr);
108-
assertEquals(success, true);
109-
assertEquals(code, 0);
105+
await RunCommandShell(others, cwd);
110106
}
111107

112108
async function RunXmakeTest(file: string) {
113-
const os = Deno.build.os;
114109
console.log({ file });
115110
// console.log({ os });
116-
const cmd = os === "windows" ? "powershell.exe" : "bash";
117111
const others = [
118112
` xmake run -v test`,
119113
];
120-
const args = os === "windows"
121-
? [
122-
"-command",
123-
others.join(" \n "),
124-
]
125-
: [
126-
"-c",
127-
others.join(" && "),
128-
];
129114
const cwd = path.dirname(file);
130-
console.log(JSON.stringify({ cmd, cwd, args }));
131-
const command = new Deno.Command(cmd, { cwd: cwd, args });
132-
133-
const { success, stderr, stdout, code } = await command.output();
134-
console.log(new TextDecoder().decode(stdout));
135-
console.error(new TextDecoder().decode(stderr));
136-
console.log({ success, code });
137-
// await writeAll(Deno.stdout, stdout);
138-
//await writeAll(Deno.stderr, stderr);
139-
assertEquals(success, true);
140-
assertEquals(code, 0);
115+
await RunCommandShell(others, cwd);
141116
}

0 commit comments

Comments
 (0)