From b1b4df356ba0b8d6dc7b7ffddf294c6d2d507be8 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Fri, 5 Apr 2024 20:44:51 -0400 Subject: [PATCH 1/2] chore: add a generic workflow to generate libraries --- .../hermetic_library_generation.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/hermetic_library_generation.yaml diff --git a/.github/workflows/hermetic_library_generation.yaml b/.github/workflows/hermetic_library_generation.yaml new file mode 100644 index 000000000000..daad80097aef --- /dev/null +++ b/.github/workflows/hermetic_library_generation.yaml @@ -0,0 +1,57 @@ +name: Hermetic library generation upon generation config change through pull requests + +on: + pull_request: + types: + - synchronize + paths: + - generation_config.yaml + +jobs: + library_generation: + runs-on: ubuntu-latest + env: + library_generation_image_tag: latest + repo_volumes: "-v repo-google-cloud-java:/workspace/google-cloud-java" + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + - name: get baseline generation config + uses: actions/checkout@v4 + with: + ref: ${{ github.base_ref }} + path: baseline + sparse-checkout: generation_config.yaml + - name: setup docker environment + shell: bash + run: | + # we create a volume pointing to `pwd` (google-cloud-java) that will + # be referenced by the container and its children + docker volume rm repo-google-cloud-java + docker volume create --name "repo-google-cloud-java" --opt "type=none" --opt "device=$(pwd)" --opt "o=bind" + - name: generate libraries + shell: bash + run: | + docker run --rm \ + ${repo_volumes} \ + -v /tmp:/tmp \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -e "RUNNING_IN_DOCKER=true" \ + -e "REPO_BINDING_VOLUMES=${repo_volumes}" \ + gcr.io/cloud-devrel-public-resources/java-library-generation:"${library_generation_image_tag}" \ + python /src/cli/entry_point.py generate \ + --baseline-generation-config-yaml=/workspace/google-cloud-java/baseline/generation_config.yaml \ + --current-generation-config-yaml=/workspace/google-cloud-java/generation_config.yaml + --repository-path=/workspace/google-cloud-java + - name: Commit the change and push to the pull request branch + shell: bash + run: | + [ -z "`git config user.email`" ] && git config --global user.email "cloud-java-bot@google.com" + [ -z "`git config user.name`" ] && git config --global user.name "cloud-java-bot" + git add java-* pom.xml gapic-libraries-bom/pom.xml versions.txt generation_config.yaml + # use --allow-empty because (rarely) there's no change. + git commit --allow-empty -m "generate libraries based on configuration change" + git push + env: + GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} From 7c0c2cb96ed3edf4e749906e0d378ab0a37fb723 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Tue, 9 Apr 2024 13:57:12 -0400 Subject: [PATCH 2/2] remove generation logic --- .../hermetic_library_generation.yaml | 32 ++----------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/.github/workflows/hermetic_library_generation.yaml b/.github/workflows/hermetic_library_generation.yaml index daad80097aef..e469a9e7fc2b 100644 --- a/.github/workflows/hermetic_library_generation.yaml +++ b/.github/workflows/hermetic_library_generation.yaml @@ -23,35 +23,7 @@ jobs: ref: ${{ github.base_ref }} path: baseline sparse-checkout: generation_config.yaml - - name: setup docker environment + - name: diff shell: bash run: | - # we create a volume pointing to `pwd` (google-cloud-java) that will - # be referenced by the container and its children - docker volume rm repo-google-cloud-java - docker volume create --name "repo-google-cloud-java" --opt "type=none" --opt "device=$(pwd)" --opt "o=bind" - - name: generate libraries - shell: bash - run: | - docker run --rm \ - ${repo_volumes} \ - -v /tmp:/tmp \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -e "RUNNING_IN_DOCKER=true" \ - -e "REPO_BINDING_VOLUMES=${repo_volumes}" \ - gcr.io/cloud-devrel-public-resources/java-library-generation:"${library_generation_image_tag}" \ - python /src/cli/entry_point.py generate \ - --baseline-generation-config-yaml=/workspace/google-cloud-java/baseline/generation_config.yaml \ - --current-generation-config-yaml=/workspace/google-cloud-java/generation_config.yaml - --repository-path=/workspace/google-cloud-java - - name: Commit the change and push to the pull request branch - shell: bash - run: | - [ -z "`git config user.email`" ] && git config --global user.email "cloud-java-bot@google.com" - [ -z "`git config user.name`" ] && git config --global user.name "cloud-java-bot" - git add java-* pom.xml gapic-libraries-bom/pom.xml versions.txt generation_config.yaml - # use --allow-empty because (rarely) there's no change. - git commit --allow-empty -m "generate libraries based on configuration change" - git push - env: - GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} + diff generation_config.yaml baseline/generation_config.yaml