Skip to content

Commit

Permalink
test(fix): we were accidentally making temp directories in the projec…
Browse files Browse the repository at this point in the history
…t instead of in /tmp
  • Loading branch information
Ned Batchelder committed Jul 26, 2023
1 parent 170c895 commit 18f04e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ edx_repo_tools.egg-info
.idea/

build/

fake_repo*
17 changes: 7 additions & 10 deletions tests/test_gha_release_workflow_modernizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Tests for Github Actions Modernizer Script
Tests for GitHub Actions Modernizer Script
"""
import shutil
import uuid
Expand All @@ -14,9 +14,8 @@
def setup_local_dir(dirpath, tmpdir):
current_directory = dirname(__file__)
local_dir = join(current_directory, dirpath)
fake_repo_path = 'fake_repo' + str(uuid.uuid4())
tmpdir.mkdir(fake_repo_path)
shutil.copytree(local_dir, fake_repo_path)
fake_repo_path = tmpdir.mkdir(f"fake_repo_{uuid.uuid4()}")
shutil.copytree(local_dir, fake_repo_path, dirs_exist_ok=True)
return fake_repo_path

def get_updated_yaml_elements(file_path):
Expand All @@ -34,14 +33,13 @@ def test_add_node_env_step(tmpdir):
for step in ci_elements['jobs']['release']['steps']:
if 'name' in step and step['name'] == 'Setup Nodejs Env':
node_env_step = step
assert node_env_step['run'] == 'echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV'
assert node_env_step['run'] == 'echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV'


def test_node_version_value(tmpdir):
fake_repo_without_nvmrc_path = setup_local_dir('fake_repos/repo_without_nvmrc/',tmpdir)
test_file = join(fake_repo_without_nvmrc_path, ".github/workflows/release.yml")
ci_elements_without_rc_file_present = get_updated_yaml_elements(
test_file)
ci_elements_without_rc_file_present = get_updated_yaml_elements(test_file)

node_setup_step = None
for step in ci_elements_without_rc_file_present['jobs']['release']['steps']:
Expand All @@ -52,9 +50,8 @@ def test_node_version_value(tmpdir):

fake_repo_with_nvmrc_path = setup_local_dir('fake_repos/repo_with_nvmrc/',tmpdir)
test_file = join(fake_repo_with_nvmrc_path, ".github/workflows/release.yml")
ci_elements_with_rc_file_present = get_updated_yaml_elements(
test_file)

ci_elements_with_rc_file_present = get_updated_yaml_elements(test_file)

node_setup_step = None
for step in ci_elements_with_rc_file_present['jobs']['release']['steps']:
if 'uses' in step and step['uses'] in NODE_JS_SETUP_ACTION_LIST:
Expand Down

0 comments on commit 18f04e7

Please sign in to comment.