Skip to content

Commit fe428c0

Browse files
committed
Merge branch 'main' into thumper/feat/tf-runner-env
2 parents c0416a7 + a6edd7d commit fe428c0

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
Lint:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v2
18-
- uses: actions/setup-python@v4
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
1919
with:
2020
python-version: "3.10"
2121
- name: Linting
@@ -28,23 +28,27 @@ jobs:
2828
runs-on: ubuntu-latest
2929
strategy:
3030
matrix:
31-
python-version: [3.9, "3.10", "3.11", "3.12"]
31+
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]
3232
steps:
3333
- name: Checkout
34-
uses: actions/checkout@v3
34+
uses: actions/checkout@v4
3535

3636
- name: Install poetry
3737
run: pipx install poetry
3838

3939
- name: Set up Python ${{ matrix.python-version }}
40-
uses: actions/setup-python@v4
40+
uses: actions/setup-python@v5
4141
with:
4242
python-version: "${{ matrix.python-version }}"
4343
cache: "poetry"
4444

4545
- name: Install dependencies
4646
run: poetry install
4747

48+
- uses: hashicorp/setup-terraform@v3
49+
with:
50+
terraform_version: "1.10.1"
51+
4852
- name: Coverage run pytest
4953
run: poetry run coverage run --source pytest_terraform -m pytest tests
5054

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout
14-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1515

1616
- name: Install poetry
1717
run: pipx install poetry
1818

1919
- name: Set up Python
20-
uses: actions/setup-python@v4
20+
uses: actions/setup-python@v5
2121
with:
2222
python-version: "3.10"
2323
cache: "poetry"

pytest_terraform/tf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ def __init__(
6464

6565
def apply(self, plan=True):
6666
"""run terraform apply"""
67-
if plan is True:
67+
if plan:
6868
plan_path = os.path.join(self.work_dir, "tfplan")
6969
self.plan(plan_path)
7070
apply_args = self._get_cmd_args("apply", plan=plan_path)
71-
elif plan:
71+
else:
7272
apply_args = self._get_cmd_args("apply", plan="")
7373
try:
7474
self._run_cmd(apply_args)

tests/test_terraform.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ def write_file(content: str, filename="resources.tf"):
171171
yield write_file
172172

173173

174-
def test_tf_runner(tmpdir, tmpdir_writer, trunner):
174+
@pytest.mark.skipif(not shutil.which("terraform"), reason="Terraform binary missing")
175+
@pytest.mark.parametrize("plan", (True, False))
176+
def test_tf_runner(testdir, tmpdir, plan):
175177
# ** requires network access to install plugin **
176178
tmpdir_writer(
177179
"""
@@ -183,7 +185,7 @@ def test_tf_runner(tmpdir, tmpdir_writer, trunner):
183185
)
184186

185187
trunner.init()
186-
state = trunner.apply()
188+
state = trunner.apply(plan=plan)
187189
assert state.get("foo")["content"] == "foo!"
188190
with open(tmpdir.join("foo.bar")) as fh:
189191
assert fh.read() == "foo!"

0 commit comments

Comments
 (0)