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

chore: Unify repos #8

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
49 changes: 49 additions & 0 deletions .github/actions/prepare-int-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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

name: Prepare integration tests
description: Executed some steps to prepare the integration tests.
inputs:
package:
required: true
description: The name of the package which should be tested.

runs:
using: composite
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Set commit id
shell: bash
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
BRANCH_NAME_PREFIX: "@"
run: |
NEW_CONFIG="$(jq --arg BRANCH "$BRANCH_NAME_PREFIX$BRANCH_NAME" '.packages |= . + { (. | keys_unsorted[0]): $BRANCH }' ${{ inputs.package }}/test/.velocitas.json)"
echo "${NEW_CONFIG}" > ${{ inputs.package }}/test/.velocitas.json

- name: Install Velocitas CLI and Python requirements
shell: bash
run: |
sudo curl -L https://github.com/eclipse-velocitas/cli/releases/latest/download/velocitas-linux-x64 -o /usr/bin/velocitas
sudo chmod +x /usr/bin/velocitas
pip install -r ${{ inputs.package }}/test/requirements.txt

- name: Init velocitas project
shell: bash
run: |
cd ${{ inputs.package }}/test
velocitas init -v
39 changes: 39 additions & 0 deletions .github/actions/update-velocitas-json/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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

name: update-velocitas-json
description: Update the project's velocitas JSON.
inputs:
project_dir:
description: Directory containing the Velocitas project
required: true
template_file:
description: JSON file which will replace the .velocitas.json file.
default: None
runs:
using: composite
steps:
- name: Set commit id
shell: bash
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
BRANCH_NAME_PREFIX: "@"
run: |
if [ "${{ inputs.template_file }}" != "None" ]; then
echo "Copying template file..."
cp -f ${{ inputs.template_file }} ${{ inputs.project_dir }}/.velocitas.json
fi

NEW_CONFIG="$(jq --arg BRANCH "$BRANCH_NAME_PREFIX$BRANCH_NAME" '.packages |= . + { (. | keys_unsorted[0]): $BRANCH }' ${{ inputs.project_dir }}/.velocitas.json)"
echo "${NEW_CONFIG}" > ${{ inputs.project_dir }}/.velocitas.json
182 changes: 182 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# 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

name: CI
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
push:
# Run only on branches/commits and not tags
branches:
- main
pull_request:
branches:
- main

jobs:
unit-test:
name: Run unit tests
runs-on: ubuntu-22.04
container: ghcr.io/eclipse-velocitas/devcontainer-base-images/python:v0.3
strategy:
matrix:
component:
[
"build-system/cpp-cmake-conan",
"conan-setup",
"devcontainer-setup",
"github-templates",
"github-workflows",
"grpc-interface-support",
"pantaris-integration",
"runtime-kanto",
"runtime-local",
"sdk-installer",
"vehicle-signal-interface"
]
fail-fast: false

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install required packages
run: |
REQUIREMENTS=components/extensions/${{ matrix.component }}/requirements.txt
REQUIREMENTS_TEST=components/extensions/${{ matrix.component }}/test/requirements.txt

if [ -e "${REQUIREMENTS}" ]; then
pip install -r ${REQUIREMENTS}
fi

if [ -e "${REQUIREMENTS_TEST}" ]; then
pip install -r ${REQUIREMENTS_TEST}
fi

- name: unit test
id: unit_test
shell: bash
run: |
TEST_DIR=components/extensions/${{ matrix.component }}/test/unit
if [ -e "${TEST_DIR}" ]; then
pytest --override-ini junit_family=xunit1 \
--junit-xml=./results/UnitTest/${{ matrix.component }}/junit.xml \
--cov . \
--cov-report=xml:results/CodeCoverage/${{ matrix.component }}/cobertura-coverage.xml \
--cov-branch \
${TEST_DIR}

echo "test_ran=true\n" >> $GITHUB_OUTPUT
fi

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: steps.unit_test.outputs.test_ran == true
with:
report_paths: ./results/UnitTest/${{ matrix.component }}/junit.xml
summary: true
update_check: true
annotate_only: true

- uses: irongut/[email protected]
if: steps.unit_test.outputs.test_ran == true
with:
filename: results/CodeCoverage/${{ matrix.component }}/cobertura-coverage.xml
badge: true
format: markdown
hide_complexity: true
indicators: true
output: both

- if: steps.unit_test.outputs.test_ran == true
run: |
cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY

run-integration-tests:
name: Run Integration Test
runs-on: ubuntu-22.04
env:
packageInstallPath: .velocitas/packages/package_under_test/@main
strategy:
matrix:
language: ["python", "cpp"]
component:
[
"build-system/cpp-cmake-conan",
"conan-setup",
"devcontainer-setup",
"github-templates",
"github-workflows",
"grpc-interface-support",
"pantaris-integration",
"runtime-kanto",
"runtime-local",
"sdk-installer",
"vehicle-signal-interface"
]
fail-fast: false

steps:
- name: Checkout template repository
uses: actions/checkout@v4
with:
repository: eclipse-velocitas/vehicle-app-${{ matrix.language }}-template
fetch-depth: 0

- name: Checkout package repository
uses: actions/checkout@v4
with:
path: ${{ env.packageInstallPath }}
fetch-depth: 0

- name: Add safe directory
run: |
git config --global --add safe.directory "*"

- name: Replace project config
run: |
cat ${{ env.packageInstallPath }}/components/extensions/${{ matrix.component }}/test/.velocitas.json | sed -e 's/$language/${{ matrix.language }}/g' > .velocitas.json
cat .velocitas.json

- name: Run devContainer
uses: devcontainers/[email protected]
with:
env: VELOCITAS_HOME=/workspaces/pkg-velocitas-main
runCmd: |
CWD=$(pwd)

export VELOCITAS_TEMPLATE_REPO_PATH=$CWD
export VELOCITAS_PACKAGE_REPO_PATH=$CWD/${{ env.packageInstallPath }}
export VELOCITAS_TEST_LANGUAGE=${{ matrix.language }}
export VELOCITAS_COMPONENT_PATH=${VELOCITAS_PACKAGE_REPO_PATH}/components/extensions/${{ matrix.component }}

cd $VELOCITAS_PACKAGE_REPO_PATH

REQUIREMENTS_TEST=components/extensions/${{ matrix.component }}/test/requirements.txt
if [ -e "${REQUIREMENTS_TEST}" ]; then
python -m pip install -r ./components/extensions/${{ matrix.component }}/test/requirements.txt
fi

REQUIREMENTS=components/extensions/${{ matrix.component }}/requirements.txt
if [ -e "${REQUIREMENTS}" ]; then
python -m pip install -r ./components/extensions/${{ matrix.component }}/requirements.txt
fi

TESTS=./components/extensions/${{ matrix.component }}/test/integration
if [ -e "${TESTS}" ]; then
pytest -s ./components/extensions/${{ matrix.component }}/test/integration
fi
105 changes: 105 additions & 0 deletions .github/workflows/github-templates.x_yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# 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

name: CI-devenv-github-templates
concurrency:
group: ${{ github.ref }}-devenv-github-templates
cancel-in-progress: true

on:
workflow_dispatch:
push:
# Run only on branches/commits and not tags
branches:
- main
pull_request:
branches:
- main

jobs:
run-integration-tests:
name: Run Integration Test
runs-on: ubuntu-22.04
container: ghcr.io/eclipse-velocitas/devcontainer-base-images/${{ matrix.language }}:v0.3
strategy:
matrix:
language: ["python", "cpp"]
fail-fast: false

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Fix dubious ownership
run: |
git config --global --add safe.directory $( pwd )

- name: Checkout template repo
uses: actions/checkout@v4
with:
repository: eclipse-velocitas/vehicle-app-${{ matrix.language }}-template
path: test/${{ matrix.language }}/repo

- name: Update Velocitas JSON with correct version
uses: ./.github/actions/update-velocitas-json
with:
project_dir: test/${{ matrix.language }}/repo
template_file: test/${{ matrix.language }}/.velocitas.json

- name: Init velocitas project
run: |
cd test/${{ matrix.language }}/repo
velocitas init

- name: Sync velocitas project
run: |
cd test/${{ matrix.language }}/repo
velocitas sync

- name: Reset .velocitas.json to latest template state
run: |
cd test/${{ matrix.language }}/repo
git checkout .velocitas.json

- name: Identify changes in devenv repo
uses: dorny/paths-filter@v2
id: changesInPath
with:
filters: |
templatesApp:
- 'src/app/**'
templatesSdk:
- 'src/sdk/**'

- name: Check if cloned template repo has changes after sync
if: (steps.changesInPath.outputs.templatesApp == 'true' || steps.changesInPath.outputs.templatesSdk == 'true')
id: changes
run: |
cd test/${{ matrix.language }}/repo
git diff
if [[ -z "$(git status --porcelain .)" ]];
then
echo "No Changes"
echo "changed=0" >> $GITHUB_OUTPUT
else
echo "Changes"
echo "changed=1" >> $GITHUB_OUTPUT
fi
shell: bash

- name: Fail if there are changes in setup files detected but sync probably failed
if: |
(steps.changes.outputs.changed == 0 && steps.changesInPath.outputs.templatesApp == 'true') ||
(steps.changes.outputs.changed == 0 && steps.changesInPath.outputs.templatesSdk == 'true')
run: exit 1
Loading
Loading