Skip to content

CI polishing, add win64, update macOS min version #578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 34 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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 @@ -62,24 +62,35 @@ 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
# 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
rsrc -arch 386 -manifest manifest.xml
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
run: |
rsrc -arch 386 -manifest manifest.xml
task build-win
rm *.syso
if: matrix.operating-system == 'windows-2019'

- name: Build the Agent for win64
run: |
rsrc -arch amd64 -manifest manifest.xml
task build-win
rm *.syso
if: matrix.operating-system == 'windows-2019'

- 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'

Expand All @@ -101,12 +112,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 +135,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

Comment on lines +139 to +154
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really simple and effective mechanism for templating config files, kudos!

- 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
45 changes: 36 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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 +49,54 @@ jobs:
- name: Run unit tests
run: task test-unit

- name: Build the Agent
run: task build
if: matrix.operating-system != 'windows-2019'
- name: Build the Agent for linux
run: task test:build
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
run: task test: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
# 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
rsrc -arch 386 -manifest manifest.xml
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
run: |
rsrc -arch 386 -manifest manifest.xml
task test:build-win
rm *.syso
if: matrix.operating-system == 'windows-2019'

- name: Build the Agent for win64
run: |
rsrc -arch amd64 -manifest manifest.xml
task test:build-win
rm *.syso
if: matrix.operating-system == 'windows-2019'

- 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 test: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 }}
path: |
arduino-create-agent*
config.ini
if-no-files-found: error
41 changes: 31 additions & 10 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,33 @@ tasks:
build:
desc: Build the project
cmds:
- go build -v -i {{.LDFLAGS}}
- go build -v -i -o {{.APP_NAME}} {{.LDFLAGS}}

build-cli:
desc: Build the project without tray support
cmds:
- go build -v -i -tags cli -o {{.APP_NAME}}_cli {{.LDFLAGS}}

build-win32:
desc: Build the project for win 32 bit
build-win:
desc: Build the project for win
cmds:
- go build -v -i {{.WIN_LDFLAGS}}
- go build -v -i -o {{.APP_NAME}}_{{.GOARCH}} {{.WIN_LDFLAGS}}

test:build:
desc: Build the project for test.yml
env:
cmds:
- go build -v -i -o {{.APP_NAME}} {{.TEST_LDFLAGS}}

test:build-cli:
desc: Build the project without tray support for test.yml
cmds:
- go build -v -i -tags cli -o {{.APP_NAME}}_cli {{.TEST_LDFLAGS}}

test:build-win:
desc: Build the project for win for test.yml
cmds:
- go build -v -i -o {{.APP_NAME}}_{{.GOARCH}} {{.TEST_WIN_LDFLAGS}}

test:
desc: Run the full testsuite, `legacy` will be skipped
Expand Down Expand Up @@ -50,25 +66,30 @@ vars:
sh: echo `go list ./... | grep -v 'arduino-create-agent/gen/' | tr '\n' ' '`
# build vars
APP_NAME: arduino-create-agent
GOARCH:
sh: go env GOARCH
WIN_FLAGS: -H=windowsgui
COMMIT:
sh: echo ${TRAVIS_COMMIT:-`git log -n 1 --format=%h`}
TAG:
sh: echo `git describe --tags --abbrev=0`
TEST_TAG: "0.0.0-dev"
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}}'
-ldflags '-X main.version={{.TEST_TAG}}
-X main.git_revision={{.COMMIT}}'
TEST_WIN_LDFLAGS: >
-ldflags '-X main.version={{.TEST_TAG}}
-X main.git_revision={{.COMMIT}}
{{.WIN_FLAGS}}'

GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic"
# check-lint vars
GOLINTBIN:
sh: go list -f {{"{{"}}".Target{{"}}"}}" golang.org/x/lint/golint
Expand Down