Skip to content

Commit 9518840

Browse files
authored
Merge pull request #114 from bcmi-labs/gh-actions
Gh actions
2 parents f6f6cb2 + 6bb852c commit 9518840

25 files changed

+2229
-1757
lines changed

.github/workflows/build.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Arduino Pro IDE
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- 'v[0-9]+.[0-9]+.[0-9]+*'
9+
pull_request:
10+
branches:
11+
- master
12+
schedule:
13+
- cron: '0 3 * * *' # run every day at 3AM (https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
14+
15+
env:
16+
IS_NIGHTLY: ${{ github.event_name == 'schedule' || github.head_ref == 'gh-actions' }} # TODO: remove OR once PR is merged.
17+
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
18+
19+
jobs:
20+
build:
21+
strategy:
22+
matrix:
23+
config:
24+
- os: windows-2016
25+
- os: ubuntu-latest
26+
- os: turin-macmini # self-hosted macOS
27+
28+
runs-on: ${{ matrix.config.os }}
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
34+
- name: Install Node.js 10.x
35+
uses: actions/setup-node@v1
36+
with:
37+
node-version: '10.x'
38+
registry-url: 'https://registry.npmjs.org'
39+
40+
- name: Install Python 2.7
41+
uses: actions/setup-python@v2
42+
with:
43+
python-version: '2.7'
44+
45+
- name: Build
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
49+
run: yarn
50+
51+
- name: Test
52+
run: yarn test
53+
54+
- name: Package
55+
shell: bash
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://github.com/Microsoft/vscode/issues/28434#issuecomment-346199674
59+
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
60+
AC_USERNAME: ${{ secrets.AC_USERNAME }}
61+
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
62+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
63+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
64+
run: |
65+
if [ "$RUNNER_OS" == "macOS" ]; then
66+
echo ">>> Detected macOS runner. Updating keychain for the app signing..."
67+
echo "${{ secrets.KEYCHAIN }}" | base64 --decode > ~/Library/Keychains/apple-developer.keychain-db
68+
security list-keychains -s ~/Library/Keychains/apple-developer.keychain-db
69+
security unlock-keychain -p "${{ secrets.KEYCHAIN_PASSWORD }}" ~/Library/Keychains/apple-developer.keychain-db
70+
echo "<<< The keychain has been successfully updated."
71+
fi
72+
yarn --cwd ./electron/packager/
73+
yarn --cwd ./electron/packager/ package
74+
75+
- name: Upload [GitHub Actions]
76+
uses: actions/upload-artifact@v2
77+
with:
78+
name: ${{ runner.os }}
79+
path: electron/build/dist/build-artifacts/
80+
81+
- name: Upload [S3]
82+
if: env.IS_NIGHTLY == 'true'
83+
uses: kittaakos/upload-s3-action@v0.0.1
84+
with:
85+
aws_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
86+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
87+
aws_bucket: ${{ secrets.DOWNLOADS_BUCKET }}
88+
source_dir: electron/build/dist/build-artifacts/
89+
destination_dir: arduino-pro-ide/nightly/

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{
1414
"type": "node",
1515
"request": "launch",
16-
"name": "Launch Electron Packager",
16+
"name": "Electron Packager",
1717
"program": "${workspaceRoot}/electron/packager/index.js",
1818
"cwd": "${workspaceFolder}/electron/packager"
1919
},

arduino-ide-extension/scripts/download-cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
(() => {
1212

13-
const DEFAULT_VERSION = '0.9.0'; // require('moment')().format('YYYYMMDD');
13+
const DEFAULT_VERSION = '0.11.0'; // require('moment')().format('YYYYMMDD');
1414

1515
const path = require('path');
1616
const shell = require('shelljs');

arduino-ide-extension/scripts/generate-protocol.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@
3535
}
3636
}
3737

38-
shell.echo('Generating TS/JS API from:');
38+
shell.echo('>>> Generating TS/JS API from:');
3939
if (shell.exec(`git -C ${repository} rev-parse --abbrev-ref HEAD`).code !== 0) {
4040
shell.exit(1);
4141
}
42-
if (shell.exec(`git -C ${repository} rev-parse --short HEAD`).code !== 0) {
43-
shell.exit(1);
44-
}
4542

4643
const pluginExec = shell.which('grpc_tools_node_protoc_plugin');
4744
if (!pluginExec || pluginExec.code !== 0) {
@@ -86,6 +83,6 @@ ${protos.join(' ')}`).code !== 0) {
8683
shell.exit(1);
8784
}
8885

89-
shell.echo('Done.');
86+
shell.echo('<<< Generation was successful.');
9087

9188
})();

arduino-ide-extension/src/browser/arduino-commands.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ export namespace ArduinoCommands {
3838
id: 'arduino-open-file'
3939
}
4040

41+
/**
42+
* Unlike `OPEN_SKETCH`, it opens all files from a sketch folder. (ino, cpp, etc...)
43+
*/
44+
export const OPEN_SKETCH_FILES: Command = {
45+
id: 'arduino-open-sketch-files'
46+
}
47+
4148
export const SAVE_SKETCH: Command = {
4249
id: 'arduino-save-file'
4350
}

arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
322322
}
323323
});
324324

325+
registry.registerCommand(ArduinoCommands.OPEN_SKETCH_FILES, {
326+
execute: async (uri: string) => {
327+
this.openSketchFiles(uri);
328+
}
329+
});
330+
325331
registry.registerCommand(ArduinoCommands.SAVE_SKETCH, {
326332
isVisible: widget => ArduinoToolbar.is(widget) && widget.side === 'left',
327333
execute: (sketch: Sketch) => {
@@ -548,7 +554,7 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
548554
});
549555
}
550556

551-
async openSketchFiles(uri: string): Promise<void> {
557+
protected async openSketchFiles(uri: string): Promise<void> {
552558
const uris = await this.sketchService.getSketchFiles(uri);
553559
for (const uri of uris) {
554560
await this.editorManager.open(new URI(uri));

arduino-ide-extension/src/browser/customization/arduino-frontend-application.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { injectable, inject } from 'inversify';
22
import { FileSystem } from '@theia/filesystem/lib/common/filesystem';
3+
import { CommandService } from '@theia/core/lib/common/command';
34
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
45
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
56
import { EditorMode } from '../editor-mode';
6-
import { ArduinoFrontendContribution } from '../arduino-frontend-contribution';
7+
import { ArduinoCommands } from '../arduino-commands';
78

89
@injectable()
910
export class ArduinoFrontendApplication extends FrontendApplication {
@@ -14,8 +15,8 @@ export class ArduinoFrontendApplication extends FrontendApplication {
1415
@inject(WorkspaceService)
1516
protected readonly workspaceService: WorkspaceService;
1617

17-
@inject(ArduinoFrontendContribution)
18-
protected readonly frontendContribution: ArduinoFrontendContribution;
18+
@inject(CommandService)
19+
protected readonly commandService: CommandService;
1920

2021
@inject(EditorMode)
2122
protected readonly editorMode: EditorMode;
@@ -30,7 +31,7 @@ export class ArduinoFrontendApplication extends FrontendApplication {
3031
for (const root of roots) {
3132
const exists = await this.fileSystem.exists(root.uri);
3233
if (exists) {
33-
await this.frontendContribution.openSketchFiles(root.uri);
34+
await this.commandService.executeCommand(ArduinoCommands.OPEN_SKETCH_FILES.id, root.uri);
3435
}
3536
}
3637
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { join } from 'path';
22
import { homedir } from 'os';
33
import { injectable } from 'inversify';
4-
import { EnvVariablesServerImpl } from '@theia/core/lib/node/env-variables/env-variables-server';
54
import { FileUri } from '@theia/core/lib/node/file-uri';
5+
import { EnvVariablesServerImpl } from '@theia/core/lib/node/env-variables/env-variables-server';
6+
import { BackendApplicationConfigProvider } from '@theia/core/lib/node/backend-application-config-provider';
67

78
@injectable()
89
export class ArduinoEnvVariablesServer extends EnvVariablesServerImpl {
910

10-
protected readonly configDirUri = FileUri.create(join(homedir(), '.arduinoProIDE')).toString();
11+
protected readonly configDirUri = FileUri.create(join(homedir(), BackendApplicationConfigProvider.get().configDirName)).toString();
1112

1213
}

arduino-ide-extension/src/node/boards-service-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export class BoardsServiceImpl implements BoardsService {
220220
resolve(resp);
221221
}));
222222

223-
const requiredTools = resp.getRequiredToolsList().map(t => <Tool>{
223+
const requiredTools = resp.getToolsdependenciesList().map(t => <Tool>{
224224
name: t.getName(),
225225
packager: t.getPackager(),
226226
version: t.getVersion()

arduino-ide-extension/src/test/node/arduino-daemon-impl.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SilentArduinoDaemonImpl extends ArduinoDaemonImpl {
3636
const destDir = track.mkdirSync();
3737
await spawnCommand(`"${cliPath}"`, ['config', 'init', '--dest-dir', destDir]);
3838
const content = fs.readFileSync(path.join(destDir, CLI_CONFIG), { encoding: 'utf8' });
39-
const cliConfig = safeLoad(content);
39+
const cliConfig = safeLoad(content) as any;
4040
cliConfig.daemon.port = String(this.port);
4141
const modifiedContent = safeDump(cliConfig);
4242
fs.writeFileSync(path.join(destDir, CLI_CONFIG), modifiedContent, { encoding: 'utf8' });

azure-pipelines.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

electron-app/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
}
4545
}
4646
},
47+
"backend": {
48+
"config": {
49+
"configDirName": ".arduinoProIDE"
50+
}
51+
},
4752
"generator": {
4853
"config": {
4954
"preloadTemplate": "<div class='theia-preload' style='background-color: rgb(237, 241, 242);'></div>"

electron/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ One has to manually publish the GitHub release.
4848

4949
- Select `Publish release`.
5050
-
51+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.cs.allow-jit</key>
6+
<true/>
7+
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
8+
<true/>
9+
<key>com.apple.security.cs.disable-library-validation</key>
10+
<true/>
11+
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
12+
<true/>
13+
</dict>
14+
</plist>

electron/build/scripts/arduino-pro-ide-electron-main.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

electron/build/scripts/notarize.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const isCI = require('is-ci');
2+
const { notarize } = require('electron-notarize');
3+
4+
exports.default = async function notarizing(context) {
5+
if (!isCI) {
6+
console.log('Skipping notarization: not on CI.');
7+
return;
8+
}
9+
const { electronPlatformName, appOutDir } = context;
10+
if (electronPlatformName !== 'darwin') {
11+
return;
12+
}
13+
14+
const appName = context.packager.appInfo.productFilename;
15+
const appBundleId = context.packager.config.appId;
16+
console.log(`>>> Notarizing ${appBundleId} at ${appOutDir}/${appName}.app...`);
17+
18+
return await notarize({
19+
appBundleId,
20+
appPath: `${appOutDir}/${appName}.app`,
21+
appleId: process.env.AC_USERNAME,
22+
appleIdPassword: process.env.AC_PASSWORD,
23+
});
24+
};

0 commit comments

Comments
 (0)