Skip to content

Commit

Permalink
More CI (rust-diplomat#570)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian authored Jul 19, 2024
1 parent 75ca4bb commit 22b65e1
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 37 deletions.
66 changes: 56 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,36 @@ jobs:
- name: Test C
run: cargo make test-c

check-c:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Install cargo-make
uses: taiki-e/install-action@cargo-make

- name: clang, c11
run: cargo make check-c
env:
CC: clang
C_STD: c11

- name: gcc, c11
run: cargo make check-c
env:
CC: gcc
C_STD: c11

- name: gcc, c2x
run: cargo make check-c
env:
CC: gcc
C_STD: c2x

test-cpp:
runs-on: ubuntu-latest
Expand All @@ -68,27 +98,43 @@ jobs:
- name: Install cargo-make
uses: taiki-e/install-action@cargo-make

- name: Test C++ (clang)
- name: clang
run: CXX=clang++-14 cargo make test-cpp

- name: Test C++ (gcc)
- name: gcc
run: CXX=g++ cargo make test-cpp
test-cpp-self-contained:
runs-on: ubuntu-latest

check-cpp:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Install cargo-make
uses: taiki-e/install-action@cargo-make

- name: Test C++ self-contained (clang)
run: CXX=clang++-14 cargo make test-cpp-self-contained
- name: clang++, c++17
run: cargo make check-cpp
env:
CC: clang++-14
C_STD: c++17

- name: clang++, c++20
run: cargo make check-cpp
env:
CC: clang++-14
C_STD: c++20

- name: Test C++ self-contained (clang, c++20)
run: CXX=clang++-14 CXX_STD=c++20 cargo make test-cpp-self-contained
- name: g++, c++23
run: cargo make check-cpp
env:
CC: g++
C_STD: c++23

- name: Test C++ self-contained (g++, c++23)
run: CXX=g++ CXX_STD=c++23 cargo make test-cpp-self-contained
test-js:
runs-on: ubuntu-latest
strategy:
Expand Down
70 changes: 43 additions & 27 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[config]
default_to_workspace = false



# If adding a new backend, be sure to update:
# - test-native (if necessary)
# - test-example
Expand All @@ -21,6 +19,7 @@ dependencies = [
"test-cpp",
"test-c",
]

[tasks.gen]
category = "Code generation"
dependencies = [
Expand All @@ -47,8 +46,6 @@ dependencies = [
category = "Tests"
dependencies = [
"test-c-example",
"test-c-example-self-contained",
"test-c-feature-self-contained",
]

[tasks.test-js]
Expand All @@ -63,12 +60,14 @@ dependencies = [
"test-dart-example",
"test-dart-feature",
]

[tasks.test-kotlin]
category = "Tests"
dependencies = [
"test-kotlin-example",
"test-kotlin-feature",
]

[tasks.test-example]
category = "Tests"
dependencies = [
Expand All @@ -87,8 +86,6 @@ dependencies = [
"test-kotlin-feature",
]



[tasks.test-cpp-example]
category = "Tests"
dependencies = ["build-example"]
Expand All @@ -100,8 +97,6 @@ rm tests/*.out
exec --fail-on-error make
'''



[tasks.test-cpp-feature]
category = "Tests"
dependencies = ["build-feature"]
Expand All @@ -113,8 +108,6 @@ rm tests/*.out
exec --fail-on-error make
'''



[tasks.test-c-example]
category = "Tests"
dependencies = ["build-example"]
Expand All @@ -126,8 +119,6 @@ rm *.out
exec --fail-on-error make
'''



[tasks.test-js-feature]
category = "Tests"
dependencies = ["build-feature-wasm"]
Expand Down Expand Up @@ -182,33 +173,58 @@ cd feature_tests/kotlin/somelib
exec --fail-on-error gradle test --warning-mode all
'''

[tasks.test-c-example-self-contained]
[tasks.check-c-example]
category = "Tests"
dependencies = ["build-example"]
script_runner = "@duckscript"
script = '''
exit_on_error true
cc = get_env CC
if is_empty ${cc}
cc = set "gcc"
end
c_std = get_env C_STD
if is_empty ${c_std}
c_std = set "c11"
end
cd example/c/include
files_list = glob_array "./*.h"
for file in ${files_list}
exec --fail-on-error gcc ${file}
echo "Checking ${file}"
exec --fail-on-error ${cc} -std=${c_std} ${file}
end
'''

[tasks.test-c-feature-self-contained]
[tasks.check-c-feature]
category = "Tests"
dependencies = ["build-example"]
script_runner = "@duckscript"
script = '''
exit_on_error true
cc = get_env CC
if is_empty ${cc}
cc = set "gcc"
end
c_std = get_env C_STD
if is_empty ${c_std}
c_std = set "c11"
end
cd feature_tests/c/include
files_list = glob_array "./*.h"
for file in ${files_list}
exec --fail-on-error gcc ${file}
echo "Checking ${file}"
exec --fail-on-error ${cc} -std=${c_std} ${file}
end
'''

[tasks.test-cpp-example-self-contained]
[tasks.check-c]
category = "Tests"
dependencies = [
"check-c-feature",
"check-c-example",
]

[tasks.check-cpp-example]
category = "Tests"
script_runner = "@duckscript"
script = '''
Expand All @@ -225,12 +241,12 @@ end
cd example/cpp/include
files_list = glob_array "./*.hpp"
for file in ${files_list}
echo "Testing self-containedness of ${file}"
exec --fail-on-error ${cxx} -std=${cxx_std} ${file}
echo "Checking ${file}"
exec --fail-on-error ${cxx} -std=${cxx_std} ${file}
end
'''

[tasks.test-cpp-feature-self-contained]
[tasks.check-cpp-feature]
category = "Tests"
script_runner = "@duckscript"
script = '''
Expand All @@ -247,17 +263,17 @@ end
cd feature_tests/cpp/include
files_list = glob_array "./*.hpp"
for file in ${files_list}
echo "Testing self-containedness of ${file}"
exec --fail-on-error ${cxx} -std=${cxx_std} ${file}
echo "Checking ${file}"
exec --fail-on-error ${cxx} -std=${cxx_std} ${file}
end
'''

[tasks.test-cpp-self-contained]
[tasks.check-cpp]
category = "Tests"
dependencies = [
"test-cpp-feature-self-contained",
"test-cpp-example-self-contained",
"check-cpp-feature",
"check-cpp-example",
]


Expand Down

0 comments on commit 22b65e1

Please sign in to comment.