diff --git a/.github/scripts/release.py b/.github/scripts/release.py deleted file mode 100755 index 5809e723..00000000 --- a/.github/scripts/release.py +++ /dev/null @@ -1,154 +0,0 @@ - -import argparse, copy, hashlib, json, re, requests, os, shutil - -version = '0.2.1' - -xmc_ino_root_path = os.path.relpath(os.path.join(os.path.join(os.getcwd(), os.pardir), os.pardir)) -build_dir_name = 'pkg_build' -pkg_assets_build_path = os.path.join(xmc_ino_root_path , build_dir_name) - -def strip_prefix_from_version(version): - return re.sub(r'[vV]', '', version) - -def mkdir_package_dir(version): - semver = strip_prefix_from_version(version) - pkg_name = "XMC_IFX_" + semver - pkg_build_path = os.path.join(pkg_assets_build_path, pkg_name) - os.mkdir(pkg_build_path) - - return pkg_name - -def build_package(pkg_name): - pkg_build_path = os.path.join(pkg_assets_build_path, pkg_name) - - dirs_to_copy = [ - 'cores', - 'libraries', - 'tools', - 'variants' - ] - - files_to_copy = [ - 'boards.txt', - 'keywords.txt', - 'package.json', - 'platform.txt', - 'LICENSE.md', - 'README.md' - ] - - ignore_pattern = shutil.ignore_patterns() - - for dir in dirs_to_copy: - if dir == 'libraries': - ignore_pattern = shutil.ignore_patterns('Makefile', 'Makefile.test', 'test') - shutil.copytree(os.path.join(xmc_ino_root_path, dir), os.path.join(pkg_build_path, dir), ignore=ignore_pattern) - - for file in files_to_copy: - shutil.copyfile(os.path.join(xmc_ino_root_path, file), os.path.join(pkg_build_path, file)) - -def zip_package(pkg_name): - pkg_build_path = os.path.join(pkg_assets_build_path, pkg_name) - shutil.make_archive(pkg_build_path, 'zip', pkg_assets_build_path, pkg_name) - -def get_package_size(pkg): - return os.path.getsize(pkg) - -def get_package_sha256(pkg): - with open(pkg,"rb") as f: - bytes = f.read() - hash = hashlib.sha256(bytes).hexdigest() - - return hash - -def get_latest_package_index_json(): - return requests.get('https://github.com/Infineon/XMC-for-Arduino/releases/latest/download/package_infineon_index.json').json() - -def get_local_package_index_json(): - with open(os.path.join(xmc_ino_root_path, 'package/package_infineon_index.template.json'), 'r') as f: - data = json.load(f) - return data - -def get_platform_data_struct_copy(pkg_index): - return copy.deepcopy(pkg_index['packages'][0]['platforms']) - -def set_new_platform_data_fields(platform_data_index, pkg_name, version, repository): - semver = strip_prefix_from_version(version) - platform_data = platform_data_index['packages'][0]['platforms'][0] - platform_data['version'] = str(semver) - archive_file_name = str(pkg_name) + ".zip" - platform_data['archiveFileName'] = archive_file_name - platform_data['url'] = "https://github.com/" + str(repository) + "/releases/download/" + str(version) + "/" + str(archive_file_name) - platform_data['checksum'] ="SHA-256:" + str(get_package_sha256(os.path.join(pkg_assets_build_path, archive_file_name))) - platform_data['size'] = str(get_package_size(os.path.join(pkg_assets_build_path, archive_file_name))) - -def add_platform_to_package_index(pkg_index, platform): - pkg_index['packages'][0]['platforms'].extend(platform) - -def make_package_index_file(pkg_index): - pkg_index_json_obj = json.dumps(pkg_index, indent=2) - pkg_index_w_path = os.path.join(pkg_assets_build_path, "package_infineon_index.json") - with open(pkg_index_w_path, "w") as pkg_file: - pkg_file.write(pkg_index_json_obj) - -def build_package_index_json(pkg_name, version, repository): - # get online package index json - latest_package_index = get_latest_package_index_json() - # get local package index template - local_package_index = get_local_package_index_json() - # set data field in local template for newest package - set_new_platform_data_fields(local_package_index, pkg_name, version, repository) - # get old package array - old_platform_data = get_platform_data_struct_copy(latest_package_index) - # append to local package index - add_platform_to_package_index(local_package_index, old_platform_data) - make_package_index_file(local_package_index) - -def build_release_assets(version, repository): - if os.path.exists(pkg_assets_build_path): - shutil.rmtree(pkg_assets_build_path) - os.mkdir(pkg_assets_build_path) - pkg_name = mkdir_package_dir(version) - build_package(pkg_name) - zip_package(pkg_name) - build_package_index_json(pkg_name, version, repository) - -def parser(): - - def main_parser_func(args): - parser.print_help() - - def parser_build_release_assets_func(args): - global xmc_ino_root_path - global pkg_build_path - xmc_ino_root_path = args.root_path - pkg_build_path = args.build_path - build_release_assets(args.version, args.repository) - - class ver_action(argparse.Action): - def __init__(self, option_strings, dest, **kwargs): - return super().__init__(option_strings, dest, nargs=0, default=argparse.SUPPRESS, **kwargs) - - def __call__(self, parser, namespace, values, option_string, **kwargs): - print('xmc-release version: ' + version) - parser.exit() - - # General parser - parser = argparse.ArgumentParser(description="xmc-release tool") - parser.add_argument('-v','--version', action=ver_action, help='xmc-release version') - subparser = parser.add_subparsers() - parser.set_defaults(func=main_parser_func) - - # Release parser - parser_release = subparser.add_parser('build-release', description='Build package release assets') - parser_release.add_argument('repository', type=str, help='Repository name') - parser_release.add_argument('version', type=str, help='Package release version (format: Vx.y.z)') - parser_release.add_argument('-r','--root-path', type=str, default=xmc_ino_root_path, help='Path to the XMC-for-Arduino root path') - parser_release.add_argument('-b','--build-path', type=str, default=pkg_assets_build_path, help='Path to build package') - parser_release.set_defaults(func=parser_build_release_assets_func) - - args = parser.parse_args() - args.func(args) - -if __name__ == "__main__": - parser() \ No newline at end of file diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml new file mode 100644 index 00000000..16e1b4e9 --- /dev/null +++ b/.github/workflows/compile-examples.yml @@ -0,0 +1,9 @@ +name: Compile examples + +on: + push: + +jobs: + compile-examples: + uses: Infineon/arduino-devops/.github/workflows/compile-examples.yml@latest + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/compile-platform-examples.yml b/.github/workflows/compile-platform-examples.yml deleted file mode 100644 index 64ba263a..00000000 --- a/.github/workflows/compile-platform-examples.yml +++ /dev/null @@ -1,207 +0,0 @@ - -name: Compile Examples - -# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows -on: - push: - paths: - - ".github/workflows/compile-platform-examples.ya?ml" - - "cores/**" - - "libraries/**" - - "variants/**" - - "boards.txt" - - "platform.txt" - pull_request: - paths: - - ".github/workflows/compile-platform-examples.ya?ml" - - "cores/**" - - "libraries/**" - - "variants/**" - - "boards.txt" - - "platform.txt" - workflow_dispatch: - repository_dispatch: - -jobs: - build: - name: ${{ matrix.board.fqbn }} - runs-on: ubuntu-latest - - env: - SKETCHES_REPORTS_PATH: sketches-reports - - strategy: - fail-fast: false - - matrix: - board: - - fqbn: Infineon:xmc:XMC1100_Boot_Kit - i2s: true - dieTemp: true - heapMem: true - sleep1100: true - sleep4700 : false - stackMem: true - dma: false - alarmRtc: false - can: false - - fqbn: Infineon:xmc:XMC1100_XMC2GO - i2s: true - dieTemp: true - heapMem: true - sleep1100: true - sleep4700 : false - stackMem: true - dma: false - alarmRtc: false - can: false - - fqbn: Infineon:xmc:XMC1300_Boot_Kit - i2s: false - dieTemp: true - heapMem: true - sleep1100: true - sleep4700 : false - stackMem: true - multiSerial: false - dma: false - alarmRtc: false - can: false - - fqbn: Infineon:xmc:XMC4200_Platform2GO - i2s: false - dieTemp: false - heapMem: false - sleep1100: false - sleep4700 : false - stackMem: true - multiSerial: false - dma: false - alarmRtc: true - can: true - - fqbn: Infineon:xmc:XMC4400_Platform2GO - i2s: false - dieTemp: false - heapMem: false - sleep1100: false - sleep4700 : false - stackMem: true - dma: false - alarmRtc: false - can: true - - fqbn: Infineon:xmc:XMC4700_Relax_Kit - i2s: true - dieTemp: true - heapMem: true - sleep1100: false - sleep4700 : true - stackMem: true - multiSerial: true - dma: true - alarmRtc: true - can: true - - fqbn: Infineon:xmc:XMC1400_XMC2GO - i2s: true - dieTemp: true - heapMem: true - sleep1100: true - sleep4700 : false - stackMem: false - dma: false - alarmRtc: false - can: true - - fqbn: Infineon:xmc:XMC1400_Arduino_Kit - i2s: false - dieTemp: true - heapMem: true - sleep1100: true - sleep4700 : false - stackMem: false - multiSerial: false - dma: false - alarmRtc: false - can: false - - # Make board type-specific customizations to the matrix jobs - include: - - board: - i2s: true - i2s-sketch-paths: | - - libraries/I2S - - board: - dieTemp: true - dieTemp-sketch-paths: | - - libraries/DeviceControlXMC/examples/DieTemperatureMeasurement - - board: - heapMem: true - heapMem-sketch-paths: | - - libraries/DeviceControlXMC/examples/HeapMemoryMeasurement - - board: - sleep1100: true - sleep1100-sketch-paths: | - - libraries/DeviceControlXMC/examples/SleepModeXMC1100 - - board: - sleep4700: true - sleep4700-sketch-paths: | - - libraries/DeviceControlXMC/examples/SleepModeXMC4700 - - board: - stackMem: true - stackMem-sketch-paths: | - - libraries/DeviceControlXMC/examples/StackMemoryMeasurement - - board: - dma: true - dma-sketch-paths: | - - libraries/DMA - - board: - alarmRtc: true - alarmRtc-sketch-paths: | - - libraries/RTC/examples/AlarmRTC - - board: - can: true - can-sketch-paths: | - - libraries/CAN/examples - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Compile examples - uses: arduino/compile-sketches@v1.1.1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - fqbn: ${{ matrix.board.fqbn }} - platforms: | - # Use Boards Manager to install the latest release of the platform to get the toolchain. - - name: Infineon:xmc - source-url: https://github.com/${{ github.repository }}/releases/latest/download/package_infineon_index.json - - - source-path: ./ - name: Infineon:xmc - sketch-paths: | - # Compile these sketches for all boards - - libraries/LED - - libraries/RTC/examples/SimpleRTC - - libraries/SPI - - libraries/Wire - # Board-specific sketches - ${{ matrix.i2s-sketch-paths }} - ${{ matrix.dieTemp-sketch-paths }} - ${{ matrix.heapMem-sketch-paths }} - ${{ matrix.sleep1100-sketch-paths }} - ${{ matrix.sleep4700-sketch-paths }} - ${{ matrix.stackMem-sketch-paths }} - ${{ matrix.multiSerial-sketch-paths }} - ${{ matrix.dma-sketch-paths }} - ${{ matrix.alarmRtc-sketch-paths }} - ${{ matrix.can-sketch-paths }} - enable-deltas-report: false - sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} - - - name: Modify the environment variable - run: | - BOARD_NAME=$(echo ${{ matrix.board.fqbn }} | sed 's/:/-/g') - echo "BOARD_NAME=$BOARD_NAME" >> $GITHUB_ENV - - - name: Save sketches report as workflow artifact - uses: actions/upload-artifact@v4 - with: - if-no-files-found: error - name: ${{ env.SKETCHES_REPORTS_PATH }}-${{ env.BOARD_NAME }} - path: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ecb094d2..7ecab897 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,39 +1,11 @@ -name: XMC-for-Arduino Release Automation +name: Release on: - release: - types: published push: - tags: - - 'v*.*.*' - - 'V*.*.*' + jobs: - release: - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/V') - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - run: pip install requests - - - name: Build release changelog - id: build_changelog - uses: mikepenz/release-changelog-builder-action@v3 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Build release assets - run: | - cd .github/scripts - python release.py build-release ${{ github.repository }} ${{ github.ref_name }} - - - name: Upload assets - uses: softprops/action-gh-release@v1 - with: - name: XMC-for-Arduino ${{ github.ref_name }} - files: | - pkg_build/*.zip - pkg_build/package_infineon_index.json - body: ${{steps.build_changelog.outputs.changelog}} \ No newline at end of file + arduino-devops: + uses: Infineon/arduino-devops/.github/workflows/release.yml@latest + with: + release-title: XMC-for-Arduino + secrets: inherit \ No newline at end of file diff --git a/ci-matrix-config.yml b/ci-matrix-config.yml new file mode 100644 index 00000000..cb1b9aa2 --- /dev/null +++ b/ci-matrix-config.yml @@ -0,0 +1,59 @@ +sketch: + - libraries/LED + - libraries/RTC/examples/SimpleRTC + - libraries/SPI + - libraries/Wire + - libraries/DeviceControlXMC/examples/DieTemperatureMeasurement/DieTemperatureMeasurement.ino + - libraries/DeviceControlXMC/examples/HeapMemoryMeasurement/HeapMemoryMeasurement.ino + - libraries/DeviceControlXMC/examples/StackMemoryMeasurement/StackMemoryMeasurement.ino + +include: + - fqbn: Infineon:xmc:XMC1100_Boot_Kit + sketch: + - libraries/I2S + - libraries/DeviceControlXMC/examples/SleepModeXMC1100/SleepModeXMC1100.ino + - fqbn: Infineon:xmc:XMC1100_XMC2GO + sketch: + - libraries/I2S + - libraries/DeviceControlXMC/examples/SleepModeXMC1100/SleepModeXMC1100.ino + - fqbn: Infineon:xmc:XMC1300_Boot_Kit + sketch: + - libraries/DeviceControlXMC/examples/SleepModeXMC1100/SleepModeXMC1100.ino + - fqbn: Infineon:xmc:XMC1400_XMC2GO + sketch: + - libraries/I2S + - libraries/DeviceControlXMC/examples/SleepModeXMC1100/SleepModeXMC1100.ino + - libraries/CAN + - fqbn: Infineon:xmc:XMC1400_Arduino_Kit + sketch: + - libraries/DeviceControlXMC/examples/SleepModeXMC1100/SleepModeXMC1100.ino + - fqbn: Infineon:xmc:XMC4200_Platform2GO + sketch: + - libraries/RTC/examples/AlarmRTC/AlarmRTC.ino + - libraries/CAN + - fqbn: Infineon:xmc:XMC4400_Platform2GO + sketch: + - libraries/CAN + - fqbn: Infineon:xmc:XMC4700_Relax_Kit + sketch: + - libraries/I2S + - libraries/DeviceControlXMC/examples/SleepModeXMC4700/SleepModeXMC4700.ino + - libraries/DMA + - libraries/RTC/examples/AlarmRTC/AlarmRTC.ino + - libraries/CAN + +exclude: + - fqbn: Infineon:xmc:XMC1400_XMC2GO + sketch: + - libraries/DeviceControlXMC/examples/StackMemoryMeasurement/StackMemoryMeasurement.ino + - fqbn: Infineon:xmc:XMC1400_Arduino_Kit + sketch: + - libraries/DeviceControlXMC/examples/StackMemoryMeasurement/StackMemoryMeasurement.ino + - fqbn: Infineon:xmc:XMC4200_Platform2GO + sketch: + - libraries/DeviceControlXMC/examples/DieTemperatureMeasurement/DieTemperatureMeasurement.ino + - libraries/DeviceControlXMC/examples/HeapMemoryMeasurement/HeapMemoryMeasurement.ino + - fqbn: Infineon:xmc:XMC4400_Platform2GO + sketch: + - libraries/DeviceControlXMC/examples/DieTemperatureMeasurement/DieTemperatureMeasurement.ino + - libraries/DeviceControlXMC/examples/HeapMemoryMeasurement/HeapMemoryMeasurement.ino diff --git a/package/config.yml b/package/config.yml new file mode 100644 index 00000000..43c4104c --- /dev/null +++ b/package/config.yml @@ -0,0 +1,18 @@ +package-name: xmc-for-arduino +include: + - cores + - libraries + - tools + - variants + - boards.txt + - keywords.txt + - LICENSE.md + - package.json + - platform.txt + - programmers.txt + - README.md +index-name: package_infineon_index +server: + type: github + owner: Infineon + repo: XMC-for-Arduino \ No newline at end of file