Skip to content

Commit

Permalink
github/workflows: Add torizon_arch value to settings.json of projects
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Riesco <[email protected]>
  • Loading branch information
andreriesco committed Jul 15, 2024
1 parent 0013071 commit a26780e
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 32 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/build-ccpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ jobs:
project:
- folder: cppQML
container: cpp-qml
arch: arm64
vendor: "{ arch: 'arm64', torizon_arch: 'aarch64' }"

- folder: cppSlint
container: cpp-slint
arch: arm64

vendor: "{ arch: 'arm64', torizon_arch: 'aarch64' }"

steps:
- uses: actions/checkout@v3
Expand All @@ -30,10 +29,14 @@ jobs:
env:
PROJECT_FOLDER: ${{ matrix.project.folder }}
PROJECT_CONTAINER: ${{ matrix.project.container }}
PROJECT_ARCH: ${{ matrix.project.arch }}
VENDOR: ${{ matrix.project.vendor }}
DOCKER_LOGIN: localhost:5002

run: |
$_vendor = ($env:VENDOR | ConvertFrom-Json)
$env:TORIZON_ARCH = $_vendor.torizon_arch
$env:PROJECT_ARCH = $_vendor.arch
docker run --rm --privileged torizon/binfmt
scripts/createFromTemplate.ps1 `
Expand All @@ -46,4 +49,9 @@ jobs:
false
cd "${env:GITHUB_WORKSPACE}/${env:PROJECT_FOLDER}CITest"
$_settingsJson = Get-Content -Path ".vscode/settings.json" | ConvertFrom-Json
$_settingsJson.torizon_arch = $env:TORIZON_ARCH
Set-Content -Path ".vscode/settings.json" -Value ($_settingsJson | ConvertTo-Json) -Encoding UTF8
./.vscode/tasks.ps1 run build-container-torizon-release-${env:PROJECT_ARCH}
19 changes: 14 additions & 5 deletions .github/workflows/build-debug-ccpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,28 @@ jobs:
project:
- folder: cppQML
container: cpp-qml
arch: arm64
vendor: "{ arch: 'arm64', torizon_arch: 'aarch64' }"

- folder: cppSlint
container: cpp-slint
arch: arm64

vendor: "{ arch: 'arm64', torizon_arch: 'aarch64' }"

steps:
- uses: actions/checkout@v3

- name: Build ${{ matrix.project.folder }} Dockerfile.debug
- name: Build ${{ matrix.project.folder }} Dockerfile
shell: pwsh
env:
PROJECT_FOLDER: ${{ matrix.project.folder }}
PROJECT_CONTAINER: ${{ matrix.project.container }}
PROJECT_ARCH: ${{ matrix.project.arch }}
VENDOR: ${{ matrix.project.vendor }}
DOCKER_LOGIN: localhost:5002

run: |
$_vendor = ($env:VENDOR | ConvertFrom-Json)
$env:TORIZON_ARCH = $_vendor.torizon_arch
$env:PROJECT_ARCH = $_vendor.arch
docker run --rm --privileged torizon/binfmt
scripts/createFromTemplate.ps1 `
Expand All @@ -45,6 +49,11 @@ jobs:
false
cd "${env:GITHUB_WORKSPACE}/${env:PROJECT_FOLDER}CITest"
$_settingsJson = Get-Content -Path ".vscode/settings.json" | ConvertFrom-Json
$_settingsJson.torizon_arch = $env:TORIZON_ARCH
Set-Content -Path ".vscode/settings.json" -Value ($_settingsJson | ConvertTo-Json) -Encoding UTF8
# TODO: this is bad, but it's the only way to make it work for now
chmod 777 . -R
Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/build-debug-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ jobs:
project:
- folder: python3Console
container: python3-console
arch: arm64

vendor: "{ arch: 'arm64', torizon_arch: 'aarch64' }"

steps:
- uses: actions/checkout@v3

- name: Build ${{ matrix.project.folder }} Dockerfile.debug
- name: Build ${{ matrix.project.folder }} Dockerfile
shell: pwsh
env:
PROJECT_FOLDER: ${{ matrix.project.folder }}
PROJECT_CONTAINER: ${{ matrix.project.container }}
PROJECT_ARCH: ${{ matrix.project.arch }}
VENDOR: ${{ matrix.project.vendor }}
DOCKER_LOGIN: localhost:5002

run: |
$_vendor = ($env:VENDOR | ConvertFrom-Json)
$env:TORIZON_ARCH = $_vendor.torizon_arch
$env:PROJECT_ARCH = $_vendor.arch
docker run --rm --privileged torizon/binfmt
scripts/createFromTemplate.ps1 `
Expand All @@ -41,4 +45,9 @@ jobs:
false
cd "${env:GITHUB_WORKSPACE}/${env:PROJECT_FOLDER}CITest"
$_settingsJson = Get-Content -Path ".vscode/settings.json" | ConvertFrom-Json
$_settingsJson.torizon_arch = $env:TORIZON_ARCH
Set-Content -Path ".vscode/settings.json" -Value ($_settingsJson | ConvertTo-Json) -Encoding UTF8
./.vscode/tasks.ps1 run build-container-torizon-debug-${env:PROJECT_ARCH}
17 changes: 13 additions & 4 deletions .github/workflows/build-debug-rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ jobs:
project:
- folder: rustSlint
container: rust-slint
arch: arm64

vendor: "{ arch: 'arm64', torizon_arch: 'aarch64' }"

steps:
- uses: actions/checkout@v3

- name: Build ${{ matrix.project.folder }} Dockerfile.debug
- name: Build ${{ matrix.project.folder }} Dockerfile
shell: pwsh
env:
PROJECT_FOLDER: ${{ matrix.project.folder }}
PROJECT_CONTAINER: ${{ matrix.project.container }}
PROJECT_ARCH: ${{ matrix.project.arch }}
VENDOR: ${{ matrix.project.vendor }}
DOCKER_LOGIN: localhost:5002

run: |
$_vendor = ($env:VENDOR | ConvertFrom-Json)
$env:TORIZON_ARCH = $_vendor.torizon_arch
$env:PROJECT_ARCH = $_vendor.arch
docker run --rm --privileged torizon/binfmt
scripts/createFromTemplate.ps1 `
Expand All @@ -41,6 +45,11 @@ jobs:
false
cd "${env:GITHUB_WORKSPACE}/${env:PROJECT_FOLDER}CITest"
$_settingsJson = Get-Content -Path ".vscode/settings.json" | ConvertFrom-Json
$_settingsJson.torizon_arch = $env:TORIZON_ARCH
Set-Content -Path ".vscode/settings.json" -Value ($_settingsJson | ConvertTo-Json) -Encoding UTF8
# TODO: this is bad, but it's the only way to make it work for now
chmod 777 . -R
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/build-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ jobs:
project:
- folder: python3Console
container: python3-console
arch: arm64

vendor: "{ arch: 'arm64', torizon_arch: 'aarch64' }"

steps:
- uses: actions/checkout@v3
Expand All @@ -26,10 +25,14 @@ jobs:
env:
PROJECT_FOLDER: ${{ matrix.project.folder }}
PROJECT_CONTAINER: ${{ matrix.project.container }}
PROJECT_ARCH: ${{ matrix.project.arch }}
VENDOR: ${{ matrix.project.vendor }}
DOCKER_LOGIN: localhost:5002

run: |
$_vendor = ($env:VENDOR | ConvertFrom-Json)
$env:TORIZON_ARCH = $_vendor.torizon_arch
$env:PROJECT_ARCH = $_vendor.arch
docker run --rm --privileged torizon/binfmt
scripts/createFromTemplate.ps1 `
Expand All @@ -42,4 +45,9 @@ jobs:
false
cd "${env:GITHUB_WORKSPACE}/${env:PROJECT_FOLDER}CITest"
$_settingsJson = Get-Content -Path ".vscode/settings.json" | ConvertFrom-Json
$_settingsJson.torizon_arch = $env:TORIZON_ARCH
Set-Content -Path ".vscode/settings.json" -Value ($_settingsJson | ConvertTo-Json) -Encoding UTF8
./.vscode/tasks.ps1 run build-container-torizon-release-${env:PROJECT_ARCH}
14 changes: 11 additions & 3 deletions .github/workflows/build-rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ jobs:
project:
- folder: rustSlint
container: rust-slint
arch: arm64

vendor: "{ arch: 'arm64', torizon_arch: 'aarch64' }"

steps:
- uses: actions/checkout@v3
Expand All @@ -26,10 +25,14 @@ jobs:
env:
PROJECT_FOLDER: ${{ matrix.project.folder }}
PROJECT_CONTAINER: ${{ matrix.project.container }}
PROJECT_ARCH: ${{ matrix.project.arch }}
VENDOR: ${{ matrix.project.vendor }}
DOCKER_LOGIN: localhost:5002

run: |
$_vendor = ($env:VENDOR | ConvertFrom-Json)
$env:TORIZON_ARCH = $_vendor.torizon_arch
$env:PROJECT_ARCH = $_vendor.arch
docker run --rm --privileged torizon/binfmt
scripts/createFromTemplate.ps1 `
Expand All @@ -42,4 +45,9 @@ jobs:
false
cd "${env:GITHUB_WORKSPACE}/${env:PROJECT_FOLDER}CITest"
$_settingsJson = Get-Content -Path ".vscode/settings.json" | ConvertFrom-Json
$_settingsJson.torizon_arch = $env:TORIZON_ARCH
Set-Content -Path ".vscode/settings.json" -Value ($_settingsJson | ConvertTo-Json) -Encoding UTF8
./.vscode/tasks.ps1 run build-container-torizon-release-${env:PROJECT_ARCH}
9 changes: 8 additions & 1 deletion scripts/createDockerComposeProduction.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,14 @@ if ([string]::IsNullOrEmpty($tag)) {
}
}

$objSettings = Get-Content ("$compoFilePath/.vscode/settings.json") | `
if ($null -eq $env:TASKS_CUSTOM_SETTINGS_JSON) {
$env:TASKS_CUSTOM_SETTINGS_JSON = "settings.json"
} else {
Write-Host "ℹ️ :: CUSTOM SETTINGS :: ℹ️"
Write-Host "Using custom settings file: $env:TASKS_CUSTOM_SETTINGS_JSON"
}

$objSettings = Get-Content ("$compoFilePath/.vscode/$env:TASKS_CUSTOM_SETTINGS_JSON") | `
Out-String | ConvertFrom-Json
$localRegistry = $objSettings.host_ip

Expand Down
23 changes: 15 additions & 8 deletions scripts/tasks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ if ($env:TASKS_USE_PWSH_INSTEAD_BASH -eq $true) {
$_usePwshInsteadBash = $false;
}

if ($null -eq $env:TASKS_CUSTOM_SETTINGS_JSON) {
$env:TASKS_CUSTOM_SETTINGS_JSON = "settings.json"
} else {
Write-Host "ℹ️ :: CUSTOM SETTINGS :: ℹ️"
Write-Host "Using custom settings file: $env:TASKS_CUSTOM_SETTINGS_JSON"
}

try {
$tasksFileContent = Get-Content $PSScriptRoot/tasks.json
$settingsFileContent = Get-Content $PSScriptRoot/settings.json
$settingsFileContent = Get-Content $PSScriptRoot/$env:TASKS_CUSTOM_SETTINGS_JSON
$json = $tasksFileContent | ConvertFrom-Json
$settings = $settingsFileContent | ConvertFrom-Json
$inputs = $json.inputs
Expand Down Expand Up @@ -215,7 +222,7 @@ function checkTorizonInputs ([System.Collections.ArrayList] $list) {
foreach ($matchValue in $maches) {
$matchValue = $matchValue.Value
$item = $item.Replace(
"`${command:torizon_${matchValue}}",
"`${command:torizon_${matchValue}}",
"`${config:torizon_${matchValue}}"
)
}
Expand All @@ -242,7 +249,7 @@ function checkDockerInputs ([System.Collections.ArrayList] $list) {
foreach ($matchValue in $maches) {
$matchValue = $matchValue.Value
$item = $item.Replace(
"`${command:docker_${matchValue}}",
"`${command:docker_${matchValue}}",
"`${config:docker_${matchValue}}"
)
}
Expand Down Expand Up @@ -273,7 +280,7 @@ function checkTCBInputs ([System.Collections.ArrayList] $list) {
}

$item = $item.Replace(
"`${command:tcb.getNextPackageVersion}",
"`${command:tcb.getNextPackageVersion}",
"$_next"
)
}
Expand All @@ -287,7 +294,7 @@ function checkTCBInputs ([System.Collections.ArrayList] $list) {
foreach ($matchValue in $maches) {
$matchValue = $matchValue.Value
$item = $item.Replace(
"`${command:tcb.${matchValue}}",
"`${command:tcb.${matchValue}}",
"`${config:tcb.${matchValue}}"
)
}
Expand Down Expand Up @@ -379,7 +386,7 @@ function bashVariables ([System.Collections.ArrayList] $list) {
# then we continue because these are meant to be expanded
if (
$item.Contains("`$global:") -or
$item.Contains("`$env:") -or
$item.Contains("`$env:") -or
$item.Contains("`${")
) {
[void]$ret.Add($item)
Expand Down Expand Up @@ -544,7 +551,7 @@ function runTask () {
)
} else {
if (
$null -eq
$null -eq
[System.Environment]::GetEnvironmentVariable($env)
) {
$_env = _parseEnvs $env $task
Expand Down Expand Up @@ -648,7 +655,7 @@ function getCliInputs () {
# main()
# set the relative workspaceFolder (following the pattern that VS Code expects)
if (
($null -eq $env:APOLLOX_WORKSPACE) -and
($null -eq $env:APOLLOX_WORKSPACE) -and
($env:APOLLOX_CONTAINER -ne 1)
) {
$Global:workspaceFolder = Join-Path $PSScriptRoot ..
Expand Down

0 comments on commit a26780e

Please sign in to comment.