Skip to content

Commit

Permalink
Add velocitas config update action (#55)
Browse files Browse the repository at this point in the history
* Add velocitas config update action
* Update for slim project config

---------

Signed-off-by: Dennis Meister <[email protected]>
  • Loading branch information
dennismeister93 authored May 7, 2024
1 parent 80adbf9 commit 0eeb7a0
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 24 deletions.
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
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ jobs:
repository: eclipse-velocitas/vehicle-app-${{ matrix.language }}-template
path: test/${{ matrix.language }}/repo

- name: Prepare .velocitas.json for integration test
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
NEW_CONFIG="$(jq --arg BRANCH "$BRANCH_NAME" '.packages[0].version |= $BRANCH' test/${{ matrix.language }}/.velocitas.json)"
echo "${NEW_CONFIG}" > test/${{ matrix.language }}/repo/.velocitas.json
- 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: |
Expand Down
17 changes: 8 additions & 9 deletions test/cpp/.velocitas.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"packages": [
{
"name": "devenv-github-workflows",
"version": "hash_id"
}
],
"packages": {
"devenv-github-workflows": "hash_id"
},
"variables": {
"appManifestPath": "app/AppManifest.json",
"language": "cpp",
"repoType": "app",
"appManifestPath": "app/AppManifest.json",
"githubRepoId": "eclipse-velocitas/vehicle-app-cpp-template",
"appExecutionPlatforms": "linux/amd64"
}
"appExecutionPlatforms": "linux/amd64",
"generatedModelPath": "./app/vehicle_model"
},
"cliVersion": "v0.9.0"
}
16 changes: 7 additions & 9 deletions test/python/.velocitas.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"packages": [
{
"name": "devenv-github-workflows",
"version": "hash_id"
}
],
"packages": {
"devenv-github-workflows": "hash_id"
},
"variables": {
"appManifestPath": "app/AppManifest.json",
"language": "python",
"repoType": "app",
"appManifestPath": "app/AppManifest.json",
"githubRepoId": "eclipse-velocitas/vehicle-app-python-template",
"appExecutionPlatforms": "linux/amd64"
}
"generatedModelPath": "./gen/vehicle_model"
},
"cliVersion": "v0.9.0"
}

0 comments on commit 0eeb7a0

Please sign in to comment.