diff --git a/.github/workflows/adding_tests.yml b/.github/workflows/adding_tests.yml new file mode 100644 index 0000000..2fece0f --- /dev/null +++ b/.github/workflows/adding_tests.yml @@ -0,0 +1,54 @@ +--- +name: "Linting and Tests" +on: + - push + - workflow_dispatch + +jobs: + linting: + runs-on: "ubuntu-24.04" + + steps: + # Checkout this repository + - uses: actions/checkout@v4 + + # Setup the specified Python version + - name: "Set up Python 3.12" + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r ./requirements.txt + + - name: Linting (pylama) + run: pylama . + + - name: Linting (black) + run: black --check . + + pytest: + needs: linting + runs-on: "ubuntu-24.04" + + steps: + # Checkout this repository + - uses: actions/checkout@v4 + + # Setup the specified Python version + - name: "Set up Python 3.12" + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r ./requirements.txt + + - name: Execute Tests + run: py.test -s -v tests/ diff --git a/requirements.txt b/requirements.txt index 02cdb0c..4015fe7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ setuptools rich==13.7.0 pylama==8.4.1 black==24.4.2 +pytest==8.2.2 diff --git a/tests/test_simple.py b/tests/test_simple.py new file mode 100644 index 0000000..0ef73a4 --- /dev/null +++ b/tests/test_simple.py @@ -0,0 +1,11 @@ +import os + + +def test_gh_actions(): + running_in_gh = os.getenv("GITHUB_ACTIONS") + assert running_in_gh + + +def test_env_var(): + my_env = os.getenv("ENVIRONMENT", "local") + assert my_env == "gh_actions"