如何获取包含环境变量导出的 bash 脚本?
env.sh
...
export VARIABLE=test
...
Run Code Online (Sandbox Code Playgroud)
test_file.py
...
os.environ['VARIABLE'] # Throws KeyError
...
Run Code Online (Sandbox Code Playgroud)
如何使用预提交运行env.sh
来设置以下pytest
钩子可以使用的环境?
- repo: local
hooks:
- id: tests
name: run tests
entry: pytest -v
language: system
types: [python]
Run Code Online (Sandbox Code Playgroud) 这篇文章说只需单击 Logs 列下的 view 即可查看 Google Cloud Scheduler 日志的输出。但是,虽然我可以看到 HTTP 调度函数的状态代码,但我看不到响应。例如,这个请求通常返回一个对象数组,但这是我从 Cloud Scheduler 返回的完整日志:
{
httpRequest: {
status: 200
}
insertId: "------"
jsonPayload: {
@type: "type.googleapis.com/google.cloud.scheduler.logging.AttemptFinished"
jobName: "projects/----/locations/us-west2/jobs/name"
targetType: "HTTP"
url: "http://endpoint.com/test"
}
logName: "projects/----/logs/cloudscheduler.googleapis.com%2Fexecutions"
receiveTimestamp: "2019-07-18T16:00:12.574419040Z"
resource: {
labels: {
job_id: "Name"
location: "us-west2"
project_id: "----"
}
type: "cloud_scheduler_job"
}
severity: "INFO"
timestamp: "2019-07-18T16:00:12.574419040Z"
}
Run Code Online (Sandbox Code Playgroud)
我还如何查看来自 Cloud Scheduler 请求的响应对象/文本?
google-cloud-platform google-cloud-logging google-cloud-functions google-cloud-scheduler
我的项目结构如下:
cloudbuild.yaml
requirements.txt
functions/
folder_a/
test/
main_test.py
main.py
Run Code Online (Sandbox Code Playgroud)
我的 cloudbuild.yaml
steps:
# Install
- name: 'docker.io/library/python:3.7'
args: ['pip', 'install', '-t', '/workspace/lib', '-r', 'requirements.txt']
# Test
- name: '?'
args: ['pytest', 'functions/**/*_test.py']
Run Code Online (Sandbox Code Playgroud)
我使用什么构建器来运行 pytest?我刚刚使用上一个安装步骤安装了它。我应该使用相同的 docker 镜像吗?在 pytest 成功完成所有测试之前,如何阻止我的构建通过?
pytest python-3.x google-cloud-platform google-cloud-functions google-cloud-build
我正在尝试遵循此示例,但在使用时遇到问题combineLatest()
:
Property 'subscribe' does not exist on type 'OperatorFunction<unknown, [unknown, Item[], User[]]>'
这是我的门面:
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { combineLatest, distinctUntilChanged, map } from 'rxjs/operators';
export interface User {
test: string;
}
export interface Item {
test: string;
}
interface State {
items: Item[];
users: User[];
}
let _state: State = {
items: [],
users: [],
};
@Injectable()
export class Facade { …
Run Code Online (Sandbox Code Playgroud) 我的项目结构设置如下:
cloudbuild.yaml
requirements.txt
functions/
folder_a/
test/
main_test.py
main.py
Run Code Online (Sandbox Code Playgroud)
我需要在 my 中指定什么才能cloudbuild.yaml
获取 中每个新编辑的函数functions/
,运行测试,然后将这些函数同步到 Google Cloud Functions?所有函数都是 python37 并使用 http 作为触发器。
python-3.x google-cloud-platform google-cloud-functions google-cloud-build