Skip to content

Commit

Permalink
Check all possible output dirs (#61)
Browse files Browse the repository at this point in the history
3.0.1 release broke builds using cordova-ios<7 (but using cordova>7).
Removed the bad version check, while retaining compatibility with cordova-ios 6 and 7.
  • Loading branch information
lpusok committed Mar 6, 2024
1 parent 45cbb97 commit add8d31
Show file tree
Hide file tree
Showing 23 changed files with 541 additions and 491 deletions.
62 changes: 0 additions & 62 deletions CHANGELOG.md

This file was deleted.

25 changes: 4 additions & 21 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@ default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

app:
envs:
- STEP_VERSION: 2.0.0
- ORIG_BITRISE_SOURCE_DIR: $BITRISE_SOURCE_DIR

workflows:
test:
envs:
- SAMPLE_APP_URL: https://github.com/bitrise-samples/sample-apps-cordova-with-karma-jasmine.git
- SAMPLE_APP_BRANCH: master
before_run:
- audit-this-step
steps:
- go-list: {}
- golint: {}
- errcheck: {}
- go-test: {}
- git::https://github.com/bitrise-steplib/steps-check.git: { }
after_run:
- test-with-npm
- test-with-yarn
Expand Down Expand Up @@ -69,7 +63,7 @@ workflows:
inputs:
- content: git clone --single-branch -b "${SAMPLE_APP_BRANCH}" "${SAMPLE_APP_URL}" .
- script:
run_if: '{{enveq "USE_YARN" "true"}}'
run_if: '{{enveq "USE_YARN" "true"}}' # yamllint disable-line rule:quoted-strings
inputs:
- content: |-
#!/usr/bin/env bash
Expand All @@ -87,12 +81,12 @@ workflows:
envman unset --key ANDROID_NDK_HOME
- yarn:
run_if: '{{enveq "USE_YARN" "true"}}'
run_if: '{{enveq "USE_YARN" "true"}}' # yamllint disable-line rule:quoted-strings
inputs:
- command: install
- cordova-prepare:
title: Cordova prepare
run_if: '{{enveq "RUN_PREPARE_STEP" "true"}}'
run_if: '{{enveq "RUN_PREPARE_STEP" "true"}}' # yamllint disable-line rule:quoted-strings
inputs: []
- path::./:
title: Cordova archive
Expand Down Expand Up @@ -142,14 +136,3 @@ workflows:
title: Change back to original working directory
inputs:
- path: ${ORIG_BITRISE_SOURCE_DIR}

# ----------------------------------------------------------------
# --- workflows to Share this step into a Step Library
audit-this-step:
steps:
- script:
inputs:
- content: |-
#!/bin/bash
set -ex
stepman audit --step-yml ./step.yml
4 changes: 2 additions & 2 deletions cordova/cordova_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ func Test_platformCustomOptions(t *testing.T) {
{
"Project with only packageType option and APK output",
*New().SetCustomOptions("--", `--packageType="bundle"`).SetPlatforms("android").SetAndroidAppType("apk"),
`cordova "compile" "android" "--" "--packageType=apk" "--packageType=\"bundle\""`,
`cordova "compile" "android" "--" "--packageType=apk" "--packageType="bundle""`,
},
{
"Project with only packageType option and AAB output",
*New().SetCustomOptions("--", `--packageType="bundle"`).SetPlatforms("android").SetAndroidAppType("bundle"),
`cordova "compile" "android" "--" "--packageType=bundle" "--packageType=\"bundle\""`,
`cordova "compile" "android" "--" "--packageType=bundle" "--packageType="bundle""`,
},
}

Expand Down
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
module github.com/bitrise-steplib/steps-cordova-archive

go 1.16
go 1.18

require (
github.com/bitrise-io/go-steputils v0.0.0-20210514150206-5b6261447e77
github.com/bitrise-io/go-utils v0.0.0-20210517121358-79fa64f4a5f6
github.com/bitrise-io/go-steputils v1.0.6
github.com/bitrise-io/go-utils v1.0.13
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/tools v0.1.1 // indirect
)
54 changes: 14 additions & 40 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
github.com/bitrise-io/go-steputils v0.0.0-20210514150206-5b6261447e77 h1:+wd+ADdtJCRL9JEghE1RMbR4ywXBYNvIBelAW/UkWr8=
github.com/bitrise-io/go-steputils v0.0.0-20210514150206-5b6261447e77/go.mod h1:H0iZjgsAR5NA6pnlD/zKB6AbxEsskq55pwJ9klVmP8w=
github.com/bitrise-io/go-utils v0.0.0-20210507100250-37de47dfa6ce/go.mod h1:15EZZf02noI5nWFqXMZEoyb1CyqYRXTMz5Fyu4CWFzI=
github.com/bitrise-io/go-utils v0.0.0-20210517121358-79fa64f4a5f6 h1:wDvbiDFw+DPgWm8a6ZF4xWw9KU/Ju/LwxkQrZ3ZKGjM=
github.com/bitrise-io/go-utils v0.0.0-20210517121358-79fa64f4a5f6/go.mod h1:DRx7oFuAqk0dbKpAKCqWl0TgrowfJUb/MqYPRscxJOQ=
github.com/bitrise-io/go-steputils v1.0.6 h1:eBRL70DWwEd7DWYGd5Ds7OSIY5HElzhoDOI6UuITKQg=
github.com/bitrise-io/go-steputils v1.0.6/go.mod h1:YIUaQnIAyK4pCvQG0hYHVkSzKNT9uL2FWmkFNW4mfNI=
github.com/bitrise-io/go-utils v1.0.1/go.mod h1:ZY1DI+fEpZuFpO9szgDeICM4QbqoWVt0RSY3tRI1heY=
github.com/bitrise-io/go-utils v1.0.13 h1:1QENhTS/JlKH9F7+/nB+TtbTcor6jGrE6cQ4CJWfp5U=
github.com/bitrise-io/go-utils v1.0.13/go.mod h1:ZY1DI+fEpZuFpO9szgDeICM4QbqoWVt0RSY3tRI1heY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
github.com/hashicorp/go-retryablehttp v0.7.0/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -17,46 +18,19 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
1 change: 0 additions & 1 deletion gows.yml

This file was deleted.

40 changes: 40 additions & 0 deletions ios_outputs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"path/filepath"
"strings"

"github.com/bitrise-io/go-utils/log"
"github.com/bitrise-io/go-utils/pathutil"
)

func getIosOutputCandidateDirsPaths(workDir string, target string, configuration string) []string {
targetPlatform := "iphonesimulator"
if target == "device" {
targetPlatform = "iphoneos"
}

// disable linting deprecated Title check SA1019
cordovaIOS7targetComponent := strings.Title(configuration) + "-" + targetPlatform //nolint:staticcheck

return []string{
filepath.Join(workDir, "platforms", "ios", "build", target), // cordova-ios <7
filepath.Join(workDir, "platforms", "ios", "build", cordovaIOS7targetComponent), // cordova-ios =>7
}
}

func findFirstExistingDir(candidateDirPaths []string) string {
for _, path := range candidateDirPaths {
exist, err := pathutil.IsDirExists(path)
if err != nil {
log.Warnf("Failed to check if dir (%s) exist: %s", path, err)
continue
}

if exist {
return path
}
}

return ""
}
47 changes: 47 additions & 0 deletions ios_outputs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package main

import (
"testing"
)

func Test_getIosOutputCandidateDirsPaths(t *testing.T) {
testCases := []struct {
name string
target string
configuration string
want []string
}{
{
name: "Device + debug",
target: "device",
configuration: "debug",
want: []string{
"/workdir/platforms/ios/build/device",
"/workdir/platforms/ios/build/Debug-iphoneos",
},
},
{
name: "Emulator + release",
target: "emulator",
configuration: "release",
want: []string{
"/workdir/platforms/ios/build/emulator",
"/workdir/platforms/ios/build/Release-iphonesimulator",
},
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got := getIosOutputCandidateDirsPaths("/workdir", tc.target, tc.configuration)
if len(got) != len(tc.want) {
t.Fatalf("got len %v not equal to want len %v", got, tc.want)
}
for i, wantElem := range tc.want {
if wantElem != got[i] {
t.Fatalf("got %v not equal to want %v", got, tc.want)
}
}
})
}
}
32 changes: 5 additions & 27 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -173,25 +172,6 @@ func fail(format string, v ...interface{}) {
os.Exit(1)
}

func findIosTargetPathComponent(target string, configuration string, cordovaVersion string) string {
if cordovaVersion == "" {
return target
}

majorVersion, err := strconv.Atoi(strings.Split(cordovaVersion, ".")[0])
if err != nil || majorVersion < 7 {
// Pre-Cordova-7 behavior: path segment is just "device" or "emulator"
return target
}

targetPlatform := "iphonesimulator"
if target == "device" {
targetPlatform = "iphoneos"
}

return strings.Title(configuration) + "-" + targetPlatform
}

func main() {
var configs config
if err := stepconf.Parse(&configs); err != nil {
Expand Down Expand Up @@ -321,15 +301,13 @@ func main() {

// collect outputs
var ipas, apps []string
iosOutputDirExist := false
iosOutputDir := filepath.Join(workDir, "platforms", "ios", "build", findIosTargetPathComponent(configs.Target, configs.Configuration, configs.CordovaVersion))
if exist, err := pathutil.IsDirExists(iosOutputDir); err != nil {
fail("Failed to check if dir (%s) exist, error: %s", iosOutputDir, err)
} else if exist {
iosOutputDirExist = true

iosOutputDir := findFirstExistingDir(getIosOutputCandidateDirsPaths(workDir, configs.Target, configs.Configuration))
iosOutputDirExist := iosOutputDir != ""
if iosOutputDirExist {
fmt.Println()
log.Infof("Collecting ios outputs")
log.Infof("Collecting iOS outputs")
log.Printf("iOS output directory: %s", iosOutputDir)

ipas, err = findArtifact(iosOutputDir, "ipa", compileStart)
if err != nil {
Expand Down
Loading

0 comments on commit add8d31

Please sign in to comment.