Skip to content

Commit

Permalink
Add crash-report capabilities (#574)
Browse files Browse the repository at this point in the history
* change approach: redirect stderr to file instead using defer

* update gin dependency because of gin-gonic/gin#1571

* set default logger to stdout. (stderr is currently redirected to file)

* save crash-report to newly created `logs/` folder

* add enable/disable crash-report generation (default off)

* add entry in trayicon's menu to remove crash-reports (if there are any)

* CI polishing, add win64, update macOS min version  (#578)
  • Loading branch information
umbynos authored Dec 17, 2020
1 parent b88987e commit 9c49735
Show file tree
Hide file tree
Showing 11 changed files with 379 additions and 88 deletions.
82 changes: 55 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ jobs:
build:
strategy:
matrix:
operating-system: [ubuntu-18.04, windows-2019, macos-10.15]
include:
- operating-system: ubuntu-18.04
- operating-system: windows-2019
arch: -386
- operating-system: windows-2019
arch: -amd64
- operating-system: macos-10.15

runs-on: ${{ matrix.operating-system }}
env:
TAG_VERSION: ${GITHUB_REF##*/} # will be available to all steps and will be used by task build

steps:
- name: Disable EOL conversions
Expand All @@ -24,7 +32,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.15"
go-version: "1.14"

# dependencies used for compiling the GUI
- name: Install Dependencies (Linux)
Expand Down Expand Up @@ -53,7 +61,7 @@ jobs:
run: task test-unit

- name: Build the Agent for linux
run: task build
run: task build
if: matrix.operating-system == 'ubuntu-18.04'

# build the agent without GUI support (no tray icon)
Expand All @@ -62,32 +70,36 @@ jobs:
if: matrix.operating-system == 'ubuntu-18.04'

# the manifest is required by windows GUI apps, otherwise the binary will crash with: "Unable to create main window: TTM_ADDTOOL failed" (for reference https://github.com/lxn/walk/issues/28)
# rsrc will produce *.syso files that should get automatically recognized by go build command and linked into an executable.
- name: Embed manifest in win binary
run: |
go get github.com/akavel/rsrc
rsrc -arch 386 -manifest manifest.xml
# rsrc will produce a *.syso file that should get automatically recognized by go build command and linked into an executable.
- name: Download tool to embed manifest in win binary
run: go get github.com/akavel/rsrc
if: matrix.operating-system == 'windows-2019'

# building the agent for win requires a different task because of an extra flag
- name: Build the Agent for win32
env:
GOARCH: 386 # 32bit architecture (for support)
GO386: 387 # support old instruction sets without MMX (used in the Pentium 4) (will be deprecated in GO > 1.15 https://golang.org/doc/go1.15)
run: task build-win32
if: matrix.operating-system == 'windows-2019'
run: task build-win
if: matrix.operating-system == 'windows-2019' && matrix.arch == '-386'

- name: Build the Agent for win64
run: task build-win # GOARCH=amd64 by default on the runners
if: matrix.operating-system == 'windows-2019' && matrix.arch == '-amd64'

- name: Build the Agent for macos
env:
MACOSX_DEPLOYMENT_TARGET: 10.9 # minimum supported version for mac
MACOSX_DEPLOYMENT_TARGET: 10.11 # minimum supported version for mac
CGO_CFLAGS: -mmacosx-version-min=10.11
CGO_LDFLAGS: -mmacosx-version-min=10.11
run: task build
if: matrix.operating-system == 'macos-10.15'

# config.ini is required by the executable when it's run
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: arduino-create-agent-${{ matrix.operating-system }}
name: arduino-create-agent-${{ matrix.operating-system }}${{ matrix.arch }}
path: |
arduino-create-agent*
config.ini
Expand All @@ -101,12 +113,6 @@ jobs:
RUNS_ON: macos-10.15 # used to parametrize filenames

steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: 'bcmi-labs/arduino-create-agent-installer' # the repo which contains gon.config.hcl
token: ${{ secrets.ARDUINO_CREATE_AGENT_CI_PAT }}

- name: Download artifact
uses: actions/download-artifact@v2
with:
Expand All @@ -130,14 +136,29 @@ jobs:
wget -q https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip
unzip gon_macos.zip -d /usr/local/bin
- name: Write gon config to file
# gon does not allow env variables in config file (https://github.com/mitchellh/gon/issues/20)
run: |
cat > gon.config.hcl <<EOF
source = ["arduino-create-agent-${{ env.RUNS_ON }}/arduino-create-agent"]
bundle_id = "cc.arduino.arduino-agent"
sign {
application_identity = "Developer ID Application: ARDUINO SA (7KT7ZWMCJT)"
}
# Ask Gon for zip output to force notarization process to take place.
# The CI will ignore the zip output, using the signed binary only.
zip {
output_path = "arduino-create-agent.zip"
}
EOF
- name: Code sign and notarize app
env:
AC_USERNAME: ${{ secrets.AC_USERNAME }}
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
run: |
echo "gon will notarize executable in arduino-create-agent-${{ env.RUNS_ON }}/arduino-create-agent"
gon -log-level=debug -log-json gon.config.hcl
# gon will notarize executable in "arduino-create-agent-${{ env.RUNS_ON }}/arduino-create-agent
# The CI will ignore the zip output, using the signed binary only.
timeout-minutes: 30

# This step will overwrite the non signed mac artifact (arduino-create-agent-${{ env.RUNS_ON }})
Expand Down Expand Up @@ -171,13 +192,20 @@ jobs:
strategy:
fail-fast: false # if one os is failing continue nonetheless
matrix: # used to generate installers for different OS and not for runs-on
operating-system: [ubuntu-18.04, windows-2019, macos-10.15]

include:
- operating-system: ubuntu-18.04
install-builder-name: linux-x64
executable-path: artifacts/linux-amd64/
- operating-system: windows-2019
arch: -386
browser: edge
install-builder-name: windows
executable-path: artifacts/windows/
extension: .exe
installer-extension: .exe
- operating-system: windows-2019
arch: -amd64
browser: edge
install-builder-name: windows
executable-path: artifacts/windows/
Expand Down Expand Up @@ -213,7 +241,7 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: arduino-create-agent-${{ matrix.operating-system }}
name: arduino-create-agent-${{ matrix.operating-system }}${{ matrix.arch }}
path: ${{ matrix.executable-path }} # path expected by installbuilder

# zip artifacts do not mantain executable permission
Expand Down Expand Up @@ -244,10 +272,10 @@ jobs:
- name: Launch Bitrock installbuilder-20 with CERT_INSTALL && CHOICE_CERT_INSTALL
run: |
${{ env.INSTALLBUILDER_PATH }} build installer.xml ${{ matrix.install-builder-name }} --verbose --license /tmp/license.xml --setvars ${INSTALLER_VARS} ${{ env.CERT_INSTALL }}
mv -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CI${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-${{matrix.browser}}${{matrix.installer-extension}}
mv -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CI${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}${{ matrix.arch }}-installer-${{matrix.browser}}${{matrix.installer-extension}}
${{ env.INSTALLBUILDER_PATH }} build installer.xml ${{ matrix.install-builder-name }} --verbose --license /tmp/license.xml --setvars ${INSTALLER_VARS} ${{ env.CHOICE_CERT_INSTALL }}
cp -vr ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CC${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-chrome${{matrix.installer-extension}}
mv -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CC${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-firefox${{matrix.installer-extension}}
cp -vr ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CC${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}${{ matrix.arch }}-installer-chrome${{matrix.installer-extension}}
mv -v ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-CC${{matrix.installer-extension}} ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}${{ matrix.arch }}-installer-firefox${{matrix.installer-extension}}
rm -r ArduinoCreateAgent-${VERSION%.*}-${{ matrix.install-builder-name }}-installer-C*
if: matrix.operating-system == 'windows-2019' || matrix.operating-system == 'macos-10.15'

Expand All @@ -264,7 +292,7 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ArduinoCreateAgent-${{ matrix.install-builder-name }}
name: ArduinoCreateAgent-${{ matrix.install-builder-name }}${{ matrix.arch }}
path: ArduinoCreateAgent*
if-no-files-found: error

Expand Down Expand Up @@ -378,7 +406,7 @@ jobs:
mv -v ArduinoCreateAgent-linux-x64/* release/
cat ArduinoCreateAgent-osx/*.tar | tar -xvf - -i -C release/
rm -v release/._ArduinoCreateAgent*.dmg
mv -v ArduinoCreateAgent-windows/* release/
mv -v ArduinoCreateAgent-windows*/* release/
- name: Create Github Release
uses: actions/create-release@v1
Expand Down
48 changes: 37 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ jobs:
test-matrix:
strategy:
matrix:
operating-system: [ubuntu-18.04, windows-2019, macos-10.15]
include:
- operating-system: ubuntu-18.04
- operating-system: windows-2019
arch: -386
- operating-system: windows-2019
arch: -amd64
- operating-system: macos-10.15

runs-on: ${{ matrix.operating-system }}

Expand All @@ -21,7 +27,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.15"
go-version: "1.14"

# dependencies used for compiling the GUI
- name: Install Dependencies (Linux)
Expand Down Expand Up @@ -49,27 +55,47 @@ jobs:
- name: Run unit tests
run: task test-unit

- name: Build the Agent
- name: Build the Agent for linux
run: task build
if: matrix.operating-system != 'windows-2019'
if: matrix.operating-system == 'ubuntu-18.04'

# build the agent without GUI support (no tray icon)
- name: Build the Agent-cli
run: task build-cli
if: matrix.operating-system == 'ubuntu-18.04'

# the manifest is required by windows GUI apps, otherwise the binary will crash with: "Unable to create main window: TTM_ADDTOOL failed" (for reference https://github.com/lxn/walk/issues/28)
# rsrc will produce *.syso files that should get automatically recognized by go build command and linked into an executable.
- name: Embed manifest in win binary
run: |
go get github.com/akavel/rsrc
rsrc -arch 386 -manifest manifest.xml
# rsrc will produce a *.syso file that should get automatically recognized by go build command and linked into an executable.
- name: Download tool to embed manifest in win binary
run: go get github.com/akavel/rsrc
if: matrix.operating-system == 'windows-2019'

# building the agent for win requires a different task because of an extra flag
- name: Build the Agent for win32
env:
GOARCH: 386 # 32bit architecture (for support)
GO386: 387 # support old instruction sets without MMX (used in the Pentium 4) (will be deprecated in GO > 1.15 https://golang.org/doc/go1.15)
run: task build-win32
if: matrix.operating-system == 'windows-2019'
run: task build-win
if: matrix.operating-system == 'windows-2019' && matrix.arch == '-386'

- name: Build the Agent for win64
run: task build-win # GOARCH=amd64 by default on the runners
if: matrix.operating-system == 'windows-2019' && matrix.arch == '-amd64'

- name: Build the Agent for macos
env:
MACOSX_DEPLOYMENT_TARGET: 10.11 # minimum supported version for mac
CGO_CFLAGS: -mmacosx-version-min=10.11
CGO_LDFLAGS: -mmacosx-version-min=10.11
run: task build
if: matrix.operating-system == 'macos-10.15'

# config.ini is required by the executable when it's run
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: arduino-create-agent-${{ matrix.operating-system }}${{ matrix.arch }}
path: |
arduino-create-agent*
config.ini
if-no-files-found: error
60 changes: 22 additions & 38 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
version: "2"
version: '3'

tasks:

build:
desc: Build the project
desc: Build the project, to use a specific version use `task build TAG_VERSION=x.x.x`
cmds:
- go build -v -i {{.LDFLAGS}}
- go build -v -i {{default "" .ADDITIONAL_FLAGS}} -o {{default "arduino-create-agent" .APP_NAME}} -ldflags '-X main.version={{default .TAG_TEST .TAG_VERSION}} -X main.git_revision={{.COMMIT}} {{default "" .WIN_FLAGS}}'
vars:
COMMIT:
sh: git log -n 1 --format=%h

build-cli:
desc: Build the project without tray support
cmds:
- go build -v -i -tags cli -o {{.APP_NAME}}_cli {{.LDFLAGS}}
- task: build
vars:
APP_NAME: arduino-create-agent_cli
ADDITIONAL_FLAGS: -tags cli

build-win32:
desc: Build the project for win 32 bit
build-win:
desc: Build the project for win, to build 32bit `export GOARCH=386` and for 64 bit `export GOARCH=amd64` before `task build-win`
cmds:
- go build -v -i {{.WIN_LDFLAGS}}

test:
desc: Run the full testsuite, `legacy` will be skipped
cmds:
- task: test-unit
- rsrc -arch {{.GOARCH}} -manifest manifest.xml # GOARCH shoud be either amd64 or 386
- task: build
vars:
APP_NAME: arduino-create-agent.exe
WIN_FLAGS: -H=windowsgui
- rm *.syso # rm file to avoid compilation problems on other platforms

test-unit:
desc: Run unit tests only
Expand All @@ -43,38 +49,16 @@ tasks:
# - task: python:check
# - task: docs:check
# - task: config:check

vars:
TAG_TEST: "0.0.0-dev"
GOARCH:
sh: go env GOARCH
# all modules of this project except for "gen/..." module
DEFAULT_TARGETS:
sh: echo `go list ./... | grep -v 'arduino-create-agent/gen/' | tr '\n' ' '`
# build vars
APP_NAME: arduino-create-agent
WIN_FLAGS: -H=windowsgui
COMMIT:
sh: echo ${TRAVIS_COMMIT:-`git log -n 1 --format=%h`}
TAG:
sh: echo `git describe --tags --abbrev=0`
LDFLAGS: >
-ldflags '-X main.version={{.TAG}}
-X main.git_revision={{.COMMIT}}'
WIN_LDFLAGS: >
-ldflags '-X main.version={{.TAG}}
-X main.git_revision={{.COMMIT}}
{{.WIN_FLAGS}}'
# test vars
GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic"
TEST_VERSIONSTRING: "0.0.0-alpha"
TEST_COMMIT: "deadbeef"
TEST_LDFLAGS: >
-ldflags '-X main.version={{.TEST_VERSIONSTRING}}
-X main.git_revision={{.TEST_COMMIT}}'
# check-lint vars
GOLINTBIN:
sh: go list -f {{"{{"}}".Target{{"}}"}}" golang.org/x/lint/golint
GOLINTFLAGS: "-min_confidence 0.8 -set_exit_status"
# # docs versioning
# DOCS_VERSION: dev
# DOCS_ALIAS: ""
# DOCS_REMOTE: "origin"
PRETTIER: prettier@2.0.5
1 change: 1 addition & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ appName = CreateBridge
updateUrl = https://downloads.arduino.cc/
origins = https://local.arduino.cc:8000
#httpProxy = http://your.proxy:port # Proxy server for HTTP requests
crashreport = false # enable crashreport logging
Loading

0 comments on commit 9c49735

Please sign in to comment.