From 066de6c697ab7e23852a1162bc6d95821baaff80 Mon Sep 17 00:00:00 2001 From: Florian Loitsch Date: Thu, 14 Mar 2024 14:10:48 +0100 Subject: [PATCH 1/4] Update CI. --- .github/dependabot.yml | 8 ++++ .github/workflows/ci.yml | 91 ++++++++-------------------------------- Makefile | 8 ++-- tests/CMakeLists.txt | 6 +-- 4 files changed, 33 insertions(+), 80 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5bacb9a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" # Necessary to update action hashs + directory: "/" + schedule: + interval: "weekly" + # Allow up to 3 opened pull requests for github-actions versions + open-pull-requests-limit: 3 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f101421..910af48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,93 +9,36 @@ jobs: build: strategy: matrix: - # TODO(florian): run tests on Windows. + # TODO: test on windows. os: [ ubuntu-latest, macos-latest ] + # The versions should contain (at least) the lowest requirement + # and a version that is more up to date. + toit-version: [ v2.0.0-alpha.118, latest ] + include: + - toit-version: v2.0.0-alpha.118 + version-name: old + - toit-version: latest + version-name: new + + name: CI - ${{ matrix.os }} - ${{ matrix.version-name }} runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - - - name: Setup constants - shell: bash - run: | - TOIT_VERSION=v2.0.0-alpha.118 - echo "TOIT_VERSION=$TOIT_VERSION" >> $GITHUB_ENV - export DOWNLOAD_DIR="${{ github.workspace }}/downloads" - echo "DOWNLOAD_DIR=$DOWNLOAD_DIR" >> $GITHUB_ENV - if [[ "$RUNNER_OS" = "Linux" ]]; then - TOIT_FILE=toit-linux.tar.gz - echo "TOIT_EXEC=$DOWNLOAD_DIR/toit/bin/toit.run" >> $GITHUB_ENV - echo "TPKG_EXEC=$DOWNLOAD_DIR/toit/bin/toit.pkg" >> $GITHUB_ENV - elif [[ "$RUNNER_OS" = "macOS" ]]; then - TOIT_FILE=toit-macos.tar.gz - echo "TOIT_EXEC=$DOWNLOAD_DIR/toit/bin/toit.run" >> $GITHUB_ENV - echo "TPKG_EXEC=$DOWNLOAD_DIR/toit/bin/toit.pkg" >> $GITHUB_ENV - elif [[ "$RUNNER_OS" = "Windows" ]]; then - TOIT_FILE=toit-windows.tar.gz - echo "TOIT_EXEC=$DOWNLOAD_DIR/toit/bin/toit.run.exe" >> $GITHUB_ENV - echo "TPKG_EXEC=$DOWNLOAD_DIR/toit/bin/toit.pkg.exe" >> $GITHUB_ENV - else - echo "UNSUPPORTED RUNNER: $RUNNER_OS" - exit 1 - fi + - uses: actions/checkout@v4 - echo "TOIT_URL=https://github.com/toitlang/toit/releases/download/$TOIT_VERSION/$TOIT_FILE" >> $GITHUB_ENV + - uses: toitlang/action-setup@v1 + with: + toit-version: ${{ matrix.toit-version }} - # Fetch the dependencies. Different for each platform. - - name: Install dependencies - Linux - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install ninja-build - ninja --version - cmake --version - - name: Install dependencies - macOS - if: runner.os == 'macOS' - run: | - brew install ninja - ninja --version - cmake --version - - name: Install dependencies - Windows - if: runner.os == 'Windows' + - name: Test run: | - choco install ninja - ninja --version - cmake --version - - - name: Use new Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - architecture: x64 + make test - name: Fetch Python dependencies run: | pip install -r tests/requirements.txt - - uses: suisei-cn/actions-download-file@v1.4.0 - name: Download Toit - with: - url: ${{ env.TOIT_URL }} - target: ${{ env.DOWNLOAD_DIR }} - - - name: Extract Toit - shell: bash - run: | - cd "$DOWNLOAD_DIR" - tar x -f *.tar.gz - - - name: Run cmake - shell: bash - run: | - make rebuild-cmake - cmake "-DTOIT_EXEC=$TOIT_EXEC" "-DTPKG_EXEC=$TPKG_EXEC" build - - - name: Install packages - run: | - make install-pkgs - - name: Test run: | make test diff --git a/Makefile b/Makefile index 903f99c..e7a7cd1 100644 --- a/Makefile +++ b/Makefile @@ -9,10 +9,10 @@ build/CMakeCache.txt: $(MAKE) rebuild-cmake install-pkgs: rebuild-cmake - (cd build && ninja install-pkgs) + cmake --build build --target install-pkgs test: install-pkgs rebuild-cmake - (cd build && ninja check) + cmake --build build --target check # We rebuild the cmake file all the time. # We use "glob" in the cmakefile, and wouldn't otherwise notice if a new @@ -20,6 +20,8 @@ test: install-pkgs rebuild-cmake # It takes <1s on Linux to run cmake, so it doesn't hurt to run it frequently. rebuild-cmake: mkdir -p build - (cd build && cmake .. -G Ninja) + # We need to set a build type, otherwise cmake won't run nicely on Windows. + # The build-type is otherwise unused. + cmake -B build -DCMAKE_BUILD_TYPE=Debug .PHONY: all test rebuild-cmake install-pkgs diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ffb4c6c..c0f846e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,8 +5,8 @@ # We use the suffix "test_no_external" to avoid running the test in the opentoit repository. file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*_test.toit" "*_test_no_external.toit") -set(TOIT_EXEC "toit.run" CACHE FILEPATH "The executable used to run the tests") -set(TPKG_EXEC "toit.pkg" CACHE FILEPATH "The executable used to install the packages") +set(TOIT_EXEC "toit.run${CMAKE_EXECUTABLE_SUFFIX}" CACHE FILEPATH "The executable used to run the tests") +set(TPKG_EXEC "toit.pkg${CMAKE_EXECUTABLE_SUFFIX}" CACHE FILEPATH "The executable used to install the packages") set(TEST_TIMEOUT 40 CACHE STRING "The maximal amount of time each test is allowed to run") message("TPKG: ${TPKG_EXEC}") @@ -21,7 +21,7 @@ ProcessorCount(NUM_CPU) add_custom_target( check - COMMAND ${CMAKE_CTEST_COMMAND} -j${NUM_CPU} -T test --output-on-failure + COMMAND "${CMAKE_CTEST_COMMAND}" -j${NUM_CPU} --output-on-failure -C Debug USES_TERMINAL ) From abd52a8f68847192981b590bcc273550cc25b2cb Mon Sep 17 00:00:00 2001 From: Florian Loitsch Date: Thu, 14 Mar 2024 14:13:16 +0100 Subject: [PATCH 2/4] Set Python. --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 910af48..28a001f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,12 @@ jobs: run: | make test + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + architecture: x64 + - name: Fetch Python dependencies run: | pip install -r tests/requirements.txt From e68847a3cd8123803df89a7968dfc79703b0b007 Mon Sep 17 00:00:00 2001 From: Florian Loitsch Date: Thu, 14 Mar 2024 14:14:37 +0100 Subject: [PATCH 3/4] Fix spurious make test. --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28a001f..ba943cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,10 +31,6 @@ jobs: with: toit-version: ${{ matrix.toit-version }} - - name: Test - run: | - make test - - name: Setup Python uses: actions/setup-python@v4 with: From 5b59758eb556546dcc91cc225e7cbfccf24b9b99 Mon Sep 17 00:00:00 2001 From: Florian Loitsch Date: Thu, 14 Mar 2024 14:15:50 +0100 Subject: [PATCH 4/4] NONE. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27403a6..87671a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.23) -project(modbus) +project(modbus NONE) enable_testing() add_subdirectory(tests)