Skip to content

Commit

Permalink
Run ci tests with multiple sets of extra dependencies.
Browse files Browse the repository at this point in the history
This adds a matrix that runs the tests once with `packaging`, `yaml` and both.

* .github/workflows/ci.yml

* tests/test_req2flatpak.py : Skip yaml tests when pyyaml isn't installed.
  • Loading branch information
real-yfprojects committed Feb 28, 2023
1 parent e5ab62f commit b3ad629
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:

test:
runs-on: ubuntu-latest
strategy:
matrix:
extras: ["packaging", "yaml", "packaging yaml"]
steps:
- name: Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
Expand All @@ -33,7 +36,7 @@ jobs:
id: setup
uses: ./.github/actions/setup
with:
install-options: --without lint
install-options: --without lint --extras ${{matrix.extras}}

- name: Run Tests
run: make test
Expand Down
8 changes: 7 additions & 1 deletion tests/test_req2flatpak.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
from itertools import product
from pathlib import Path
from typing import List
from unittest import skipUnless
from unittest.mock import patch

import yaml
try:
import yaml
except ImportError:
yaml = None # type: ignore

from req2flatpak import (
DownloadChooser,
Expand Down Expand Up @@ -97,6 +101,7 @@ def test_cli_with_reqs_as_args(self):
build_module = json.loads(result.stdout)
self.validate_build_module(build_module)

@skipUnless(yaml, "The yaml extra dependency is needed for this feature.")
def test_cli_with_reqs_as_args_yaml(self):
"""Runs req2flatpak in yaml mode by passing requirements as cmdline arg."""
args = ["--requirements"] + self.requirements
Expand All @@ -118,6 +123,7 @@ def test_cli_with_reqs_as_file(self):
build_module = json.loads(result.stdout)
self.validate_build_module(build_module)

@skipUnless(yaml, "The yaml extra dependency is needed for this feature.")
def test_cli_with_reqs_as_file_yaml(self):
"""Runs req2flatpak by passing requirements as requirements.txt file."""
with tempfile.NamedTemporaryFile(mode="w+", encoding="utf-8") as req_file:
Expand Down

0 comments on commit b3ad629

Please sign in to comment.