CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }}
CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}'
+ GITHUB_WORKFLOW_RUN_ID: '${{ github.run_id }}'
run: |
COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
export COMMIT_TIME
_lambda_client = None
+IS_GHA = os.getenv("IS_GHA", "0") == "1"
+
+
def sprint(*args: Any) -> None:
print("[scribe]", *args)
def invoke_lambda(name: str, payload: Any) -> Any:
- res = aws_lambda().invoke(
- FunctionName=name, Payload=json.dumps(payload).encode()
- )
+ res = aws_lambda().invoke(FunctionName=name, Payload=json.dumps(payload).encode())
payload = str(res["Payload"].read().decode())
if res.get("FunctionError"):
raise Exception(payload)
def invoke_rds(events: List[Dict[str, Any]]) -> Any:
+ if not IS_GHA:
+ sprint(f"Not invoking RDS lambda outside GitHub Actions:\n{events}")
+ return
+
return invoke_lambda("rds-proxy", events)
"ref": "string",
"branch": "string",
"workflow_id": "string",
+ "build_environment": "string",
}
- event = [
- {"create_table": {"table_name": table_name, "fields": {**schema, **base}}}
- ]
+ event = [{"create_table": {"table_name": table_name, "fields": {**schema, **base}}}]
invoke_rds(event)
def rds_write(
table_name: str, values_list: List[Dict[str, Any]], only_on_master: bool = True
) -> None:
- sprint("Writing for ", os.getenv("CIRCLE_PR_NUMBER"))
- if not only_on_master and os.getenv("CIRCLE_PR_NUMBER"):
+ sprint("Writing for", os.getenv("CIRCLE_PR_NUMBER"))
+ is_master = os.getenv("CIRCLE_PR_NUMBER", "").strip() == ""
+ if only_on_master and not is_master:
sprint("Skipping RDS write on PR")
return
+ pr = os.getenv("CIRCLE_PR_NUMBER", None)
+ if pr is not None and pr.strip() == "":
+ pr = None
+
base = {
- "pr": os.getenv("CIRCLE_PR_NUMBER"),
+ "pr": pr,
"ref": os.getenv("CIRCLE_SHA1"),
"branch": os.getenv("CIRCLE_BRANCH"),
- "workflow_id": os.getenv("CIRCLE_WORKFLOW_ID"),
+ "workflow_id": os.getenv("GITHUB_WORKFLOW_RUN_ID"),
+ "build_environment": os.environ.get("BUILD_ENVIRONMENT", "").split()[0],
}
events = []
{"write": {"table_name": table_name, "values": {**values, **base}}}
)
- print("Wrote stats for", table_name)
+ sprint("Wrote stats for", table_name)
invoke_rds(events)
def base_data() -> Dict[str, Any]:
- build_env_split = os.environ.get("BUILD_ENVIRONMENT", "").split()
- build_environment = build_env_split[0]
-
return {
- "build_environment": build_environment,
"run_duration_seconds": int(
time.time() - os.path.getmtime(os.path.realpath(__file__))
),
}
data.append({**base_data(), **library_data})
rds_write("binary_size", data)
+ print(json.dumps(data, indent=2))
else:
print("checking dir: " + file_dir)
size = get_size(file_dir)