Skip to content

Commit

Permalink
restore IT
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeWang1127 committed Oct 1, 2024
1 parent 322a703 commit 42b5774
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/verify_library_generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,40 @@ jobs:
head_repo_url: ${{ github.event.pull_request.head.repo.html_url }}
head_repo_name: ${{ github.event.pull_request.head.repo.full_name }}
base_repo: ${{ github.repository }}
library-generation-integration-tests:
runs-on: ubuntu-22.04
needs: should-run-library-generation-tests
if: needs.should-run-library-generation-tests.outputs.should_run == 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: install pyenv
shell: bash
run: |
set -ex
curl https://pyenv.run | bash
# setup environment
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
echo "PYENV_ROOT=${PYENV_ROOT}" >> $GITHUB_ENV
echo "PATH=${PATH}" >> $GITHUB_ENV
set +ex
- name: install python dependencies
shell: bash
run: |
set -ex
pushd library_generation
pip install --require-hashes -r requirements.txt
pip install .
popd
- name: Run integration tests
shell: bash
run: |
set -x
python -m unittest library_generation/test/integration_tests.py
library-generation-unit-tests:
runs-on: ubuntu-22.04
needs: should-run-library-generation-tests
Expand Down
2 changes: 0 additions & 2 deletions library_generation/cli/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ def __generate_repo_and_pr_description_impl(
current_generation_config_path = os.path.abspath(current_generation_config_path)
repository_path = os.path.abspath(repository_path)
api_definitions_path = os.path.abspath(api_definitions_path)
print(f"baseline: {os.listdir(current_generation_config_path)}")
print(f"api-definition: {os.listdir(api_definitions_path)}")
if not baseline_generation_config_path:
# Execute full generation based on current_generation_config if
# baseline_generation_config is not specified.
Expand Down
3 changes: 0 additions & 3 deletions library_generation/generate_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ def generate_from_yaml(
gen_config=config, library_config=target_libraries, repo_path=repository_path
)
# copy api definition to output folder.
print(os.listdir(api_definitions_path))
print(f"Copy from {api_definitions_path} to {repo_config.output_folder}")
shutil.copytree(api_definitions_path, repo_config.output_folder, dirs_exist_ok=True)
print(os.listdir(repo_config.output_folder))

for library_path, library in repo_config.get_libraries().items():
print(f"generating library {library.get_library_name()}")
Expand Down
13 changes: 13 additions & 0 deletions library_generation/test/integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
golden_dir = os.path.join(config_dir, "golden")
generator_jar_coordinates_file = os.path.join(config_dir, "test_generator_coordinates")
repo_root_dir = os.path.join(script_dir, "..", "..")
build_file = os.path.join(
repo_root_dir, ".cloudbuild", "library_generation", "library_generation.Dockerfile"
)
image_tag = "test-image:latest"
repo_prefix = "https://github.com/googleapis"
output_dir = shell_call("get_output_folder")
Expand All @@ -61,6 +64,7 @@ class IntegrationTest(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
cls.__download_generator_jar(coordinates_file=generator_jar_coordinates_file)
cls.__build_image(docker_file=build_file, cwd=repo_root_dir)

@classmethod
def setUp(cls) -> None:
Expand Down Expand Up @@ -202,6 +206,15 @@ def __copy_api_definition(cls, committish: str) -> str:
rmtree(repo_dest)
return api_temp_dir

@classmethod
def __build_image(cls, docker_file: str, cwd: str):
# we build the docker image without removing intermediate containers, so
# we can re-test more quickly
subprocess.check_call(
["docker", "build", "-f", docker_file, "-t", image_tag, "."],
cwd=cwd,
)

@classmethod
def __download_generator_jar(cls, coordinates_file: str) -> None:
"""
Expand Down

0 comments on commit 42b5774

Please sign in to comment.