Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Move release note generation to a sub module #3299

Merged
merged 73 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
0cb1ee4
feat: separate pr description generation from entrypoint
JoeWang1127 Oct 17, 2024
7b9e493
add unit test
JoeWang1127 Oct 17, 2024
f74d1c5
fix unit test
JoeWang1127 Oct 17, 2024
99eb34a
fix integration test
JoeWang1127 Oct 17, 2024
c87d6fb
fix integration test
JoeWang1127 Oct 17, 2024
c5dfb84
change shell script
JoeWang1127 Oct 17, 2024
758f0bc
change entrypoint
JoeWang1127 Oct 17, 2024
8fa281e
add env
JoeWang1127 Oct 17, 2024
8ae1360
change doc
JoeWang1127 Oct 17, 2024
19de9cd
change ci
JoeWang1127 Oct 17, 2024
ff85b71
change ci
JoeWang1127 Oct 17, 2024
72b3acb
create separate packages
JoeWang1127 Oct 18, 2024
3c7e8f0
setup common project
JoeWang1127 Oct 18, 2024
82c1642
fix package
JoeWang1127 Oct 18, 2024
54baaf9
add gapic_inputs.py to common
JoeWang1127 Oct 18, 2024
40c12af
remove library_generation dir
JoeWang1127 Oct 18, 2024
1e2473b
add library_generation module
JoeWang1127 Oct 18, 2024
5578047
add release_note_generation module
JoeWang1127 Oct 18, 2024
deadfb5
add init
JoeWang1127 Oct 18, 2024
fcebe5c
lint
JoeWang1127 Oct 18, 2024
0b400e9
change ci
JoeWang1127 Oct 18, 2024
b323412
change integration in ci
JoeWang1127 Oct 18, 2024
104de86
change dockerfile
JoeWang1127 Oct 18, 2024
1dff8b5
setup venv
JoeWang1127 Oct 18, 2024
78d22e1
change dir
JoeWang1127 Oct 18, 2024
d4d01b1
change dir
JoeWang1127 Oct 18, 2024
8293867
remove venv
JoeWang1127 Oct 18, 2024
6a12b86
add black
JoeWang1127 Oct 18, 2024
c58eb24
change it in ci
JoeWang1127 Oct 18, 2024
80f8a29
remove release note gen in integration test
JoeWang1127 Oct 18, 2024
cec724c
remove deprecated pkg in it
JoeWang1127 Oct 18, 2024
8c1e5b2
change dir in it
JoeWang1127 Oct 18, 2024
2afcd90
lint
JoeWang1127 Oct 18, 2024
b6273fe
Merge branch 'main' into feat/separate-pr-des-gen
JoeWang1127 Oct 18, 2024
bfb69d7
fix dir in dockerfile
JoeWang1127 Oct 18, 2024
6834fbc
change dir
JoeWang1127 Oct 18, 2024
7042b87
fix copyfile
JoeWang1127 Oct 18, 2024
06ebe0b
fix copytree
JoeWang1127 Oct 18, 2024
f576c1a
fix path in script
JoeWang1127 Oct 18, 2024
de6b870
remove pr description comp in it
JoeWang1127 Oct 18, 2024
3c03477
lint
JoeWang1127 Oct 18, 2024
3b132ce
fix showcase
JoeWang1127 Oct 18, 2024
b9c5374
fix showcase
JoeWang1127 Oct 18, 2024
d35b9aa
setup python in composite action
JoeWang1127 Oct 21, 2024
123b406
install deps
JoeWang1127 Oct 21, 2024
04f4101
change path
JoeWang1127 Oct 21, 2024
54d5116
copy and install
JoeWang1127 Oct 21, 2024
26436a7
reduce log
JoeWang1127 Oct 21, 2024
5a5465f
debug
JoeWang1127 Oct 21, 2024
8458e3b
debug
JoeWang1127 Oct 21, 2024
4d321dc
debug
JoeWang1127 Oct 21, 2024
8f3865e
debug
JoeWang1127 Oct 21, 2024
49f6cf3
debug
JoeWang1127 Oct 21, 2024
aceba84
debug
JoeWang1127 Oct 21, 2024
4b98eec
debug
JoeWang1127 Oct 21, 2024
71bd361
remove debug
JoeWang1127 Oct 21, 2024
ec17d84
install library_generation
JoeWang1127 Oct 21, 2024
180803a
change cmd
JoeWang1127 Oct 21, 2024
e458552
remove unused test resources
JoeWang1127 Oct 21, 2024
66e3812
remove unused test resources
JoeWang1127 Oct 21, 2024
af986fb
change doc
JoeWang1127 Oct 21, 2024
91f7096
Merge branch 'main' into feat/separate-pr-des-gen
JoeWang1127 Oct 22, 2024
1c9a9a7
create requirements.in for each module
JoeWang1127 Oct 22, 2024
394733f
lint
JoeWang1127 Oct 22, 2024
3cbe316
change dockerfile
JoeWang1127 Oct 22, 2024
f7559dc
change dockerfile
JoeWang1127 Oct 22, 2024
93ffa8a
change dockerfile
JoeWang1127 Oct 22, 2024
939d8b1
Merge branch 'main' into feat/separate-pr-des-gen
JoeWang1127 Oct 22, 2024
2925d89
Merge branch 'main' into feat/separate-pr-des-gen
JoeWang1127 Oct 22, 2024
d8d1e8e
change doc
JoeWang1127 Oct 22, 2024
208f51f
do not update pip in action
JoeWang1127 Oct 22, 2024
a4beff9
change comment
JoeWang1127 Oct 23, 2024
80623c0
update requirements.txt
JoeWang1127 Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions .cloudbuild/library_generation/library_generation.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,20 @@ RUN apt-get update && apt-get install -y \
&& apt-get clean

# copy source code
COPY library_generation /src
COPY hermetic_build/common /src/common
COPY hermetic_build/library_generation /src/library_generation

# install protoc
WORKDIR /protoc
RUN source /src/utils/utilities.sh \
RUN source /src/library_generation/utils/utilities.sh \
&& download_protoc "${PROTOC_VERSION}" "${OS_ARCHITECTURE}"
# we indicate protoc is available in the container via env vars
ENV DOCKER_PROTOC_LOCATION=/protoc
ENV DOCKER_PROTOC_VERSION="${PROTOC_VERSION}"

# install grpc
WORKDIR /grpc
RUN source /src/utils/utilities.sh \
RUN source /src/library_generation/utils/utilities.sh \
&& download_grpc_plugin "${GRPC_VERSION}" "${OS_ARCHITECTURE}"
# similar to protoc, we indicate grpc is available in the container via env vars
ENV DOCKER_GRPC_LOCATION="/grpc/protoc-gen-grpc-java-${GRPC_VERSION}-${OS_ARCHITECTURE}.exe"
Expand All @@ -71,16 +72,16 @@ ENV DOCKER_GRPC_VERSION="${GRPC_VERSION}"
COPY --from=ggj-build "/sdk-platform-java/gapic-generator-java.jar" "${HOME}/.library_generation/gapic-generator-java.jar"
RUN chmod 755 "${HOME}/.library_generation/gapic-generator-java.jar"

# use python 3.11 (the base image has several python versions; here we define the default one)
# use python 3.12 (the base image has several python versions; here we define the default one)
RUN rm $(which python3)
RUN ln -s $(which python3.11) /usr/local/bin/python
RUN ln -s $(which python3.11) /usr/local/bin/python3
RUN ln -s $(which python3.12) /usr/local/bin/python
RUN ln -s $(which python3.12) /usr/local/bin/python3
RUN python -m pip install --upgrade pip

# install main scripts as a python package
WORKDIR /src
RUN python -m pip install -r requirements.txt
RUN python -m pip install .
WORKDIR /
RUN python -m pip install src/common
RUN python -m pip install src/library_generation

# Install nvm with node and npm
ENV NODE_VERSION 20.12.0
Expand Down Expand Up @@ -120,4 +121,4 @@ RUN chmod -R a+rw /home
RUN chmod -R a+rx /home/.nvm

WORKDIR /workspace
ENTRYPOINT [ "python", "/src/cli/entry_point.py", "generate" ]
ENTRYPOINT [ "python", "/src/library_generation/cli/entry_point.py", "generate" ]
21 changes: 20 additions & 1 deletion .github/scripts/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,30 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Copy python script
shell: bash
run: |
set -x
# repository root
cd ${{ github.action_path }}/../../
rsync -rv \
--exclude=tests \
hermetic_build "${GITHUB_WORKSPACE}"
- name: Copy shell script
shell: bash
run: |
cd ${{ github.action_path }}
cp hermetic_library_generation.sh $GITHUB_WORKSPACE
cp hermetic_library_generation.sh "${GITHUB_WORKSPACE}"
- name: Install python packages
shell: bash
run: |
cd "${GITHUB_WORKSPACE}"
pip install hermetic_build/common
pip install hermetic_build/library_generation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to install library_generation anymore once we move ConfigChange out of this module?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We need to install library_generation because config change is still part of it. Once it moves to common, we don't need to install it.

pip install hermetic_build/release_note_generation
- name: Generate changed libraries
shell: bash
run: |
Expand Down
6 changes: 5 additions & 1 deletion .github/scripts/hermetic_library_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,16 @@ docker run \
--current-generation-config-path="${workspace_name}/${generation_config}" \
--api-definitions-path="${workspace_name}/googleapis"

python hermetic_build/release_note_generation/cli/generate_release_note.py generate \
--baseline-generation-config-path="${baseline_generation_config}" \
--current-generation-config-path="${generation_config}"

# remove api definitions after generation
rm -rf "${api_def_dir}"

# commit the change to the pull request.
rm -rdf output googleapis "${baseline_generation_config}"
git add --all -- ':!pr_description.txt' ':!hermetic_library_generation.sh'
git add --all -- ':!pr_description.txt' ':!hermetic_library_generation.sh' ':!hermetic_build'
changed_files=$(git diff --cached --name-only)
if [[ "${changed_files}" != "" ]]; then
echo "Commit changes..."
Expand Down
53 changes: 22 additions & 31 deletions .github/workflows/verify_library_generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
git checkout -b "${head_ref}" fork/${head_ref}
changed_directories="$(git diff --name-only "fork/${head_ref}" "origin/${base_ref}")"
fi
if [[ ${changed_directories} =~ "library_generation/" ]]; then
if [[ ${changed_directories} =~ "hermetic_build/" ]]; then
echo "should_run=true" >> $GITHUB_OUTPUT
else
echo "should_run=false" >> $GITHUB_OUTPUT
Expand All @@ -46,32 +46,19 @@ jobs:
- 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
python-version: 3.12
- name: install python dependencies
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: install python dependencies
- name: install python modules and dependencies

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

shell: bash
run: |
set -ex
pushd library_generation
pip install -r requirements.txt
pip install .
popd
pip install --upgrade pip
pip install hermetic_build/common
pip install hermetic_build/library_generation
- name: Run integration tests
shell: bash
run: |
set -x
python -m unittest library_generation/test/integration_tests.py
python -m unittest hermetic_build/library_generation/tests/integration_tests.py
library-generation-unit-tests:
runs-on: ubuntu-22.04
needs: should-run-library-generation-tests
Expand All @@ -80,23 +67,23 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.12
- name: install python dependencies
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: install python dependencies
- name: install python modules and dependencies

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

shell: bash
run: |
set -ex
pushd library_generation
pip install -r requirements.txt
pip install .
popd
pip install --upgrade pip
pip install hermetic_build/common
pip install hermetic_build/library_generation
pip install hermetic_build/release_note_generation
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we keep the dependencies together.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created requirements.in and requirements.txt in each module.

- name: Run shell unit tests
run: |
set -x
library_generation/test/generate_library_unit_tests.sh
hermetic_build/library_generation/tests/generate_library_unit_tests.sh
- name: Run python unit tests
run: |
set -x
python -m unittest discover -s library_generation/test/ -p "*unit_tests.py"
python -m unittest discover -s hermetic_build -p "*unit_tests.py"
library-generation-lint-shell:
runs-on: ubuntu-22.04
needs: should-run-library-generation-tests
Expand All @@ -106,7 +93,7 @@ jobs:
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@2.0.0
with:
scandir: 'library_generation'
scandir: 'hermetic_build'
format: tty
severity: error
library-generation-lint-python:
Expand All @@ -115,16 +102,20 @@ jobs:
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.12
- name: install python dependencies
shell: bash
run: |
set -ex
pushd library_generation
pip install -r requirements.txt
popd
pip install --upgrade pip
pip install hermetic_build/common
pip install hermetic_build/library_generation
pip install hermetic_build/release_note_generation
- name: Lint
shell: bash
run: |
# exclude generated golden files
# exclude owlbot until further refaction
black --check library_generation --exclude "(library_generation/test/resources/goldens)"
black --check hermetic_build --exclude "(library_generation/tests/resources/goldens)"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import yaml
from typing import Optional
from library_generation.model.library_config import LibraryConfig
from library_generation.model.gapic_config import GapicConfig
from common.model.library_config import LibraryConfig
from common.model.gapic_config import GapicConfig

REPO_LEVEL_PARAMETER = "Repo level parameter"
LIBRARY_LEVEL_PARAMETER = "Library level parameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# limitations under the License.
from hashlib import sha256
from typing import Optional
from library_generation.model.gapic_config import GapicConfig
from library_generation.model.gapic_inputs import GapicInputs
from common.model.gapic_config import GapicConfig
from common.model.gapic_inputs import GapicInputs


MAVEN_COORDINATE_SEPARATOR = ":"
Expand Down
19 changes: 19 additions & 0 deletions hermetic_build/common/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
Package information of library_generation python scripts
"""

from setuptools import setup

setup(
name="common",
version="0.1",
python_requires=">=3.12",
package_dir={
"common": ".",
},
install_requires=[
"black==24.8.0",
"parameterized==0.9.0",
"PyYAML==6.0.2",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
import unittest

from library_generation.model.gapic_config import GapicConfig
from common.model.gapic_config import GapicConfig


class GapicConfigTest(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path

from parameterized import parameterized
from library_generation.model.gapic_inputs import parse
from common.model.gapic_inputs import parse

script_dir = os.path.dirname(os.path.realpath(__file__))
resources_dir = os.path.join(script_dir, "..", "resources")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import os
import unittest
from pathlib import Path
from library_generation.model.generation_config import from_yaml, GenerationConfig
from library_generation.model.library_config import LibraryConfig
from common.model.generation_config import from_yaml, GenerationConfig
from common.model.library_config import LibraryConfig

script_dir = os.path.dirname(os.path.realpath(__file__))
resources_dir = os.path.join(script_dir, "..", "resources")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.
import unittest

from library_generation.model.gapic_config import GapicConfig
from library_generation.model.library_config import LibraryConfig
from common.model.gapic_config import GapicConfig
from common.model.library_config import LibraryConfig


class LibraryConfigTest(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ It requires docker and python 3.x to be installed.

```
python -m pip install .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The development guide shows commands to be run from the sdk-platform-java/library_generation folder. However this command now must be run from sdk-platform-java/hermetic_build/library_generation (or change pip install . to pip install library_generation and run it from //hermetic_build. We can modify this note to point to hermetic_build.

With this, then we could correct this to

Suggested change
python -m pip install .
python -m pip install library_generation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

python -m pip install -r requirements.txt
python -m unittest test/integration_tests.py
python -m unittest tests/integration_tests.py
```

# Running the unit tests
Expand All @@ -34,7 +33,7 @@ Every unit test script ends with `unit_tests.py`.
To avoid them specifying them individually, we can use the following command:

```bash
python -m unittest discover -s test/ -p "*unit_tests.py"
python -m unittest discover -s tests/ -p "*unit_tests.py"
```

> [!NOTE]
Expand Down
Loading
Loading