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

Run integration tests from ci #403

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dd8db4f
Run integration tests from ci
richardapeters Sep 12, 2024
d95edfc
Use ubuntu-24.04 instead of ubuntu-latest
richardapeters Sep 12, 2024
f215a9e
Update amp-cucumber-cpp-runner: cucumber-cpp/Context.hpp: Remove depr…
richardapeters Sep 12, 2024
9a85f8c
Fix CI
richardapeters Sep 12, 2024
424ad5f
.github/workflows/ci.yml: use ubuntu-24.04 everywhere
richardapeters Sep 12, 2024
8d81a2d
.github/workflows/ci: Run flex as service
richardapeters Sep 12, 2024
75b6a3e
Add username/password credentials to flex service
richardapeters Sep 12, 2024
4cee560
use Artifactory instead of GHCR
richardapeters Sep 13, 2024
bd51e4b
.github/workflows/ci.yml: Use Postmaster container from ghcr
richardapeters Dec 4, 2024
f990ba1
Merge remote-tracking branch 'origin/main' into feature/ci-integratio…
richardapeters Dec 4, 2024
f3e2854
Update amp-cucumber-cpp-runner
richardapeters Dec 4, 2024
3b241d6
Update amp-cucumber-cpp-runner
richardapeters Dec 4, 2024
86bafcd
.github/workflows/ci.yml: remove credentials
richardapeters Dec 4, 2024
65caefe
.github/workflows/ci.yml: give read access to read packages
richardapeters Dec 4, 2024
a411933
Use ubuntu-24.04 for running autobuild for the cpp linter
richardapeters Dec 5, 2024
e2f2cae
Create codeql.yml
richardapeters Dec 5, 2024
a907dc1
Merge remote-tracking branch 'origin/richardapeters-patch-1' into fea…
richardapeters Dec 5, 2024
b6ccb66
codeql: Run on feature branches
richardapeters Dec 5, 2024
fa00004
ci.yml: Trace service output and try to connect to a Postmaster
richardapeters Dec 5, 2024
40dea14
Run integration_test.runner
richardapeters Dec 5, 2024
79c57d2
Use amp-postmaster-flex container
richardapeters Dec 5, 2024
1811243
Use postmaster IP from environment
richardapeters Dec 19, 2024
53773eb
Merge remote-tracking branch 'origin/main' into feature/ci-integratio…
richardapeters Dec 19, 2024
ee1da71
cy.yml: Use the correct parameters
richardapeters Dec 19, 2024
bb898ed
devcontainer.json: set mounts and privileges
richardapeters Dec 19, 2024
1d71e1b
Merge branch 'feature/ci-integration-test' of https://github.com/phil…
richardapeters Dec 19, 2024
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
12 changes: 12 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,17 @@
"build": {
"context": "..",
"dockerfile": "Dockerfile"
},
"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
],
"runArgs": ["--add-host=host.docker.internal:host-gateway", "--privileged"],
"postCreateCommand": "git submodule update --init --recursive",
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.vscode-serial-monitor"
]
Comment on lines +13 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MegaLinter] reported by reviewdog 🐶

Suggested change
"extensions": [
"ms-vscode.vscode-serial-monitor"
]
"extensions": ["ms-vscode.vscode-serial-monitor"]

}
}
}
40 changes: 35 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ permissions:

jobs:
host_build_test_ubuntu:
name: Host Build & Test (ubuntu-latest)
runs-on: ubuntu-latest
name: Host Build & Test (ubuntu-24.04)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: hendrikmuhs/ccache-action@ed74d11c0b343532753ecead8a951bb09bb34bc9 # v1.2.14
with:
key: ${{ github.job }}-ubuntu-latest
key: ${{ github.job }}-ubuntu-24.04
variant: sccache
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # v5
- uses: lukka/run-cmake@af1be47fd7c933593f687731bc6fdbee024d3ff4 # v10.8
Expand All @@ -45,7 +45,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest]
os: [windows-latest]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
Expand All @@ -68,7 +68,7 @@ jobs:
path: build/host/Testing/Temporary/
embedded_build:
name: Embedded Build
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: [host_build_test_ubuntu]
strategy:
matrix:
Expand Down Expand Up @@ -116,3 +116,33 @@ jobs:
configurePreset: ${{ matrix.target }}
buildPreset: ${{ matrix.target }}-${{ matrix.configuration }}
configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=ccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache']"

integration_test:
name: Integration test
runs-on: ubuntu-24.04
needs: [embedded_build, host_build_test_ubuntu]
permissions:
packages: read
services:
flex:
image: ghcr.io/philips-software/amp-postmaster-flex:pr-5
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
ports:
- 1234:1234/tcp
- 1235:1235/tcp
env:
POSTMASTER_IP: ${{ vars.ENV_POSTMASTER_IP }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: hal_st
- run: tar -zxvf hal_st-*.tar.gz
- run: mkdir install && mv hal_st-*/* install/
- run: ls install/bin
- run: install/bin/integration_test.runner run --feature integration_test/runner/features --report console --target tcp://localhost:1234/target/echo/programmer
- run: docker logs "${{ job.services.flex.id }}"
92 changes: 92 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL Advanced"

on:
push:
branches: [ "main" ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MegaLinter] reported by reviewdog 🐶

Suggested change
branches: [ "main" ]
branches: ["main"]

pull_request:
types: [opened, synchronize, reopened]

permissions: read-all

jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-24.04' }}
permissions:
# required for all workflows
Fixed Show fixed Hide fixed
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
include:
- language: c-cpp
build-mode: autobuild
Comment on lines +46 to +47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MegaLinter] reported by reviewdog 🐶

Suggested change
- language: c-cpp
build-mode: autobuild
- language: c-cpp
build-mode: autobuild

# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4
Comment on lines +57 to +58
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MegaLinter] reported by reviewdog 🐶

Suggested change
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4


# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
Comment on lines +60 to +68
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MegaLinter] reported by reviewdog 🐶

Suggested change
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.


# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
Comment on lines +70 to +71
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MegaLinter] reported by reviewdog 🐶

Suggested change
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
Comment on lines +73 to +87
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MegaLinter] reported by reviewdog 🐶

Suggested change
# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1


- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
Comment on lines +89 to +92
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MegaLinter] reported by reviewdog 🐶

Suggested change
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"

2 changes: 1 addition & 1 deletion .github/workflows/linting-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:
jobs:
linter:
name: Linter
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: write
Expand Down
36 changes: 34 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ if (HALST_STANDALONE)
FetchContent_Declare(
emil
GIT_REPOSITORY https://github.com/philips-software/amp-embedded-infra-lib.git
GIT_TAG 37efc4e7e0ecbdac4ca77c79f13e8f813cc81d8c # unreleased
GIT_TAG d3187781f76783646ceca5e3605cedef0bab364e # unreleased
)
FetchContent_MakeAvailable(emil)

if (EMIL_HOST_BUILD)
FetchContent_Declare(
cucumber-cpp-runner
GIT_REPOSITORY https://github.com/philips-software/amp-cucumber-cpp-runner.git
GIT_TAG 70c424e53f532f520d96a303b6586272d3efc5f5 # unreleased
GIT_TAG 145ef9eda8198ba080f610859e24d998cde83b0e # unreleased
)

FetchContent_MakeAvailable(cucumber-cpp-runner)
Expand Down Expand Up @@ -76,6 +76,38 @@ if (HALST_STANDALONE)
emil_folderize_all_targets()
endif()

if (HALST_STANDALONE AND NOT CMAKE_CROSSCOMPILING)
function(generate_export_targets name)
install(EXPORT halst${name}Targets
FILE halst${name}Targets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/halst
)
endfunction()

foreach(target IN ITEMS IntegrationTest)
generate_export_targets(${target})
endforeach()

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
COMPATIBILITY SameMajorVersion
# When cross-compiling for a 32-bit architecture and re-using host tooling from a 64-bit architecture
# ARCH_INDEPENDENT is necessary here. See: https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html.
ARCH_INDEPENDENT
)

configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
endif()

set(CPACK_GENERATOR "ZIP;TGZ")
set(CPACK_SOURCE_IGNORE_FILES ".vs/;.git/;build/")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
Expand Down
5 changes: 5 additions & 0 deletions cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/halstIntegrationTestTargets.cmake")

check_required_components(IntegrationTest)
5 changes: 3 additions & 2 deletions integration_test/runner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_executable(integration_test.runner)
emil_build_for(integration_test.runner HOST Windows)
emil_build_for(integration_test.runner HOST All PREREQUISITE_BOOL HALST_STANDALONE)
emil_install(integration_test.runner EXPORT halstIntegrationTestTargets DESTINATION bin)

target_sources(integration_test.runner PRIVATE
FixtureEcho.cpp
Expand All @@ -14,7 +15,7 @@ target_sources(integration_test.runner PRIVATE

target_link_libraries(integration_test.runner PRIVATE
args
cucumber-cpp
cucumber_cpp.runner
integration_test.logic
hal.generic
gtest
Expand Down
2 changes: 1 addition & 1 deletion integration_test/runner/Hooks.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "cucumber-cpp/Hooks.hpp"
#include "cucumber_cpp/library/Hooks.hpp"
#include "generated/echo/Testing.pb.hpp"
#include "hal/generic/TimerServiceGeneric.hpp"
#include "infra/timer/Waiting.hpp"
Expand Down
2 changes: 1 addition & 1 deletion integration_test/runner/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "cucumber-cpp/Application.hpp"
#include "cucumber_cpp/library/Application.hpp"

int main(int argc, char** argv)
{
Expand Down
2 changes: 1 addition & 1 deletion integration_test/runner/StepsGpio.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "cucumber-cpp/Steps.hpp"
#include "cucumber_cpp/library/Steps.hpp"
#include "generated/echo/Testing.pb.hpp"
#include "infra/timer/Waiting.hpp"
#include "integration_test/logic/Tested.hpp"
Expand Down
2 changes: 1 addition & 1 deletion integration_test/runner/StepsUart.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "cucumber-cpp/Steps.hpp"
#include "cucumber_cpp/library/Steps.hpp"
#include "generated/echo/Testing.pb.hpp"
#include "infra/timer/Waiting.hpp"
#include "integration_test/logic/Tested.hpp"
Expand Down
2 changes: 1 addition & 1 deletion integration_test/runner/Waiting.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef INTEGRATION_TEST_WAITING_HPP
#define INTEGRATION_TEST_WAITING_HPP

#include "cucumber-cpp/Context.hpp"
#include "cucumber_cpp/library/Context.hpp"
#include "infra/timer/Timer.hpp"

namespace infra
Expand Down
Loading