-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(actions): Test all feature combinations on CI
- Loading branch information
Showing
2 changed files
with
49 additions
and
3 deletions.
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,34 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2024 Jan Holthuis <[email protected]> | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of | ||
# the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
import argparse | ||
import tomllib | ||
import json | ||
import itertools | ||
|
||
|
||
def generate_matrix(features: list[str]): | ||
for i in range(len(features) + 1): | ||
yield from itertools.combinations(iter(features), i) | ||
|
||
|
||
def main(argv=None): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("cargo_file", type=argparse.FileType("rb")) | ||
parser.add_argument("output_file", type=argparse.FileType("w")) | ||
args = parser.parse_args(argv) | ||
|
||
cargo_toml = tomllib.load(args.cargo_file) | ||
features = [feature for feature in cargo_toml["features"].keys() if feature != "default"] | ||
matrix = {"include": [{"features": "{}".format(",".join(f))} for f in generate_matrix(features=features)]} | ||
|
||
args.output_file.write("matrix={}".format(json.dumps(matrix))) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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