Skip to content

Commit

Permalink
Merge pull request #524 from IvanUkhov/yup-oauth2
Browse files Browse the repository at this point in the history
Update to Hyper 1
  • Loading branch information
Byron authored Oct 6, 2024
2 parents 6993a8f + d6bd590 commit 450748c
Show file tree
Hide file tree
Showing 49 changed files with 1,462 additions and 1,148 deletions.
File renamed without changes.
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
meta-check:
name: Check the generative code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make meta-check

check:
name: Check the generated code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- run: |
make gen-all-api
make cargo-api ARGS=check
make cargo-api ARGS='check --no-default-features'
make gen-all-cli
make cargo-cli ARGS=check
env:
CI: true
meta-test:
name: Test the generative code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make meta-test

test:
name: Test the generated code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- run: |
make gen-all-api
make cargo-api ARGS=test
env:
CI: true
document:
name: Document the generated code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- run: |
make gen-all-api
make cargo-api ARGS=doc
make docs-all
env:
CI: true
RUSTDOCFLAGS: -A warnings
37 changes: 0 additions & 37 deletions .github/workflows/rust.yml

This file was deleted.

46 changes: 23 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
**/Cargo.lock
**/build_html/
**/target/
*.go
.*.deps
.DS_Store
/.vscode/
/.idea/
.timestamp
gen/doc
*.go
**/target/
/.idea/
/.vscode/
gen/**/docs/
**/build_html/
.*.deps
**/Cargo.lock
gen/doc

# Python: Makefile lead dirs
.pyenv-*
Expand All @@ -18,43 +18,43 @@ gen/**/docs/
*.sublime-workspace

# Python: Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
*.py[cod]
__pycache__/

# Python: Distribution / packaging
*.egg
*.egg-info/
.Python
.eggs/
.installed.cfg
MANIFEST
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Python: Installer logs
pip-log.txt
pip-delete-this-directory.txt
pip-log.txt

# Python: Unit test / coverage reports
htmlcov/
.tox/
.nox/
*.cover
.cache
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.nox/
.pytest_cache/
.tox/
coverage.xml
htmlcov/
nosetests.xml

# Python: pyenv
.python-version
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
exclude: etc/api|gen/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[workspace]

resolver = "2"
members = [
"google-apis-common",
"google-clis-common",
"src/rust/preproc"
]
exclude = ["gen"]
exclude = ["gen"]
1 change: 0 additions & 1 deletion LICENSE-APACHE
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,3 @@
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.

25 changes: 18 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PYTHON_BIN := $(VENV_DIR)/bin/python
PYTHON := . $(VENV_DIR)/bin/activate; python
PYTEST := $(PYTHON) -m pytest

MAKO_RENDER := etc/bin/mako-render
MAKO_RENDER := etc/bin/mako-render.py
API_VERSION_GEN := etc/bin/api_version_to_yaml.py
SORT_JSON_FILE := etc/bin/sort_json_file.py
TPL := $(PYTHON) $(MAKO_RENDER)
Expand Down Expand Up @@ -61,14 +61,14 @@ help:
$(info help - print this help)

$(PREPROC): $(PREPROC_DIR)/src/main.rs
cd "$(PREPROC_DIR)" && cargo build --release
cd "$(PREPROC_DIR)" && cargo build --release

$(VENV_BIN):
python3 -m pip install --user virtualenv==$(VENV_VERSION)
python -m pip install --user virtualenv==$(VENV_VERSION)
touch $@

$(PYTHON_BIN): $(VENV_BIN) requirements.txt
python3 -m venv $(VENV_DIR)
python -m venv $(VENV_DIR)
$@ -m pip install -r requirements.txt

$(MAKO_RENDER): $(PYTHON_BIN) $(wildcard $(GEN_LIB_SRC)/*)
Expand All @@ -93,10 +93,21 @@ license: LICENSE.md

regen-apis: | clean-all-api clean-all-cli gen-all-api gen-all-cli license

test-gen: $(PYTHON_BIN)
export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1; $(PYTEST) src
meta-test: meta-test-python meta-test-rust

test: test-gen
meta-test-python: $(PYTHON_BIN)
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 $(PYTEST) src

meta-test-rust:
cargo test

meta-check: meta-check-python meta-check-rust

meta-check-python: $(PYTHON_BIN)
$(VENV_DIR)/bin/pre-commit run --all-files --show-diff-on-failure

meta-check-rust:
cargo clippy -- -D warnings

typecheck: $(PYTHON_BIN)
$(PYTHON) -m pyright $(GEN_LIB_SRC)
Expand Down
6 changes: 4 additions & 2 deletions etc/api/api-list-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
api:
list:
spanner:
- v1
- v1
storage:
- v1
youtube:
- v3
- v3
6 changes: 0 additions & 6 deletions etc/api/type-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,3 @@ make:
cargo:
keywords: [protocol, web, api]
doc_base_url: https://docs.rs
dependencies:
- hyper = "^ 0.14"
- http = "^0.2"
- tokio = "^1.0"
- tower-service = "^0.3.1"
- url = "= 1.7"
8 changes: 1 addition & 7 deletions etc/api/type-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,5 @@ make:
output_dir: src
cargo:
keywords: [cli]
is_executable: YES
is_executable: true
doc_base_url: http://byron.github.io/google-apis-rs
dependencies:
- clap = "^2.0"
- http = "^0.2"
- hyper = { version = "0.14", features = ["full"] }
- tokio = { version = "^ 1.0", features = ["full"] }
- tower-service = "^0.3.1"
27 changes: 18 additions & 9 deletions etc/bin/api_version_to_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
# Generate yaml output suitable for use in shared.yaml
#

import sys
import os
import sys

import yaml

isfile = os.path.isfile
isdir = os.path.isdir
join = os.path.join

if __name__ != '__main__':
if __name__ != "__main__":
raise AssertionError("Not for import")

if len(sys.argv) != 4:
sys.stderr.write(
"USAGE: <program> <api_dir> <api-list.yaml> <dest.yaml>, i.e. <program> etc/api etc/api/api-list.yaml out.yaml\n")
"USAGE: <program> <api_dir> <api-list.yaml> <dest.yaml>, i.e. <program> etc/api etc/api/api-list.yaml out.yaml\n"
)
sys.exit(1)

api_base = sys.argv[1]
Expand All @@ -25,7 +27,7 @@

yaml_path = sys.argv[2]
if isfile(yaml_path):
api_data = yaml.load(open(yaml_path, 'r'), Loader=yaml.FullLoader)['api']['list']
api_data = yaml.load(open(yaml_path, "r"), Loader=yaml.FullLoader)["api"]["list"]
else:
api_data = dict()

Expand All @@ -34,8 +36,15 @@
api_path = join(api_base, api_name)
if not isdir(api_path):
continue
all_versions = sorted((v for v in os.listdir(api_path) if isdir(
join(api_path, v)) and isfile(join(api_path, v, "%s-api.json" % api_name))), reverse=True)
all_versions = sorted(
(
v
for v in os.listdir(api_path)
if isdir(join(api_path, v))
and isfile(join(api_path, v, "%s-api.json" % api_name))
),
reverse=True,
)
if not all_versions:
try:
del api_data[api_name]
Expand All @@ -44,7 +53,7 @@
continue
last_version = None
for v in all_versions:
if 'beta' not in v and 'alpha' not in v:
if "beta" not in v and "alpha" not in v:
last_version = v
break
# end for each version
Expand All @@ -61,9 +70,9 @@
del api_data[api_name]
# end for each item in api-base

fp = open(sys.argv[3], 'wt')
fp = open(sys.argv[3], "wt")
fp.write("# DO NOT EDIT !!!\n")
fp.write("# Created by '%s'\n" % ' '.join(sys.argv))
fp.write("# Created by '%s'\n" % " ".join(sys.argv))
fp.write("# DO NOT EDIT !!!\n")
yaml.dump(dict(api=dict(list=api_data)), fp, default_flow_style=False)
fp.close()
Loading

0 comments on commit 450748c

Please sign in to comment.