Skip to content

Don't try to deploy nonexistent files #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bytes"
"errors"
"fmt"
"html/template"
"os"
Expand Down Expand Up @@ -340,6 +341,11 @@ func logDeployFiles(files []deployment.DeployableItem, logger loggerV2.Logger) {
func clearDeployFiles(filesToDeploy []string, logger loggerV2.Logger) []string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not we perform the file existence check earlier?

At the moment the step output looks like this:

List of files to deploy
- /bitrise/src/Apps/app-stg-release-unsigned.apk

Deploying files
Uploading apk file: /bitrise/src/Apps/app-stg-release-unsigned.apk
analyzing apk
Failed to parse APK info: failed to unzip the APK, error: open /bitrise/src/Apps/app-stg-release-unsigned.apk: no such file or directory
deploy failed, error: failed to get apk infos, output: asset W 01-31 12:06:07  2347  2347] Asset path /bitrise/src/Apps/app-stg-release-unsigned.apk is neither a directory nor file (type=1).
ERROR: dump failed because assets could not be loaded, error: exit status 1
deploy failed, error: failed to get apk infos, output: asset W 01-31 12:06:07  2347  2347] Asset path /bitrise/src/Apps/app-stg-release-unsigned.apk is neither a directory nor file (type=1).
ERROR: dump failed because assets could not be loaded, error: exit status 1

The step lists that it will deploy the /bitrise/src/Apps/app-stg-release-unsigned.apk file and then later it states it could not deploy the file. Why did it find the file in the first place then?

I would say that we should check if the file exists when we collect the deployable files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my thinking as well! clearDeployFiles() is called right after collecting the files based on the step inputs:

filesToDeploy, err := collectFilesToDeploy(absDeployPth, config, tmpDir, logger)
if err != nil {
fail(logger, "%s", err)
}
clearedFilesToDeploy := clearDeployFiles(filesToDeploy, logger)

And it's called before printing the list of deployable files (L168)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was thinking of doing it earlier like in the collectFilesToDeploy method. My thinking was that why are we even finding files which do not exist. The clear function was created more for filtering out the useless files.

var clearedFilesToDeploy []string
for _, pth := range filesToDeploy {
_, err := os.Stat(pth)
if err != nil && errors.Is(err, os.ErrNotExist) {
logger.Warnf("file not found, skipping: %s", pth)
continue
}
for _, fileBaseNameToSkip := range fileBaseNamesToSkip {
if filepath.Base(pth) == fileBaseNameToSkip {
logger.Warnf("skipping: %s", pth)
Expand Down
2 changes: 1 addition & 1 deletion uploaders/apkuploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (u *Uploader) DeployAPK(item deployment.DeployableItem, artifacts []string,
return ArtifactURLs{}, err
}

u.logger.Printf("apk infos: %+v", printableAppInfo(apkInfo.AppInfo))
u.logger.Printf("APK metadata: %+v", printableAppInfo(apkInfo.AppInfo))

splitMeta, err := androidartifact.CreateSplitArtifactMeta(u.logger, pth, artifacts)
if err != nil {
Expand Down