From b5a6787aead3bb71ca740a59a824a853ef790c6f Mon Sep 17 00:00:00 2001 From: dk-coligo Date: Wed, 22 May 2024 13:05:55 +0200 Subject: [PATCH 1/4] abs-path for tcb-build --- scripts/bash/tcb-env-setup.sh | 12 ++++++++++-- scripts/tasks.ps1 | 13 ++++++++++++- tcb/.github/workflows/build-torizoncore.yaml | 5 +++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/scripts/bash/tcb-env-setup.sh b/scripts/bash/tcb-env-setup.sh index 5d319fa6d..1a457028b 100755 --- a/scripts/bash/tcb-env-setup.sh +++ b/scripts/bash/tcb-env-setup.sh @@ -43,6 +43,7 @@ tcb_env_setup_cleanup () { unset under_windows unset user_tag unset storage + unset working_directory unset volumes unset network unset remote_tags @@ -95,6 +96,11 @@ tcb_env_setup_usage () { echo " It must be an absolute directory or a Docker volume name. If this" echo " flag is not set, the \"storage\" Docker volume will be used." echo "" + echo " -wd: select working directory for docker mount to /workdir" + echo " Pass the directory explicitly for docker run torizon/torizoncore-builder" + echo " to mount as /workdir." + echo " It must be an absolute directory. If this is not set, \$(pwd) with be used" + echo "" echo " -n: do not enable \"host\" network mode." echo " Under Linux the tool runs in \"host\" network mode by default allowing" echo " it to operate as a server without explicit port publishing. Under" @@ -133,6 +139,7 @@ fi # Parse flags volumes=" -v /deploy " storage="storage" +working_directory="working_directory" network=" --network=host " if [ $under_windows = "1" ]; then # Do not use "host" network mode under Windows/WSL @@ -144,6 +151,7 @@ do -a) source=$2;[ "$2" ]||source="empty"; shift; shift;; -t) user_tag="$2";[ "$2" ]||user_tag="empty"; shift; shift;; -s) storage="$2";[ "$2" ]||storage="empty"; shift; shift;; + -wd) working_directory="$2";[ "$2" ]||working_directory=$(pwd); shift; shift;; -d) volumes=" "; shift;; -n) network=" "; shift;; --) shift; break;; @@ -162,7 +170,7 @@ then tcb_env_setup_check_updated $SCRIPT_PATH fi -if [[ $source = "empty" ]] || [[ $user_tag = "empty" ]] || [[ $storage = "empty" ]] +if [[ $source = "empty" ]] || [[ $user_tag = "empty" ]] || [[ $storage = "empty" ]] || [[ $working_directory = "empty" ]] then tcb_env_setup_usage tcb_env_setup_cleanup @@ -293,7 +301,7 @@ function tcb_dynamic_params() { # TODO Not compatible with ZSH export -f tcb_dynamic_params -alias torizoncore-builder='docker run --rm'"$volumes"'-v "$(pwd)":/workdir -v '"$storage"':/storage -v /var/run/docker.sock:/var/run/docker.sock'"$network"'$(tcb_dynamic_params) '"$*"' torizon/torizoncore-builder:'"$chosen_tag" +alias torizoncore-builder='docker run --rm'"$volumes"' -v '"$working_directory"':/workdir -v '"$storage"':/storage -v /var/run/docker.sock:/var/run/docker.sock'"$network"' '"$(tcb_dynamic_params)"' '"$*"' torizon/torizoncore-builder:'"$chosen_tag" [[ $storage =~ ^[a-zA-Z][a-zA-Z0-9_.-]*$ ]] && storage="Docker volume named '$storage'" diff --git a/scripts/tasks.ps1 b/scripts/tasks.ps1 index 213cd8893..620edb5ff 100644 --- a/scripts/tasks.ps1 +++ b/scripts/tasks.ps1 @@ -649,9 +649,20 @@ function getCliInputs () { # set the relative workspaceFolder (following the pattern that VS Code expects) if ( ($null -eq $env:APOLLOX_WORKSPACE) -and - ($env:APOLLOX_CONTAINER -ne 1) + ($env:APOLLOX_CONTAINER -ne 1) -and + (!$env:GITHUB_WORKSPACE) ) { $Global:workspaceFolder = Join-Path $PSScriptRoot .. +} +elseif ( + $env:GITHUB_WORKSPACE +) { + # If running in a github action, this ENV is set automatically, + # github actions sandboxes runners by re-writing their ABS path, + # so when we do a docker-in-docker build, the mount point for workdir is not found. + # This sets the ABS path from a file called abs-path + $Global:workspaceFolder = Join-Path $PSScriptRoot .. + $Global:working_directory = Get-Content -Path abs-path -ReadCount 1 } else { $Global:workspaceFolder = $env:APOLLOX_WORKSPACE } diff --git a/tcb/.github/workflows/build-torizoncore.yaml b/tcb/.github/workflows/build-torizoncore.yaml index 03cd3f737..c3267153d 100644 --- a/tcb/.github/workflows/build-torizoncore.yaml +++ b/tcb/.github/workflows/build-torizoncore.yaml @@ -6,6 +6,7 @@ jobs: build-deploy: runs-on: ubuntu-latest name: Build & Deploy TorizonCore + container: ubuntu:23.04 steps: - uses: actions/checkout@v3 - uses: actions/cache@v3 @@ -13,6 +14,10 @@ jobs: with: path: storage/ key: tcb + - name: Set abs-path file + run: | + echo "${{ github.workspace }}" >> abs-path + cat abs-path - name: Initial Setup shell: bash From b4547e436c36e496393917c4187af812ae0c4f26 Mon Sep 17 00:00:00 2001 From: dk-coligo Date: Wed, 22 May 2024 14:28:32 +0200 Subject: [PATCH 2/4] ubuntu version, check if working_directory is set --- scripts/bash/tcb-env-setup.sh | 2 +- tcb/.github/workflows/build-torizoncore.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/bash/tcb-env-setup.sh b/scripts/bash/tcb-env-setup.sh index 1a457028b..d021a91bf 100755 --- a/scripts/bash/tcb-env-setup.sh +++ b/scripts/bash/tcb-env-setup.sh @@ -170,7 +170,7 @@ then tcb_env_setup_check_updated $SCRIPT_PATH fi -if [[ $source = "empty" ]] || [[ $user_tag = "empty" ]] || [[ $storage = "empty" ]] || [[ $working_directory = "empty" ]] +if [[ $source = "empty" ]] || [[ $user_tag = "empty" ]] || [[ $storage = "empty" ]] || [[ $working_directory ]] then tcb_env_setup_usage tcb_env_setup_cleanup diff --git a/tcb/.github/workflows/build-torizoncore.yaml b/tcb/.github/workflows/build-torizoncore.yaml index c3267153d..7d8362408 100644 --- a/tcb/.github/workflows/build-torizoncore.yaml +++ b/tcb/.github/workflows/build-torizoncore.yaml @@ -6,7 +6,7 @@ jobs: build-deploy: runs-on: ubuntu-latest name: Build & Deploy TorizonCore - container: ubuntu:23.04 + container: ubuntu:23.10 steps: - uses: actions/checkout@v3 - uses: actions/cache@v3 From 5c5085b0ed0b8cb419077c6a02d7c77ad297ccf1 Mon Sep 17 00:00:00 2001 From: dk-coligo Date: Wed, 22 May 2024 14:41:43 +0200 Subject: [PATCH 3/4] install docker and powershell --- tcb/.github/workflows/build-torizoncore.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tcb/.github/workflows/build-torizoncore.yaml b/tcb/.github/workflows/build-torizoncore.yaml index 7d8362408..5aee7f9f7 100644 --- a/tcb/.github/workflows/build-torizoncore.yaml +++ b/tcb/.github/workflows/build-torizoncore.yaml @@ -18,6 +18,15 @@ jobs: run: | echo "${{ github.workspace }}" >> abs-path cat abs-path + - name: Install build tools in container + run: | + apt-get update + apt-get install -y wget curl libicu-dev + curl -fsSL https://get.docker.com -o get-docker.sh + sh get-docker.sh + + wget -nv https://github.com/PowerShell/PowerShell/releases/download/v7.4.2/powershell_7.4.2-1.deb_amd64.deb + dpkg -i powershell_7.4.2-1.deb_amd64.deb - name: Initial Setup shell: bash From d4de384132cb7755e5c0cde18554a8e64bb3bd8b Mon Sep 17 00:00:00 2001 From: dk-coligo Date: Wed, 12 Jun 2024 09:24:56 +0200 Subject: [PATCH 4/4] changes to platform push --- scripts/bash/tcb-env-setup.sh | 4 ++-- tcb/.github/workflows/build-torizoncore.yaml | 1 + tcb/.vscode/tasks.json | 7 ++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/bash/tcb-env-setup.sh b/scripts/bash/tcb-env-setup.sh index d021a91bf..c9ad7e929 100755 --- a/scripts/bash/tcb-env-setup.sh +++ b/scripts/bash/tcb-env-setup.sh @@ -97,7 +97,7 @@ tcb_env_setup_usage () { echo " flag is not set, the \"storage\" Docker volume will be used." echo "" echo " -wd: select working directory for docker mount to /workdir" - echo " Pass the directory explicitly for docker run torizon/torizoncore-builder" + echo " (Optional) Pass the directory explicitly for docker run torizon/torizoncore-builder" echo " to mount as /workdir." echo " It must be an absolute directory. If this is not set, \$(pwd) with be used" echo "" @@ -170,7 +170,7 @@ then tcb_env_setup_check_updated $SCRIPT_PATH fi -if [[ $source = "empty" ]] || [[ $user_tag = "empty" ]] || [[ $storage = "empty" ]] || [[ $working_directory ]] +if [[ $source = "empty" ]] || [[ $user_tag = "empty" ]] || [[ $storage = "empty" ]] then tcb_env_setup_usage tcb_env_setup_cleanup diff --git a/tcb/.github/workflows/build-torizoncore.yaml b/tcb/.github/workflows/build-torizoncore.yaml index 5aee7f9f7..03a485870 100644 --- a/tcb/.github/workflows/build-torizoncore.yaml +++ b/tcb/.github/workflows/build-torizoncore.yaml @@ -48,6 +48,7 @@ jobs: PLATFORM_CLIENT_SECRET: ${{ secrets.PLATFORM_CLIENT_SECRET }} run: | ./.vscode/tasks.ps1 run tcb-setup + ./.vscode/tasks.ps1 run tcb-unpack ./.vscode/tasks.ps1 run tcb-platform-push-ostree - name: Deploy to Fleet diff --git a/tcb/.vscode/tasks.json b/tcb/.vscode/tasks.json index 88054cb79..a1c6faf43 100644 --- a/tcb/.vscode/tasks.json +++ b/tcb/.vscode/tasks.json @@ -433,7 +433,9 @@ "-s", "${workspaceFolder}/storage", "-t", - "${config:tcb.version}" + "${config:tcb.version}", + "-wd", + "${working_directory}" ], "problemMatcher": [ "$tsc" @@ -444,6 +446,9 @@ }, "dependsOrder": "sequence", "dependsOn": [ + // "tcb-unpack" // This will only run the unpack task, + // and exit without running platform push + ] }, {