Skip to content

Commit

Permalink
Update build-system, devcontainer setup, runtimes, and workflows (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
BjoernAtBosch authored Sep 6, 2024
1 parent a6ed187 commit 782cd03
Show file tree
Hide file tree
Showing 28 changed files with 325 additions and 558 deletions.
7 changes: 0 additions & 7 deletions .conan/profiles/linux_aarch64_debug

This file was deleted.

7 changes: 0 additions & 7 deletions .conan/profiles/linux_aarch64_release

This file was deleted.

7 changes: 0 additions & 7 deletions .conan/profiles/linux_x86_64_debug

This file was deleted.

7 changes: 0 additions & 7 deletions .conan/profiles/linux_x86_64_release

This file was deleted.

3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
"cs128.cs128-clang-tidy",
"matepek.vscode-catch2-test-adapter",
"sanaajani.taskrunnercode",
"augustocdias.tasks-shell-input"
"augustocdias.tasks-shell-input",
"ms-vscode.cpptools-extension-pack"
]
}
},
Expand Down
32 changes: 32 additions & 0 deletions .devcontainer/scripts/configure-codespaces.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json
# Copyright (c) 2023-2024 Contributors to the Eclipse Foundation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

if [ "${CODESPACES}" = "true" ]; then
echo "#######################################################"
echo "### Setup Access to Codespaces ###"
echo "#######################################################"

# restart Docker connection if in Codespaces
# Workaround according to https://github.com/devcontainers/features/issues/671#issuecomment-1701754897
sudo pkill dockerd && sudo pkill containerd
/usr/local/share/docker-init.sh

# Remove the default credential helper
sudo sed -i -E 's/helper =.*//' /etc/gitconfig

# Add one that just uses secrets available in the Codespace
git config --global credential.helper '!f() { sleep 1; echo "username=${GITHUB_USER}"; echo "password=${MY_GH_TOKEN}"; }; f'
fi
68 changes: 12 additions & 56 deletions .devcontainer/scripts/onCreateCommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,75 +14,31 @@
#
# SPDX-License-Identifier: Apache-2.0

# exit when any command fails
set -e

# restart Docker connection if in Codespaces
# Workaround according to https://github.com/devcontainers/features/issues/671#issuecomment-1701754897
if [ "${CODESPACES}" = "true" ]; then
sudo pkill dockerd && sudo pkill containerd
/usr/local/share/docker-init.sh
fi

echo "#######################################################"
echo "### Run VADF Lifecycle Management ###"
echo "#######################################################"
# needed to get rid of old leftovers
sudo rm -rf ~/.velocitas
velocitas init
velocitas sync

sudo chmod +x .devcontainer/scripts/*.sh
sudo chown -R $(whoami) $HOME

echo "#######################################################"
echo "### Install Prerequisites and Tools ###"
echo "#######################################################"

# Optionally install the cmake for vcpkg
.devcontainer/scripts/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}

# Install python, conan and ccache
sudo apt-get update
sudo apt-get install -y python3
sudo apt-get install -y python3-distutils
curl -fsSL https://bootstrap.pypa.io/get-pip.py | sudo python3
sudo apt-get -y install --no-install-recommends ccache

pip3 install -r ./requirements.txt

# Install static analyzer tools
sudo apt-get install -y cppcheck clang-format-14 clang-tidy-14
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 100
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-14 100

if [ "${CODESPACES}" = "true" ]; then
echo "#######################################################"
echo "### Setup Access to Codespaces ###"
echo "#######################################################"

# Remove the default credential helper
sudo sed -i -E 's/helper =.*//' /etc/gitconfig
.devcontainer/scripts/setup-git.sh

# Add one that just uses secrets available in the Codespace
git config --global credential.helper '!f() { sleep 1; echo "username=${GITHUB_USER}"; echo "password=${MY_GH_TOKEN}"; }; f'
if [[ -z "${VELOCITAS_OFFLINE}" ]]; then
.devcontainer/scripts/configure-codespaces.sh
.devcontainer/scripts/upgrade-cli.sh
elif [[ -x .devcontainer/scripts/local-setup.sh ]]; then
.devcontainer/scripts/local-setup.sh
fi

echo "#######################################################"
echo "### Init submodules ###"
echo "### Run VADF Lifecycle Management ###"
echo "#######################################################"
git config --global --add safe.directory "*"
git submodule update --init
velocitas init
velocitas sync

echo "#######################################################"
echo "### Install Dependencies ###"
echo "#######################################################"
velocitas exec build-system install 2>&1 | tee -a $HOME/install_dependencies.log
# Some setup might be required even in offline mode
.devcontainer/scripts/setup-dependencies.sh

echo "#######################################################"
echo "### VADF package status ###"
echo "#######################################################"
velocitas upgrade --dry-run
velocitas upgrade --dry-run --ignore-bounds

# Don't let container creation fail if lifecycle management fails
echo "Done!"
68 changes: 2 additions & 66 deletions .devcontainer/scripts/postStartCommand.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json
# Copyright (c) 2023-2024 Contributors to the Eclipse Foundation
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
Expand All @@ -14,68 +14,4 @@
#
# SPDX-License-Identifier: Apache-2.0

echo "#######################################################"
echo "### Auto-Upgrade CLI ###"
echo "#######################################################"

ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../.." )
DESIRED_VERSION=$(cat $ROOT_DIRECTORY/.velocitas.json | jq .cliVersion | tr -d '"')

# Get installed CLI version
INSTALLED_VERSION=v$(velocitas --version | sed -E 's/velocitas-cli\/(\w+.\w+.\w+).*/\1/')

if [ "$DESIRED_VERSION" = "$INSTALLED_VERSION" ]; then
echo "> Already up to date!"
exit 0
else
echo "> Checking upgrade to $DESIRED_VERSION"
fi

AUTHORIZATION_HEADER=""
if [ "${GITHUB_API_TOKEN}" != "" ]; then
AUTHORIZATION_HEADER="-H \"Authorization: Bearer ${GITHUB_API_TOKEN}\""
fi

if [ "$DESIRED_VERSION" = "latest" ]; then
CLI_RELEASES_URL=https://api.github.com/repos/eclipse-velocitas/cli/releases/latest
else
CLI_RELEASES_URL=https://api.github.com/repos/eclipse-velocitas/cli/releases/tags/${DESIRED_VERSION}
fi

CLI_RELEASES=$(curl -s -L \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
${AUTHORIZATION_HEADER} \
${CLI_RELEASES_URL})

res=$?
if test "$res" != "0"; then
echo "the curl command failed with exit code: $res"
exit 0
fi

DESIRED_VERSION_TAG=$(echo ${CLI_RELEASES} | jq -r .name)

if [ "$DESIRED_VERSION_TAG" = "null" ] || [ "$DESIRED_VERSION_TAG" = "" ]; then
echo "> Can't find desired Velocitas CLI version: $DESIRED_VERSION. Skipping Auto-Upgrade."
exit 0
fi

if [ "$DESIRED_VERSION_TAG" != "$INSTALLED_VERSION" ]; then
echo "> Upgrading CLI..."
if [[ $(arch) == "aarch64" ]]; then
CLI_ASSET_NAME=velocitas-linux-arm64
else
CLI_ASSET_NAME=velocitas-linux-x64
fi
CLI_INSTALL_PATH=/usr/bin/velocitas
CLI_DOWNLOAD_URL="https://github.com/eclipse-velocitas/cli/releases/download/${DESIRED_VERSION_TAG}/${CLI_ASSET_NAME}"

echo "> Downloading Velocitas CLI from ${CLI_DOWNLOAD_URL}"
sudo curl -s -L ${CLI_DOWNLOAD_URL} -o "${CLI_INSTALL_PATH}"
sudo chmod +x "${CLI_INSTALL_PATH}"
else
echo "> Up to date!"
fi

echo "> Using CLI: $(velocitas --version)"
.devcontainer/scripts/upgrade-cli.sh
50 changes: 50 additions & 0 deletions .devcontainer/scripts/setup-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
# This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json
# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

echo "#######################################################"
echo "### Install Prerequisites and Tools ###"
echo "#######################################################"

if [[ -z "${VELOCITAS_OFFLINE}" ]]; then
# Optionally install the cmake for vcpkg
.devcontainer/scripts/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}

# Install python, conan and ccache
sudo apt-get update
sudo apt-get install -y python3
sudo apt-get install -y python3-distutils
curl -fsSL https://bootstrap.pypa.io/get-pip.py | sudo python3
sudo apt-get -y install --no-install-recommends ccache

build_arch=$(arch)

# ensure we can always build for an arm target
if [ "${build_arch}" != "aarch64" ]; then
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
fi

pip3 install -r ./requirements.txt

# Install static analyzer tools
sudo apt-get install -y cppcheck clang-format-14 clang-tidy-14
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 100
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-14 100
fi

echo "#######################################################"
echo "### Install Dependencies ###"
echo "#######################################################"
velocitas exec build-system install 2>&1 | tee -a $HOME/install_dependencies.log
26 changes: 26 additions & 0 deletions .devcontainer/scripts/setup-git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json
# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

echo "#######################################################"
echo "### Setup Git ###"
echo "#######################################################"
# Add git name and email from env variables
if [[ -n "${GIT_CONFIG_NAME}" && -n "${GIT_CONFIG_EMAIL}" ]]; then
git config --global user.name $GIT_CONFIG_NAME
git config --global user.email $GIT_CONFIG_EMAIL
fi

git config --global --add safe.directory "*"
Loading

0 comments on commit 782cd03

Please sign in to comment.