Skip to content

Commit

Permalink
feat!: replace previous library version tests with new ones. (#139)
Browse files Browse the repository at this point in the history
* !feat: replace previous library version tests with new ones.

This is in preparation for the new library, with the new generator.

* fix working directory for dependency install.

* use python, as generator is not executable

* add the env var so the tests actually run (instead of skip)

* dir path should be all the way to testdata

* install the library we just generated. 🤦

* add informational comment to the test workflow

* licenses and fallback generation, per Averi.
  • Loading branch information
muncus authored Feb 2, 2023
1 parent 8d2abbb commit a547c64
Show file tree
Hide file tree
Showing 22 changed files with 312 additions and 574 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
# Copyright 2020 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json
name: Test Library Generation
on:
pull_request:
paths-ignore:
- "scripts/**"
- ".github/workflows/test_generation.yaml"

import stringcase

from helper import compare_values
jobs:
test-generator:
runs-on: ubuntu-latest
permissions:
contents: none

steps:
- run: echo "No build required."
77 changes: 77 additions & 0 deletions .github/workflows/test_generation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Test Library Generation
# This workflow verifies the tooling that creates the library. It does this by
# running the generator, and verifying that the tests pass on the
# newly-generated library (not the library code currently committed)
on:
pull_request:
paths:
- "scripts/**"
- ".github/workflows/test_generation.yaml"

jobs:
test-generator:
runs-on: ubuntu-latest
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
LIBRARY_CHECKOUT_PATH: library
DATA_SOURCE_CHECKOUT_PATH: google-cloudevents

steps:
- name: Python Library > Checkout Repository
uses: actions/checkout@v3
with:
path: ${{ env.LIBRARY_CHECKOUT_PATH }}

- name: Proto Schemas > Checkout Repository
uses: actions/checkout@v3
with:
repository: googleapis/google-cloudevents
path: ${{ env.DATA_SOURCE_CHECKOUT_PATH }}

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'

- name: Install Generator Dependencies
working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }}
run: pip install -r ./scripts/requirements.txt

- name: Run the generator
working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }}
run: python ./scripts/generate-from-proto.py -o ./src --quiet

- name: Run library tests
working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }}
env:
GOOGLE_EVENTS_TESTDATA: ../${{env.DATA_SOURCE_CHECKOUT_PATH}}/testdata
run: |
pip install -r requirements-dev.txt
pip install ./src
pytest -v .
- name: View generator output
if: ${{ always() }}
working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }}
run: |
git add -N . # Needed if files are untracked
git diff --ignore-all-space --ignore-blank-lines
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
env/
tmp/
.vscode/
.github/*
__pycache__
*.egg-info
node_modules/
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r requirements.txt
black==20.8b1
pylint==2.6.0
pytest==6.2.2
pytest==7.2.1
stringcase==1.2.0
93 changes: 0 additions & 93 deletions tests/data/cloud_audit_v1_logentrydata_pubsubcreatetopic.json

This file was deleted.

71 changes: 0 additions & 71 deletions tests/data/cloud_firestore_v1_documenteventdata_complex.json

This file was deleted.

39 changes: 0 additions & 39 deletions tests/data/cloud_firestore_v1_documenteventdata_simple.json

This file was deleted.

8 changes: 0 additions & 8 deletions tests/data/cloud_pubsub_v1_messagepublisheddata_binary.json

This file was deleted.

10 changes: 0 additions & 10 deletions tests/data/cloud_pubsub_v1_messagepublisheddata_text.json

This file was deleted.

19 changes: 0 additions & 19 deletions tests/data/cloud_storage_v1_storageobjectdata_simple.json

This file was deleted.

Loading

0 comments on commit a547c64

Please sign in to comment.