Skip to content

Commit

Permalink
Merge branch 'main' into floitsch/update
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch committed Jan 2, 2025
2 parents 9237e4a + a1e95ff commit cd91517
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 76 deletions.
71 changes: 2 additions & 69 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ on:

env:
TOIT_VERSION: v2.0.0-alpha.100
# Will be set in the 'Setup constants' step
TOIT_URL:
# Will be set in the 'Setup constants' step
DOWNLOAD_DIR:

jobs:
build:
Expand All @@ -23,72 +19,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup constants
shell: bash
run: |
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
echo "TOIT_URL=https://github.com/toitlang/toit/releases/download/$TOIT_VERSION/$TOIT_FILE" >> $GITHUB_ENV
# 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'
run: |
choco install ninja
ninja --version
cmake --version
- uses: suisei-cn/actions-download-file@v1
name: Download Toit
- uses: toitlang/action-setup@v1
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
toit-version: ${{ env.TOIT_VERSION }}

- name: Test
run: |
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

cmake_minimum_required(VERSION 3.23)

project(certificate_roots)
project(certificate_roots NONE)

enable_testing()
add_subdirectory(tests)
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ 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
# file (for example a test) was added or removed.
# 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)
cmake -B build

.PHONY: all test rebuild-cmake install-pkgs
6 changes: 3 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*_test.toit" "*-test.toit" "*_test_slow.toit" "*-test-slow.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")
set(TEST_TIMEOUT_SLOW 200 CACHE STRING "The maximal amount of time each test is allowed to run")

Expand All @@ -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} -T test --output-on-failure -C Debug
USES_TERMINAL
)

Expand Down

0 comments on commit cd91517

Please sign in to comment.