Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/scripts/test-matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os
import json

TEST_DIR = "bin/icp-cli/tests"

MACOS_TESTS = ["hello_tests"]

def test_names():
all_files = os.listdir(TEST_DIR)
rust_files = filter(lambda f: f.endswith(".rs"), all_files)
return [f"{filename[:-3]}" for filename in rust_files]

include = []
for test in test_names():
# Ubuntu: run everything
include.append({
"test": test,
"os": "ubuntu-22.04"
})

# macOS: only run selected tests
if test in MACOS_TESTS:
include.append({
"test": test,
"os": "macos-13"
})


matrix = {
"include": include,
}

print(json.dumps(matrix))
15 changes: 11 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ on:
pull_request:

jobs:
discover:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: echo "matrix=$(python3 .github/scripts/test-matrix.py)" >> $GITHUB_OUTPUT

test:
name: ${{ matrix.test }} on ${{ matrix.os }}
needs: discover
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
test:
- hello_tests
matrix: ${{fromJson(needs.discover.outputs.matrix)}}

steps:
- uses: actions/checkout@v4
Expand Down