Skip to content

Commit

Permalink
[ci] fix PlatformIO deployment script
Browse files Browse the repository at this point in the history
ci: fix PlatformIO deployment script
fix: fix Coverity issues
  • Loading branch information
igor-krechetov committed May 15, 2023
1 parent 8689872 commit c3f1e16
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 27 deletions.
30 changes: 26 additions & 4 deletions .github/workflows/deploy-platformio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: "Deploy PlatformIO library"

on:
workflow_dispatch:
inputs:
version:
type: string
# Start only after Build was finished
workflow_run:
workflows: [Build]
Expand All @@ -16,7 +19,7 @@ jobs:

runs-on: ubuntu-latest
outputs:
commit_version: ${{ steps.get_version.outputs.commit_version }}
commit_version: ${{ steps.finalize_version.outputs.commit_version }}
commit_action: ${{ steps.get_version.outputs.commit_action }}

steps:
Expand All @@ -27,6 +30,23 @@ jobs:
repo_dir: ${{ env.GITHUB_WORKSPACE }}
commit_sha: ${{ github.event.workflow_run.head_sha }}

- name: Check user input
if: ${{ github.event.inputs.version != '' }}"
id: check_user_input
run: |
echo "TEMP_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Check commit version
id: check_commit
if: ${{ github.event.inputs.version == '' }}
run: |
echo "TEMP_VERSION=${{ steps.get_version.outputs.commit_version }}" >> $GITHUB_ENV
- name: Final
id: finalize_version
run: |
echo "commit_version=$TEMP_VERSION" >> $GITHUB_OUTPUT
deploy-platformio:
runs-on: ubuntu-latest
needs: check-hsmcpp-version
Expand Down Expand Up @@ -75,12 +95,14 @@ jobs:
run: cp -Rv ./main/build/deploy/platformio/* "$target_dir"

- name: Publish PlatformIO package
# only publish release versions
if: ${{ needs.check-hsmcpp-version.outputs.commit_action == 'r' }}
# only publish release versions or when started manually
if: ${{ (needs.check-hsmcpp-version.outputs.commit_action == 'r') || (github.event.inputs.version != '') }}
env:
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_TOKEN }}
# $PWD is needed due to an issue in "pio pkg publish". It usese os.path.isdir() and sometimes it doesn't not
# recognize relative path as a directory
run: |
pio pkg publish ./main/build/deploy/platformio --type library --no-interactive
pio pkg publish --type library --no-interactive $PWD/main/build/deploy/platformio/
- name: Prepare commit message
run: |
Expand Down
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,25 +311,25 @@ fix: deleting HSM instance while it still had pending events sometimes cased cra
- scxml2gen: improve state description format when generating plantuml diagram
- hsmdebugger: support of timers

## [0.15.0] 2021-08-06
## [0.15.0] - 2021-08-06

### Fixed
- added namespace for hsmcpp

## [0.14.4] 2021-08-04
## [0.14.4] - 2021-08-04
### Added
- BYTEARRAY type to Variant

### Fixed
- fix build issue related with no default constructor for TransitionInfo

## [0.14.3] 2021-08-03
## [0.14.3] - 2021-08-03

### Fixed
- fix build warnings
- renamed trace macroses to avoid potential name conflicts

## [0.14.1] 2021-06-13
## [0.14.1] - 2021-06-13

### Updated
- memory footprint test
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ message("HSMBUILD_DISPATCHER_FREERTOS = ${HSMBUILD_DISPATCHER_FREERTOS}")
message("HSMBUILD_TESTS = ${HSMBUILD_TESTS}")
message("HSMBUILD_EXAMPLES = ${HSMBUILD_EXAMPLES}")
message("HSMBUILD_CODECOVERAGE = ${HSMBUILD_CODECOVERAGE}")
message("HSMBUILD_CLANGTIDY = ${HSMBUILD_CLANGTIDY}")
message("")
message("HSMBUILD_PLATFORM = ${HSMBUILD_PLATFORM}")
if (HSMBUILD_PLATFORM STREQUAL "freertos")
Expand Down
2 changes: 1 addition & 1 deletion examples/01_trafficlight/01_trafficlight_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace TrafficLightEvent {

class TrafficLight : public hsmcpp::HierarchicalStateMachine {
public:
TrafficLight(const std::shared_ptr<hsmcpp::HsmEventDispatcherGLibmm>& dispatcher, Glib::RefPtr<Glib::MainLoop> loop)
TrafficLight(const std::shared_ptr<hsmcpp::HsmEventDispatcherGLibmm>& dispatcher, const Glib::RefPtr<Glib::MainLoop>& loop)
: hsmcpp::HierarchicalStateMachine(TrafficLightState::OFF)
, mLoop(loop) {
registerState(TrafficLightState::OFF, this, &TrafficLight::onOff);
Expand Down
36 changes: 18 additions & 18 deletions include/hsmcpp/hsm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class HierarchicalStateMachine {
bool registerStateAction(const StateID_t state,
const StateActionTrigger actionTrigger,
const StateAction action,
Args... args);
Args&&... args);

/**
* @brief Registers a transition from one state to another.
Expand Down Expand Up @@ -449,7 +449,7 @@ class HierarchicalStateMachine {
* @threadsafe{ }
*/
template <typename... Args>
void transition(const EventID_t event, Args... args);
void transition(const EventID_t event, Args&&... args);

/**
* @brief Trigger a transition in the HSM.
Expand All @@ -475,7 +475,7 @@ class HierarchicalStateMachine {
* @threadsafe{ }
*/
template <typename... Args>
bool transitionEx(const EventID_t event, const bool clearQueue, const bool sync, const int timeoutMs, Args... args);
bool transitionEx(const EventID_t event, const bool clearQueue, const bool sync, const int timeoutMs, Args&&... args);

/**
* @brief Trigger a transition in the HSM with arguments passed as a vector.
Expand Down Expand Up @@ -511,7 +511,7 @@ class HierarchicalStateMachine {
* @threadsafe{ }
*/
template <typename... Args>
bool transitionSync(const EventID_t event, const int timeoutMs, Args... args);
bool transitionSync(const EventID_t event, const int timeoutMs, Args&&... args);

/**
* @brief Trigger a transition in the HSM and clear all pending events.
Expand All @@ -524,7 +524,7 @@ class HierarchicalStateMachine {
* @threadsafe{ }
*/
template <typename... Args>
void transitionWithQueueClear(const EventID_t event, Args... args);
void transitionWithQueueClear(const EventID_t event, Args&&... args);

/**
* @brief Interrupt/signal safe version of transition
Expand Down Expand Up @@ -563,7 +563,7 @@ class HierarchicalStateMachine {
* @notthreadsafe{Calling thing API from multiple threads can cause data races and will result in undefined behavior}
*/
template <typename... Args>
bool isTransitionPossible(const EventID_t event, Args... args);
bool isTransitionPossible(const EventID_t event, Args&&... args);

/**
* @brief Start a timer.
Expand Down Expand Up @@ -804,10 +804,10 @@ template <typename... Args>
bool HierarchicalStateMachine::registerStateAction(const StateID_t state,
const StateActionTrigger actionTrigger,
const StateAction action,
Args... args) {
Args&&... args) {
VariantVector_t eventArgs;

makeVariantList(eventArgs, args...);
makeVariantList(eventArgs, std::forward<Args>(args)...);
return registerStateActionImpl(state, actionTrigger, action, eventArgs);
}

Expand Down Expand Up @@ -860,38 +860,38 @@ void HierarchicalStateMachine::registerSelfTransition(const StateID_t state,
}

template <typename... Args>
void HierarchicalStateMachine::transition(const EventID_t event, Args... args) {
(void)transitionEx(event, false, false, 0, args...);
void HierarchicalStateMachine::transition(const EventID_t event, Args&&... args) {
(void)transitionEx(event, false, false, 0, std::forward<Args>(args)...);
}

template <typename... Args>
bool HierarchicalStateMachine::transitionEx(const EventID_t event,
const bool clearQueue,
const bool sync,
const int timeoutMs,
Args... args) {
Args&&... args) {
VariantVector_t eventArgs;

makeVariantList(eventArgs, args...);
makeVariantList(eventArgs, std::forward<Args>(args)...);
return transitionExWithArgsArray(event, clearQueue, sync, timeoutMs, eventArgs);
}

template <typename... Args>
bool HierarchicalStateMachine::transitionSync(const EventID_t event, const int timeoutMs, Args... args) {
return transitionEx(event, false, true, timeoutMs, args...);
bool HierarchicalStateMachine::transitionSync(const EventID_t event, const int timeoutMs, Args&&... args) {
return transitionEx(event, false, true, timeoutMs, std::forward<Args>(args)...);
}

template <typename... Args>
void HierarchicalStateMachine::transitionWithQueueClear(const EventID_t event, Args... args) {
void HierarchicalStateMachine::transitionWithQueueClear(const EventID_t event, Args&&... args) {
// NOTE: async transitions always return true
(void)transitionEx(event, true, false, 0, args...);
(void)transitionEx(event, true, false, 0, std::forward<Args>(args)...);
}

template <typename... Args>
bool HierarchicalStateMachine::isTransitionPossible(const EventID_t event, Args... args) {
bool HierarchicalStateMachine::isTransitionPossible(const EventID_t event, Args&&... args) {
VariantVector_t eventArgs;

makeVariantList(eventArgs, args...);
makeVariantList(eventArgs, std::forward<Args>(args)...);

return isTransitionPossibleImpl(event, eventArgs);
}
Expand Down

0 comments on commit c3f1e16

Please sign in to comment.