Skip to content

Commit 5af3621

Browse files
Integrate PyOCD distribution (#22)
* Integrate PyOCD distribution * Fixup workflow * Cache downloaded tools * Exclude tool download metadata from package * Add docu and yarn caching * Debug * Further updates: - Apache 2.0 copyright - Address review comments - Use yarn cache for tool downloads - Check tool sha256 if available * Fix command line flags for cache * Remove debug output * Fix sha256sum and add --force option * Fix user-agent ---------
1 parent 80a006d commit 5af3621

File tree

11 files changed

+965
-37
lines changed

11 files changed

+965
-37
lines changed

.github/workflows/ci.yml

Lines changed: 86 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,109 @@ on:
99
- main
1010
workflow_dispatch:
1111
merge_group:
12+
release:
13+
types: [published]
1214

1315
jobs:
1416
build:
15-
name: Build, test, and package
17+
name: Build and test
1618
runs-on: [ubuntu-latest]
1719
steps:
18-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1921
with:
2022
fetch-depth: 0
2123
submodules: true
22-
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
24+
25+
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.2.0
2326
with:
24-
node-version: 20.x
27+
node-version-file: package.json
2528
registry-url: https://npm.pkg.github.com
2629
always-auth: true
30+
cache: 'yarn'
31+
2732
- name: Build
2833
env:
2934
GITHUB_TOKEN: ${{github.token}}
30-
run: yarn --frozen-lockfile
35+
run: yarn --frozen-lockfile --prefer-offline
36+
3137
- name: Test
3238
run: yarn test
33-
- name: Package desktop
39+
40+
- name: Upload dist
41+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.6.0
42+
with:
43+
name: dist
44+
path: |
45+
./dist
46+
retention-days: 1
47+
48+
package:
49+
name: Package
50+
runs-on: [ubuntu-latest]
51+
needs: build
52+
strategy:
53+
fail-fast: true
54+
matrix:
55+
target:
56+
- win32-x64
57+
- win32-arm64
58+
- linux-x64
59+
- linux-arm64
60+
- darwin-x64
61+
- darwin-arm64
62+
steps:
63+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
64+
65+
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.2.0
66+
with:
67+
node-version-file: package.json
68+
registry-url: https://npm.pkg.github.com
69+
always-auth: true
70+
cache: 'yarn'
71+
72+
- name: Download dist
73+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
74+
with:
75+
name: dist
76+
path: dist
77+
78+
- name: Cache tools
79+
uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.6
80+
with:
81+
path: tools
82+
key: tools-${{ matrix.target }}-${{ github.head_ref || github.ref_name }}
83+
restore-keys: |
84+
tools-${{ matrix.target }}-${{ github.base_ref || 'main' }}
85+
tools-${{ matrix.target }}-
86+
87+
- name: Download tools
88+
run: |
89+
yarn --frozen-lockfile --ignore-scripts --prefer-offline
90+
yarn download-tools --target ${{ matrix.target }} --no-cache
91+
92+
- name: Create vsix package
3493
run: |
35-
yarn package
36-
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
94+
yarn package --target ${{ matrix.target }}
95+
96+
- name: Upload package
97+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.6.0
3798
with:
38-
name: vsix-package
99+
name: vsix-package-${{ matrix.target }}
39100
path: ./*.vsix
40101
retention-days: 1
102+
103+
publish:
104+
name: Publish release
105+
runs-on: [ubuntu-latest]
106+
if: github.event_name == 'release'
107+
needs: package
108+
steps:
109+
- name: Download packages
110+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
111+
with:
112+
pattern: vsix-package-*
113+
114+
- name: Attach packages
115+
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
116+
with:
117+
files: "**/*.vsix"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ dist
44
*.log
55
test-workspace/*
66
!test-workspace/.vscode
7+
tools

.vscode/launch.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@
1717
],
1818
"sourceMapPathOverrides": {
1919
"webpack://?:*/*": "${workspaceFolder}/*"
20-
}
21-
}
20+
},
21+
},
22+
{
23+
"type": "node",
24+
"request": "launch",
25+
"name": "Run download-tools.ts",
26+
"skipFiles": ["<node_internals>/**"],
27+
"program": "${workspaceFolder}/scripts/download-tools.ts",
28+
"runtimeArgs": ["-r", "ts-node/register"],
29+
"args": ["pyocd"]
30+
}
2231
]
2332
}

.vscodeignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ src
1111
test-workspace
1212
tsconfig.json
1313
webpack.config.js
14+
scripts
15+
tools/**/version.txt
16+
tools/**/target.txt
17+
tools/**/sha256.txt

DEVELOPMENT.md

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,88 @@
11
# Developing this extension
22

33
## Prerequisites
4+
45
- Install **Visual Studio Code**.
56
- Install **Node.js** on your machine and ensure it is on your path.
67
- The currently recommended version is 20.x (LTS).
78
- Install **Yarn** which is used to build and execute scripts in this repository:
8-
```
9-
> npm install -g yarn
10-
```
9+
10+
```sh
11+
> npm install -g yarn
12+
```
1113

1214
## Building
1315

14-
1. Open a terminal and execute the following command to download NPM dependencies and tools, and to build the Typescript code:
15-
```
16-
> yarn
17-
```
16+
Major parts are platform independent but due to the inclusion of binary tools the resulting
17+
packages become platform-specific, i.e. for on `<target>`.
18+
19+
Supported `<target>`s are:
20+
21+
- win32-x64 (Windows, Intel, x86-64)
22+
- win32-arm64 (Windows, Arm, aarch64)
23+
- linux-x64 (Linux, Intel, x86-64)
24+
- linux-arm64 (Linux, Arm, aarch64)
25+
- darwin-x64 (MacOS, Intel, x86-64)
26+
- darwin-arm64 (MacOS, Arm, aarch64)
27+
28+
1. Open a terminal and execute the following command to download NPM dependencies and tools, and
29+
to build the Typescript code:
30+
31+
```sh
32+
> yarn
33+
```
34+
35+
2. Download binary tools
36+
37+
```sh
38+
> yarn download-tools [--target <target>] [--no-cache]
39+
```
40+
41+
If no `<target>` is specified the local system's architecture is used by default.
42+
By default, tool downloads are cached in the yarn cache (see `yarn cache dir`) to prevent
43+
recurring downloads of exact same archives on clean builds.
1844
19-
2. Package the extension as a locally installable VSIX file:
20-
```
21-
> yarn package
22-
```
45+
3. Package the extension as a locally installable VSIX file:
46+
47+
```sh
48+
> yarn package [--target <target>]
49+
```
2350
2451
## Developing
2552
26-
1. If you are developing and debugging this extension, we recommend you run the following command after an initial build:
27-
```
28-
> yarn watch
29-
```
30-
While just calling `yarn` creates a production build of the extension, running the above creates a build dedicated for debug. Additionally, it sets up a watch which detects code changes and rebuilds them incrementally.
53+
1. If you are developing and debugging this extension, we recommend you run the following command
54+
after an initial build:
55+
56+
```sh
57+
> yarn watch
58+
```
59+
60+
While just calling `yarn` creates a production build of the extension, running the above
61+
creates a build dedicated for debug. Additionally, it sets up a watch which detects code
62+
changes and rebuilds them incrementally.
3163
3264
2. Switch to the VS Code `Run and Debug` view.
65+
3366
3. Select and run `Desktop Extension`. This launches an extension host that runs this extension.
3467
3568
## Testing
3669
3770
1. Run the following command to execute all test locally:
38-
```
39-
> yarn test
40-
```
4171
42-
**Note**: At this point, no tests have been added to this repository.
72+
```sh
73+
> yarn test
74+
```
75+
76+
**Note**: At this point, no tests have been added to this repository.
77+
78+
## Updating tool dependencies
79+
80+
Tool dependencies are recorded in `package.json`:
81+
82+
```json
83+
"cmsis": {
84+
"<tool>": "[<owner>/<repo>@]<version>"
85+
}
86+
````
87+
88+
The `<version>` must match the tools release version tag.

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default [
2121
{
2222
ignores: [
2323
"dist",
24+
"scripts",
2425
"**/*.d.ts",
2526
"jest.config.js",
2627
"node_modules",

package.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"theme": "dark"
2020
},
2121
"engines": {
22+
"node": "^20.18.0",
23+
"yarn": "^1.22.0",
2224
"vscode": "^1.63.0"
2325
},
2426
"categories": [
@@ -196,7 +198,6 @@
196198
"description": "Path to *.cbuild-run.yml debug configuration file generated with CMSIS-Toolbox."
197199
}
198200
}
199-
200201
}
201202
}
202203
},
@@ -221,7 +222,8 @@
221222
},
222223
"scripts": {
223224
"prepare": "yarn run build",
224-
"clean": "git clean -f -x ./node_modules ./dist ./coverage",
225+
"download-tools": "ts-node scripts/download-tools.ts",
226+
"clean": "git clean -f -x ./node_modules ./dist ./coverage ./tools",
225227
"build": "webpack --mode production && yarn lint",
226228
"watch": "webpack -w",
227229
"lint": "eslint .",
@@ -235,18 +237,28 @@
235237
"devDependencies": {
236238
"@types/jest": "^29.5.14",
237239
"@types/node": "^20.14.8",
240+
"@types/node-fetch": "^2.6.12",
238241
"@types/vscode": "^1.63.0",
239242
"@typescript-eslint/eslint-plugin": "^8.21.0",
240243
"@typescript-eslint/parser": "^8.21.0",
241244
"@vscode/vsce": "^3.2.1",
242245
"eslint": "^9.19.0",
246+
"extract-zip": "^2.0.1",
243247
"jest": "^29.7.0",
248+
"node-fetch": "^3.3.2",
249+
"octokit": "^4.1.2",
250+
"tempfile": "^5.0.0",
251+
"ts-command-line-args": "^2.5.1",
244252
"ts-jest": "29.2.5",
245253
"ts-loader": "^9.5.2",
246254
"ts-node": "^10.9.2",
247255
"typescript": "^5.4.5",
248256
"typescript-eslint": "8.21.0",
249257
"webpack": "^5.97.1",
250-
"webpack-cli": "^6.0.1"
258+
"webpack-cli": "^6.0.1",
259+
"yargs": "^17.7.2"
260+
},
261+
"cmsis": {
262+
"pyocd": "MatthiasHertel80/[email protected]"
251263
}
252264
}

0 commit comments

Comments
 (0)