-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add tests and publish actions #5
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
TOIT_VERSION: v2.0.0-alpha.121 | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest, windows-latest, macos-latest ] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Setup Toit | ||
id: setup-toit | ||
uses: toitlang/action-setup@v1 | ||
with: | ||
toit-version: ${{ env.TOIT_VERSION }} | ||
|
||
# Fetch the dependencies. Different for each platform. | ||
- name: Install dependencies - Linux | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt-get update | ||
cmake --version | ||
- name: Install dependencies - macOS | ||
if: runner.os == 'macOS' | ||
run: | | ||
cmake --version | ||
- name: Install dependencies - Windows | ||
if: runner.os == 'Windows' | ||
run: | | ||
cmake --version | ||
|
||
- name: Run cmake | ||
shell: bash | ||
run: | | ||
make rebuild-cmake | ||
cmake build | ||
|
||
- name: Install packages | ||
run: | | ||
make install-pkgs | ||
|
||
- name: Test | ||
run: | | ||
make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Zero-Clause BSD License | ||
|
||
# Copyright (C) 2023 Toitware ApS. | ||
|
||
# Permission to use, copy, modify, and/or distribute this software for any | ||
# purpose with or without fee is hereby granted. | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
# PERFORMANCE OF THIS SOFTWARE. | ||
|
||
name: Publish package | ||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
- 'v[0-9]+.[0-9]+.[0-9]+-*' | ||
jobs: | ||
create-release: | ||
name: Create new release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Publish | ||
uses: toitlang/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | ||
# for details. All rights reserved. Use of this source code is governed by a | ||
# BSD-style license that can be found in the LICENSE file. | ||
|
||
cmake_minimum_required(VERSION 3.22) | ||
|
||
# NONE means skip testing the C compiler. | ||
project(case NONE) | ||
|
||
enable_testing() | ||
add_subdirectory(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | ||
# for details. All rights reserved. Use of this source code is governed by a | ||
# BSD-style license that can be found in the LICENSE file. | ||
|
||
.PHONY: all | ||
all: test | ||
|
||
.PHONY: install-pkgs | ||
install-pkgs: rebuild-cmake | ||
cmake --build build --target install-pkgs | ||
|
||
.PHONY: test | ||
test: install-pkgs rebuild-cmake | ||
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. | ||
.PHONY: rebuild-cmake | ||
rebuild-cmake: | ||
mkdir -p build | ||
cmake -B build -DCMAKE_BUILD_TYPE=Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | ||
# for details. All rights reserved. Use of this source code is governed by a | ||
# BSD-style license that can be found in the LICENSE file. | ||
|
||
file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*-test.toit") | ||
|
||
set(TOITRUN toit.run${CMAKE_EXECUTABLE_SUFFIX} CACHE FILEPATH "The executable used to run the tests") | ||
set(TOITPKG 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(SLOW_TEST_TIMEOUT 200 CACHE STRING "The maximal amount of time each slow test is allowed to run") | ||
|
||
message("TPKG: ${TOITPKG}") | ||
add_custom_target( | ||
"install-pkgs" | ||
COMMAND "${TOITPKG}" install | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
include(ProcessorCount) | ||
ProcessorCount(NUM_CPU) | ||
|
||
add_custom_target( | ||
check | ||
COMMAND ${CMAKE_CTEST_COMMAND} -j${NUM_CPU} --output-on-failure -C Release | ||
USES_TERMINAL | ||
) | ||
|
||
set(TEST_PREFIX "") | ||
include(fail.cmake OPTIONAL) | ||
|
||
message("Failing tests: ${FAILING_TESTS}") | ||
message("Skipped tests: ${SKIP_TESTS}") | ||
|
||
foreach(file ${TESTS}) | ||
set(test_name "/tests/${file}") | ||
if("${test_name}" IN_LIST SKIP_TESTS) | ||
continue() | ||
endif() | ||
|
||
add_test( | ||
NAME "${test_name}" | ||
COMMAND ${TOITRUN} "tests/${file}" | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.. | ||
) | ||
|
||
if ("${file}" MATCHES "slow.toit") | ||
set_tests_properties(${test_name} PROPERTIES TIMEOUT ${SLOW_TEST_TIMEOUT}) | ||
else() | ||
set_tests_properties(${test_name} PROPERTIES TIMEOUT ${TEST_TIMEOUT}) | ||
endif() | ||
|
||
if("${test_name}" IN_LIST FAILING_TESTS) | ||
set_tests_properties("${test_name}" PROPERTIES WILL_FAIL TRUE) | ||
endif() | ||
endforeach() |
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See pkg-fs for how to write this without ninja.