Skip to content
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

feature/sc-100324/ci-build-cross-platform #2418

Merged
merged 3 commits into from Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
278 changes: 278 additions & 0 deletions .circleci/config.yml
Expand Up @@ -9,9 +9,138 @@ tag_filters: &tag_filters
only:
- /.+/

orbs:
win: circleci/windows@2.4.0

aliases:
- &tasks ["compile:all clean:all", "compile:user clean:user", "compile:debug clean:debug"]
- &platforms ["photon", "p1", "electron", "argon", "boron", "bsom", "b5som", "tracker"]

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
setup-workspace:
machine:
image: ubuntu-2004:current
steps:
- run:
name: "Create Tested Platforms Files in Workspace"
command: |
mkdir -p $HOME/workspace/tested-platforms
ls -la $HOME/workspace
ls -la $HOME/workspace/tested-platforms
echo ":::: done!"
- persist_to_workspace:
root: ~/workspace
paths:
- tested-platforms
validate-toolchain-platforms:
machine:
image: ubuntu-2004:current
steps:
- attach_workspace:
at: ~/workspace
- checkout
- install-prtcl-ubuntu
- run:
name: "Check if all toolchain platforms were tested"
command: |
ls -la $HOME/workspace
ls -la $HOME/workspace/tested-platforms
echo
deviceOSPath=~/project
deviceOSSource="source:${deviceOSPath}"
toolchain="$(prtcl toolchain:view ${deviceOSSource} --json)"
platformsStr=$(echo $toolchain | jq '.platforms' | jq 'map(.name)')
platforms=()
while read p; do
platforms+=($(echo ${p} | tr -d '"'))
done < <(echo $platformsStr | jq -c '.[]')
echo ":::: Found toolchain platforms: ${platforms[@]}"
oses=(
'darwin-x64'
'ubuntu-x64'
'windows-x64'
)
for os in "${oses[@]}"; do
for platform in "${platforms[@]}"; do
dir="${HOME}/workspace/tested-platforms"
prefix="${os}-${platform}"
pattern="${prefix}-*"
echo ":::: Checking for results matching '${dir}/${pattern}'"
results=$(find $dir -maxdepth 1 -name "${pattern}" -type f)
count=0
if [ -n "${results}" ]; then
count=$(echo "$results" | wc -l)
fi
echo ":::: Found ${count} results:"
echo "$results"
echo
if [ $count -lt 1 ]; then
echo ":::: Missing tests for ${platform}!"
exit 1
fi
done
done
echo ":::: done!"
build-for-windows:
executor:
name: win/default
size: xlarge
parameters:
tasks:
type: string
platform:
type: string
steps:
- checkout
- run: git submodule update --init --recursive
- install-prtcl-windows
- test-localcompiler-windows:
tasks: << parameters.tasks >>
platform: << parameters.platform >>
- save-platform-to-workspace:
os: windows-x64
tasks: << parameters.tasks >>
platform: << parameters.platform >>
build-for-darwin:
macos:
xcode: "13.2.1"
parameters:
tasks:
type: string
platform:
type: string
steps:
- checkout
- run: git submodule update --init --recursive
- install-prtcl-darwin
- test-localcompiler-nix:
tasks: << parameters.tasks >>
platform: << parameters.platform >>
- save-platform-to-workspace:
os: darwin-x64
tasks: << parameters.tasks >>
platform: << parameters.platform >>
build-for-ubuntu:
machine:
image: ubuntu-2004:current
parameters:
tasks:
type: string
platform:
type: string
steps:
- checkout
- run: git submodule update --init --recursive
- install-prtcl-ubuntu
- test-localcompiler-nix:
tasks: << parameters.tasks >>
platform: << parameters.platform >>
- save-platform-to-workspace:
os: ubuntu-x64
tasks: << parameters.tasks >>
platform: << parameters.platform >>
combine-binaries:
docker:
- image: alpine:latest
Expand Down Expand Up @@ -166,10 +295,158 @@ jobs:
paths:
- release

commands:
install-prtcl-ubuntu:
steps:
- run:
name: "Install `prtcl` CLI (ubuntu)"
command: |
sudo apt-get update -q
sudo apt-get install -qy zlib1g-dev jq
sudo curl https://prtcl.s3.amazonaws.com/install-apt.sh | sh
echo ":::: done!"
install-prtcl-darwin:
steps:
- run:
name: "Install `prtcl` CLI (darwin)"
command: |
brew tap particle-iot/brew && brew install prtcl jq
echo ":::: done!"
install-prtcl-windows:
steps:
- run:
name: "Install `prtcl` CLI (windows)"
command: |
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
echo ":::: Insufficient privileges! Must be Admin"
exit 1;
}

$ErrorActionPreference = "Stop"
echo ":::: Downloading CLI installer..."
Invoke-WebRequest "https://prtcl.s3.amazonaws.com/prtcl-x64.exe" -OutFile "./prtcl-x64.exe"

echo ":::: Installing CLI..."
Start-Process ".\prtcl-x64.exe" -argumentlist "/S" -Wait
echo ":::: done!"
environment:
PRTCL_DISABLE_AUTOUPDATE: "1"
test-localcompiler-nix:
parameters:
tasks:
type: string
platform:
type: string
steps:
- run:
name: "Test Local Compilation Tasks"
no_output_timeout: "10m"
command: scripts/test-build-tasks.sh ~/project "<< parameters.platform >>" "<< parameters.tasks >>"
environment:
PRTCL_DISABLE_AUTOUPDATE: "1"
test-localcompiler-windows:
parameters:
tasks:
type: string
platform:
type: string
steps:
- run:
name: "Test Local Compilation Tasks"
no_output_timeout: "20m"
command: pwsh scripts/test-build-tasks.ps1 $home\project "<< parameters.platform >>" "<< parameters.tasks >>"
environment:
PRTCL_DISABLE_AUTOUPDATE: "1"
save-platform-to-workspace:
parameters:
os:
type: string
tasks:
type: string
platform:
type: string
steps:
- attach_workspace:
at: ~/workspace
- when:
condition:
or:
- equal: [ 'ubuntu-x64', << parameters.os >> ]
- equal: [ 'darwin-x64', << parameters.os >> ]
steps:
- run:
name: "Save Platform to Workspace (*nix)"
command: |
os="<< parameters.os >>"
tasks="<< parameters.tasks >>"
platform="<< parameters.platform >>"
dir="${HOME}/workspace/tested-platforms"
filename="${os}-${platform}-$(echo $tasks | tr -d ' ":')"
filepath="${dir}/${filename}"
echo ":::: Adding: ${filepath}"
touch $filepath
ls -la $dir
echo ":::: done!"
- when:
condition:
and:
- equal: [ 'windows-x64', << parameters.os >> ]
steps:
- run:
name: "Save Platform to Workspace (windows)"
shell: powershell.exe
command: |
$ErrorActionPreference = "Stop"
$os = "<< parameters.os >>"
$tasks = "<< parameters.tasks >>"
$platform = "<< parameters.platform >>"
$dir = "$($home)\workspace\tested-platforms"
$filename = "$($os)-$($platform)-$($tasks -replace '[ :"]','')"
$filepath = "$($dir)\$($filename)"
echo ":::: Adding: $($filepath)"
New-Item $filepath -type file
Get-ChildItem -Force $dir
echo ":::: done!"
- persist_to_workspace:
root: ~/workspace
paths:
- tested-platforms
workflows:
build-and-test:
jobs:
- setup-workspace:
<<: *tag_filters
- build-for-windows:
<<: *tag_filters
matrix:
parameters:
tasks: *tasks
platform: *platforms
requires:
- setup-workspace
- build-for-ubuntu:
<<: *tag_filters
matrix:
parameters:
tasks: *tasks
platform: *platforms
requires:
- setup-workspace
- build-for-darwin:
<<: *tag_filters
matrix:
parameters:
tasks: *tasks
platform: *platforms
requires:
- setup-workspace
- validate-toolchain-platforms:
<<: *tag_filters
requires:
- setup-workspace
- build-for-windows
- build-for-ubuntu
- build-for-darwin
- build-and-test:
<<: *tag_filters
context:
Expand All @@ -184,3 +461,4 @@ workflows:
requires:
- build-and-test
- combine-binaries

7 changes: 1 addition & 6 deletions .workbench/manifest.json
Expand Up @@ -2,7 +2,7 @@
"version": "1.0.0",
"toolchains": [
{
"platforms": [6, 8, 10, 12, 13, 22, 23, 25, 26],
"platforms": [6, 8, 10, 12, 13, 23, 25, 26],
"firmware": "deviceOS@source",
"compilers": "gcc-arm@10.2.1",
"tools": "buildtools@1.1.1",
Expand Down Expand Up @@ -36,11 +36,6 @@
"name": "boron",
"generation": 3
},
{
"id": 22,
"name": "asom",
"generation": 3
},
{
"id": 23,
"name": "bsom",
Expand Down