Skip to content

Commit 229dfa8

Browse files
authored
Merge pull request #4104 from fbbdev/v3-alpha-feature/typescript-runtime-testdata
[v3] Testdata update + smarter npm workflow
2 parents fc0eb76 + 2a424f6 commit 229dfa8

File tree

468 files changed

+2934
-9001
lines changed

Some content is hidden

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

468 files changed

+2934
-9001
lines changed

.github/workflows/build-and-test-v3.yml

-44
Original file line numberDiff line numberDiff line change
@@ -26,50 +26,6 @@ jobs:
2626
echo "approved=false" >> $GITHUB_OUTPUT
2727
fi
2828
29-
check_build_artifacts:
30-
name: Check runtime build artifact changes
31-
runs-on: ubuntu-latest
32-
steps:
33-
- name: Checkout code
34-
uses: actions/checkout@v4
35-
with:
36-
persist-credentials: 'true'
37-
38-
- name: Get changed files
39-
id: changed-files
40-
uses: tj-actions/changed-files@v45
41-
with:
42-
files: |
43-
v3/internal/runtime/desktop/@wailsio/runtime/dist/**
44-
v3/internal/runtime/desktop/@wailsio/runtime/types/**
45-
46-
- name: Get merge base
47-
id: merge-base
48-
if: steps.changed-files.outputs.any_changed == 'true'
49-
env:
50-
BASE_SHA: ${{github.event.pull_request.base.sha}}
51-
HEAD_SHA: ${{github.event.pull_request.head.sha}}
52-
run: |
53-
echo "sha=$(git merge-base "$BASE_SHA" "$HEAD_SHA")" >> $GITHUB_OUTPUT
54-
55-
- name: This PR includes changes to runtime build artifacts
56-
uses: actions/github-script@v7
57-
if: steps.changed-files.outputs.any_changed == 'true'
58-
env:
59-
MERGE_BASE_SHA: ${{steps.merge-base.outputs.sha}}
60-
with:
61-
script: |
62-
process.exitCode = 1
63-
core.error(
64-
'The CI pipeline will rebuild and publish the runtime automatically.\n' +
65-
'Please run the following command (or equivalent) in your local wails repo\n' +
66-
'to revert all build artifact changes; then update the PR:\n\n' +
67-
' cd v3/internal/runtime/desktop/@wailsio/runtime &&\n' +
68-
` git restore -s ${process.env.MERGE_BASE_SHA} -W -S -- dist types &&\n` +
69-
' git commit -m "Revert build artifact changes"\n',
70-
{ title: 'This PR includes changes to runtime build artifacts' }
71-
);
72-
7329
test_js:
7430
name: Run JS Tests
7531
needs: check_approval

.github/workflows/publish-npm.yml

+48-30
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,55 @@ on:
33
branches: ['v3-alpha']
44
workflow_dispatch:
55

6+
concurrency:
7+
group: publish-npm-v3
8+
cancel-in-progress: true
9+
610
jobs:
7-
publish:
11+
detect:
12+
name: Detect committed changes
13+
if: github.event_name != 'workflow_dispatch'
14+
outputs:
15+
changed: ${{ steps.package-json-changes.outputs.any_modified == 'true' || steps.source-changes.outputs.any_modified == 'true' }}
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
ref: ${{ github.sha }}
22+
persist-credentials: 'true'
23+
24+
- name: Detect committed package.json changes
25+
id: package-json-changes
26+
uses: tj-actions/changed-files@v45
27+
with:
28+
files: |
29+
v3/internal/runtime/desktop/@wailsio/runtime/package.json
30+
31+
- name: Detect committed source changes
32+
if: >-
33+
steps.package-json-changes.outputs.any_modified != 'true'
34+
id: source-changes
35+
uses: tj-actions/changed-files@v45
36+
with:
37+
files: |
38+
v3/internal/runtime/Taskfile.yaml
39+
v3/internal/runtime/desktop/@wailsio/compiled/main.js
40+
v3/internal/runtime/desktop/@wailsio/runtime/tsconfig.json
41+
v3/internal/runtime/desktop/@wailsio/runtime/src/**
42+
v3/pkg/events/events.txt
43+
v3/tasks/events/**
44+
45+
rebuild_and_publish:
46+
name: Rebuild and publish
47+
needs: [detect]
48+
if: >-
49+
!failure() && !cancelled()
50+
&& (github.event_name == 'workflow_dispatch' || needs.detect.outputs.changed == 'true')
851
runs-on: ubuntu-latest
952
steps:
10-
- uses: actions/checkout@v4
53+
- name: Checkout code
54+
uses: actions/checkout@v4
1155
with:
1256
fetch-depth: 0
1357
ref: 'v3-alpha'
@@ -49,48 +93,22 @@ jobs:
4993
npm test
5094
npm run build
5195
52-
- name: Detect npm package changes
53-
uses: tj-actions/verify-changed-files@v20
54-
id: package-changes
55-
with:
56-
files: |
57-
v3/internal/runtime/desktop/@wailsio/runtime/dist/**
58-
v3/internal/runtime/desktop/@wailsio/runtime/types/**
59-
6096
- name: Bump version
61-
if: github.event_name == 'workflow_dispatch' || steps.package-changes.outputs.files_changed == 'true'
6297
id: bump-version
6398
working-directory: v3/internal/runtime/desktop/@wailsio/runtime
6499
run: |
65-
echo "version=$(npm version prerelease)" >> $GITHUB_OUTPUT
100+
echo "version=$(npm --no-git-tag-version --force version prerelease)" >> "$GITHUB_OUTPUT"
66101
67102
- name: Commit changes
68-
if: github.event_name == 'workflow_dispatch' || steps.package-changes.outputs.files_changed == 'true'
69103
run: |
70104
git add .
71105
git commit -m "[skip ci] Publish @wailsio/runtime ${{ steps.bump-version.outputs.version }}"
72106
git push
107+
fi
73108
74109
- name: Publish npm package
75110
uses: JS-DevTools/npm-publish@v3
76-
if: github.event_name == 'workflow_dispatch' || steps.package-changes.outputs.files_changed == 'true'
77111
with:
78112
package: v3/internal/runtime/desktop/@wailsio/runtime
79113
access: public
80114
token: ${{ secrets.NPM_TOKEN }}
81-
82-
- name: Detect docs and bundled runtime changes
83-
if: github.event_name != 'workflow_dispatch' && steps.package-changes.outputs.files_changed != 'true'
84-
uses: tj-actions/verify-changed-files@v20
85-
id: docs-bundle-changes
86-
with:
87-
files: |
88-
v3/internal/assetserver/bundledassets/**
89-
v3/internal/runtime/desktop/@wailsio/runtime/docs/**
90-
91-
- name: Commit docs and bundled runtime changes
92-
if: github.event_name != 'workflow_dispatch' && steps.package-changes.outputs.files_changed != 'true' && steps.docs-bundle-changes.outputs.files_changed == 'true'
93-
run: |
94-
git add .
95-
git commit -m "[skip ci] Update runtime docs and bundle"
96-
git push

v3/internal/generator/testdata/output/lang=JS/UseInterfaces=false/UseNames=false/encoding/json/models.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
// @ts-ignore: Unused imports
7-
import {Create as $Create} from "/wails/runtime.js";
7+
import { Create as $Create } from "/wails/runtime.js";
88

99
/**
1010
* Marshaler is the interface implemented by types that

v3/internal/generator/testdata/output/lang=JS/UseInterfaces=false/UseNames=false/encoding/models.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
// @ts-ignore: Unused imports
7-
import {Create as $Create} from "/wails/runtime.js";
7+
import { Create as $Create } from "/wails/runtime.js";
88

99
/**
1010
* TextMarshaler is the interface implemented by an object that can

v3/internal/generator/testdata/output/lang=JS/UseInterfaces=false/UseNames=false/github.com/wailsapp/wails/v3/internal/generator/testcases/aliases/greetservice.js

+13-31
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1111
// @ts-ignore: Unused imports
12-
import {Call as $Call, Create as $Create} from "/wails/runtime.js";
12+
import { Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create } from "/wails/runtime.js";
1313

1414
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1515
// @ts-ignore: Unused imports
@@ -22,81 +22,63 @@ import * as $models from "./models.js";
2222
/**
2323
* Get someone.
2424
* @param {$models.Alias} aliasValue
25-
* @returns {Promise<$models.Person> & { cancel(): void }}
25+
* @returns {$CancellablePromise<$models.Person>}
2626
*/
2727
export function Get(aliasValue) {
28-
let $resultPromise = /** @type {any} */($Call.ByID(1928502664, aliasValue));
29-
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
28+
return $Call.ByID(1928502664, aliasValue).then(/** @type {($result: any) => any} */(($result) => {
3029
return $$createType0($result);
3130
}));
32-
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
33-
return $typingPromise;
3431
}
3532

3633
/**
3734
* Apparently, aliases are all the rage right now.
3835
* @param {$models.AliasedPerson} p
39-
* @returns {Promise<$models.StrangelyAliasedPerson> & { cancel(): void }}
36+
* @returns {$CancellablePromise<$models.StrangelyAliasedPerson>}
4037
*/
4138
export function GetButAliased(p) {
42-
let $resultPromise = /** @type {any} */($Call.ByID(1896499664, p));
43-
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
39+
return $Call.ByID(1896499664, p).then(/** @type {($result: any) => any} */(($result) => {
4440
return $$createType0($result);
4541
}));
46-
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
47-
return $typingPromise;
4842
}
4943

5044
/**
5145
* Get someone quite different.
52-
* @returns {Promise<$models.GenericPerson<boolean>> & { cancel(): void }}
46+
* @returns {$CancellablePromise<$models.GenericPerson<boolean>>}
5347
*/
5448
export function GetButDifferent() {
55-
let $resultPromise = /** @type {any} */($Call.ByID(2240931744));
56-
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
49+
return $Call.ByID(2240931744).then(/** @type {($result: any) => any} */(($result) => {
5750
return $$createType1($result);
5851
}));
59-
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
60-
return $typingPromise;
6152
}
6253

6354
/**
64-
* @returns {Promise<nobindingshere$0.PrivatePerson> & { cancel(): void }}
55+
* @returns {$CancellablePromise<nobindingshere$0.PrivatePerson>}
6556
*/
6657
export function GetButForeignPrivateAlias() {
67-
let $resultPromise = /** @type {any} */($Call.ByID(643456960));
68-
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
58+
return $Call.ByID(643456960).then(/** @type {($result: any) => any} */(($result) => {
6959
return $$createType2($result);
7060
}));
71-
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
72-
return $typingPromise;
7361
}
7462

7563
/**
76-
* @returns {Promise<$models.AliasGroup> & { cancel(): void }}
64+
* @returns {$CancellablePromise<$models.AliasGroup>}
7765
*/
7866
export function GetButGenericAliases() {
79-
let $resultPromise = /** @type {any} */($Call.ByID(914093800));
80-
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
67+
return $Call.ByID(914093800).then(/** @type {($result: any) => any} */(($result) => {
8168
return $$createType3($result);
8269
}));
83-
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
84-
return $typingPromise;
8570
}
8671

8772
/**
8873
* Greet a lot of unusual things.
8974
* @param {$models.EmptyAliasStruct} $0
9075
* @param {$models.EmptyStruct} $1
91-
* @returns {Promise<$models.AliasStruct> & { cancel(): void }}
76+
* @returns {$CancellablePromise<$models.AliasStruct>}
9277
*/
9378
export function Greet($0, $1) {
94-
let $resultPromise = /** @type {any} */($Call.ByID(1411160069, $0, $1));
95-
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
79+
return $Call.ByID(1411160069, $0, $1).then(/** @type {($result: any) => any} */(($result) => {
9680
return $$createType7($result);
9781
}));
98-
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
99-
return $typingPromise;
10082
}
10183

10284
// Private type creation functions

v3/internal/generator/testdata/output/lang=JS/UseInterfaces=false/UseNames=false/github.com/wailsapp/wails/v3/internal/generator/testcases/aliases/models.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
// @ts-ignore: Unused imports
7-
import {Create as $Create} from "/wails/runtime.js";
7+
import { Create as $Create } from "/wails/runtime.js";
88

99
/**
1010
* A nice type Alias.
@@ -203,7 +203,7 @@ export class GenericPerson {
203203
* Given creation functions for each type parameter,
204204
* returns a creation function for a concrete instance
205205
* of the generic class GenericPerson.
206-
* @template T
206+
* @template [T=any]
207207
* @param {(source: any) => T} $$createParamT
208208
* @returns {($$source?: any) => GenericPerson<T>}
209209
*/

v3/internal/generator/testdata/output/lang=JS/UseInterfaces=false/UseNames=false/github.com/wailsapp/wails/v3/internal/generator/testcases/complex_expressions/config/service7.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
// @ts-ignore: Unused imports
7-
import {Call as $Call, Create as $Create} from "/wails/runtime.js";
7+
import { Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create } from "/wails/runtime.js";
88

99
/**
10-
* @returns {Promise<void> & { cancel(): void }}
10+
* @returns {$CancellablePromise<void>}
1111
*/
1212
export function TestMethod() {
13-
let $resultPromise = /** @type {any} */($Call.ByID(2241101727));
14-
return $resultPromise;
13+
return $Call.ByID(2241101727);
1514
}

v3/internal/generator/testdata/output/lang=JS/UseInterfaces=false/UseNames=false/github.com/wailsapp/wails/v3/internal/generator/testcases/complex_expressions/config/service9.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
// @ts-ignore: Unused imports
7-
import {Call as $Call, Create as $Create} from "/wails/runtime.js";
7+
import { Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create } from "/wails/runtime.js";
88

99
/**
10-
* @returns {Promise<void> & { cancel(): void }}
10+
* @returns {$CancellablePromise<void>}
1111
*/
1212
export function TestMethod2() {
13-
let $resultPromise = /** @type {any} */($Call.ByID(1556848345));
14-
return $resultPromise;
13+
return $Call.ByID(1556848345);
1514
}

v3/internal/generator/testdata/output/lang=JS/UseInterfaces=false/UseNames=false/github.com/wailsapp/wails/v3/internal/generator/testcases/complex_json/greetservice.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1111
// @ts-ignore: Unused imports
12-
import {Call as $Call, Create as $Create} from "/wails/runtime.js";
12+
import { Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create } from "/wails/runtime.js";
1313

1414
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1515
// @ts-ignore: Unused imports
@@ -19,9 +19,8 @@ import * as $models from "./models.js";
1919
* Greet does XYZ
2020
* @param {$models.Person} person
2121
* @param {$models.Embedded1} emb
22-
* @returns {Promise<string> & { cancel(): void }}
22+
* @returns {$CancellablePromise<string>}
2323
*/
2424
export function Greet(person, emb) {
25-
let $resultPromise = /** @type {any} */($Call.ByID(1411160069, person, emb));
26-
return $resultPromise;
25+
return $Call.ByID(1411160069, person, emb);
2726
}

v3/internal/generator/testdata/output/lang=JS/UseInterfaces=false/UseNames=false/github.com/wailsapp/wails/v3/internal/generator/testcases/complex_json/models.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
// @ts-ignore: Unused imports
7-
import {Create as $Create} from "/wails/runtime.js";
7+
import { Create as $Create } from "/wails/runtime.js";
88

99
export class Embedded1 {
1010
/**

v3/internal/generator/testdata/output/lang=JS/UseInterfaces=false/UseNames=false/github.com/wailsapp/wails/v3/internal/generator/testcases/complex_method/greetservice.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1111
// @ts-ignore: Unused imports
12-
import {Call as $Call, Create as $Create} from "/wails/runtime.js";
12+
import { Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create } from "/wails/runtime.js";
1313

1414
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1515
// @ts-ignore: Unused imports
@@ -25,17 +25,14 @@ import * as $models from "./models.js";
2525
* @param {{ [_: `${number}`]: boolean | null }} assoc
2626
* @param {(number | null)[]} $4
2727
* @param {string[]} other
28-
* @returns {Promise<[$models.Person, any, number[]]> & { cancel(): void }}
28+
* @returns {$CancellablePromise<[$models.Person, any, number[]]>}
2929
*/
3030
export function Greet(str, people, $2, assoc, $4, ...other) {
31-
let $resultPromise = /** @type {any} */($Call.ByID(1411160069, str, people, $2, assoc, $4, other));
32-
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
31+
return $Call.ByID(1411160069, str, people, $2, assoc, $4, other).then(/** @type {($result: any) => any} */(($result) => {
3332
$result[0] = $$createType0($result[0]);
3433
$result[2] = $$createType1($result[2]);
3534
return $result;
3635
}));
37-
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
38-
return $typingPromise;
3936
}
4037

4138
// Private type creation functions

v3/internal/generator/testdata/output/lang=JS/UseInterfaces=false/UseNames=false/github.com/wailsapp/wails/v3/internal/generator/testcases/complex_method/models.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
// @ts-ignore: Unused imports
7-
import {Create as $Create} from "/wails/runtime.js";
7+
import { Create as $Create } from "/wails/runtime.js";
88

99
/**
1010
* Person represents a person

0 commit comments

Comments
 (0)