Closed iddan closed 1 year ago
Hi @iddan
Thank you for opening an issue. It's difficult to debug when most of the values are redacted. Could you please update the issue to unmask the name
and entry_point
fields please? It's unclear to me if the gcloud command is using the same values as the Action.
Hey, the name
is *****-***-cloud-function-dev
and the entry_point
is app
.
If it helps, I can send you the details in a non-public channel.
How are you passing the source to the gcloud command?
This is the step in the GitHub Action:
- name: Deploy to GCF
uses: google-github-actions/deploy-cloud-functions@v0.8.0
with:
min_instances: 4
runtime: nodejs12
name: ****
entry_point: ****
timeout: 540s
env_vars: ****
deploy_timeout: 500 # The function deployment timeout in seconds.
The source is in the directory that I'm deploying
What is the source value in your gcloud
command though? I don't see it in the original issue.
From gcloud:
If you do not specify the --source flag:
I don't specify --source
and use the current directory of the GitHub action.
The current directory will be used for new function deployments.
Did you run actions/checkout
before deploying? That error message is coming from the Google Cloud API, and it seems to correspond to no source being uploaded.
It would be very helpful to have the debug logs from the gcloud functions deploy
command and the debug logs for the GitHub Actions run.
I did run actions/checkout
. As I said, deploying with the gcloud
CLI works as expected.
Hi @iddan without complete information, it's very difficult to try and debug this. The error message is coming from Cloud Build, not our GitHub Action. I found a number of posts on Stackoverflow which have some suggested workarounds. The root cause all appears to be a mismatch on the directory.
gcloudignore
or gitignore
file that is excluding files?package.json
?entry_point
flag?gcloud functions deploy
?I am trying to deploy to Google Cloud Functions.
The file structure:
The entry point code (index.js
)
// @ts-check
/**
* @module
* Entry point for Google Cloud Functions
*/
const pino = require("pino");
const pinoDebug = require("pino-debug");
const { default: defaultPinoConf } = require("./lib/pino-stackdriver");
// Setup logging before importing other modules
const logger = pino(defaultPinoConf);
pinoDebug(logger);
const { default: app } = require("./lib/app");
// see the following if having logging issues, pino logs can be adapted to google log explorer:
// https://github.com/pinojs/pino/blob/master/docs/help.md#stackdriver
logger.info("Bootstrapping cloud function");
exports.app = async (req, res) => {
await server.load(app);
return server.expressApp(req, res);
};
entry_point
flag value: app
The package.json you provided does not resolve:
While resolving: ts-jest@27.1.3
Found: @types/jest@26.0.24
node_modules/@types/jest
dev @types/jest@"^26.0.24" from the root project
Could not resolve dependency:
peerOptional @types/jest@"^27.0.0" from ts-jest@27.1.3
node_modules/ts-jest
dev ts-jest@"^27.1.3" from the root project
Conflicting peer dependency: @types/jest@27.4.1
node_modules/@types/jest
peerOptional @types/jest@"^27.0.0" from ts-jest@27.1.3
node_modules/ts-jest
dev ts-jest@"^27.1.3" from the root project
I'm using yarn
version v1.22.17
and it seems to install correctly.
Hi @iddan I'm trying to be helpful, but you continue to add new constraints that were not originally disclosed, which makes it extremely difficult to try and help you debug. I'm trying to establish a reproduction case, but that's very difficult when I don't have all the information. Do you have a minimum reproduction case you can put together, possibly as an open source repo, so we can try and get to the bottom of this please?
Also, we posting really long code snippets, please consider using collapse sections to make scrolling easier.
Hey @sethvargo, thank you for trying to help. I'm sorry I'm not giving the full context here it's just hard to share information about a proprietary project in a public channel. I would love to share the full context in a private channel. I can also try to reproduce the bug in a public channel. What would be better for you?
Hi @iddan
We prefer to work in the public, so as not to risk exchanging proprietary intellectual property. If you're able to put together a public repo that demonstrates the issue, that would be very helpful.
Hi @iddan were you able to make any progress on this?
Hey @sethvargo. Unfortunately, I didn't get to make progress with it.
Hi @iddan I'm sorry. Without a reliable reproduction case, it will be difficult for us to try and debug this.
I met the same issue when trying to use 'google-github-actions/deploy-cloud-functions@v0'
to deploy functions to GCP, Is this known to be repaired bug?
Hi @JohnJiangLA - please share the debug logs for your invocation so we can investigate.
Hi folks - I'm going to close this issues as not reproducible. If it's still occurring, please provide an action.yml with a reproduction case or access to the complete debug logging so we can try and trace the problem.
~I'm experiencing this issue currently when using a TypeScript project. I run the TS compiler previous to the deployment, and generate an index.js
file which I attempt to download, to no avail. I can share the debug logs~
@sethvargo Let me know if you need any further info from my side, as I would love to be able to use TS for development. Thanks in advance!
EDIT: Fixed below
Managed to fix this, so leaving if for future reference:
It is likely you have a build
script. This will execute automatically when deploying to GCP unless you add "gcp-build":""
in your package.json
's scripts or change the build
one's name. This is what caused all the weird behaviours for me.
Now all I have to do is compile the TS (done in the same job, on the steps prior, or on another job and downloading the artifact) and upload the JS, ensuring the package.json
has a reference to the entrypoint file and the deployment step to the exported function (in my case, "main": "dist/index.js"
and entry_point: main
). It is also useful to have a .gcloudignore that avoids uploading unnecessary elements. I haven't tried using external node_modules, so I still may have made a mistake on that side, but other than that this should be the blueprint for using TypeScript in GCP Functions:
TL;DR
When deploying using the CLI the deployment works:
When deploying with the custom action the deployment fails:
with:
Expected behavior
The function to deploy like in the CLI
Observed behavior
The deployment fails with:
Action YAML
Log output
Additional information
No response